Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ต้องการคำนวณยอดขายย้อนหลัง 3 เดือน ต้องทำอย่างไรคะ เขียนโดยใช้ c#



 

ต้องการคำนวณยอดขายย้อนหลัง 3 เดือน ต้องทำอย่างไรคะ เขียนโดยใช้ c#

 



Topic : 079154



โพสกระทู้ ( 2 )
บทความ ( 0 )



สถานะออฟไลน์




ถ้าต้องการคำนวณยอดขายย้อนหลัง 3 เดือน ต้องทำอย่างไรคะ เขียนโดยใช้ c# นะค่ะ ตอนนี้เขียนไปบ้างแล้วแต่ยอดที่ขึ้นเป็น "0" เพราะโค้ดยังไม่สมบูรณ์ พี่ๆช่วยดูให้หน่อยนะคะ

Code (C#)
 private void get3month()
        {
            string strd, strd1, strd2, strd3, strm, stry, strdt;
            strd1 = "/31/";
            strd2 = "/30/";
            strd3 = "/29/";
            strd = cb_date.EditValue.ToString().Substring(3, 2);
            strm = cb_date.EditValue.ToString().Substring(0, 2);
            stry = cb_date.EditValue.ToString().Substring(6, 4);

            if ()
            {
            }
            strdt = strm + strd + stry;
            txtdate.EditValue = strdt;

              DT = (Convert.ToInt32(StrMount) - Mount);//month now - month select = month show
              if ((DT < 0))//month show < 0
              {
                  DT = 0; //month show = 0
                  DT = (Mount - Convert.ToInt32(StrMount));//month show = month select - month now
                  Str3 = cbdate_str.Text.Substring(6, 4);//year now
                  DT2 = (12 - DT);//12 - montn show = month show2
                  DT3 = (Convert.ToInt32(Str3) - 1);//year now - 1 = year show
                  X = DT2.ToString().Length;
                  if ((X == 1))
                  {
                      Dateback = ("0" + DT2.ToString());
                      Str2 = (Dateback
                                  + (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
                  }
                  else
                  {
                      Str2 = (DT2.ToString()
                                  + (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
                  }
                  MessageBox.Show(Str2);
                  dsca = ojsql2.GetDataSet("select month(ddate) dmonth,sum(iquantity) qty,sum(isum )amt from salebillvouch a inner join salebillvouchs b on a.sbvid=b.sbvid where cinvcode='" + txtpd_code.Text + "' and ddate>='" + cbdate_str.EditValue + "' and ddate<='" + Str2 + "' group by month(ddate)", "data");
                  gvFile.DataSource = dsca.Tables[0];

              }
              else
              {
                  Str3 = cbdate_str.Text.Substring(6, 4);
                  DT3 = (Convert.ToInt32(Str3) - 1);
                  X = DT.ToString().Length;
                  if ((X == 1))
                  {
                      Dateback = ("0" + DT.ToString());
                      if ((Dateback == "00"))
                      {
                          Str2 = ("12"
                                      + (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
                      }
                      else
                      {
                          Str2 = (Dateback
                                      + (cbdate_str.Text.Substring(2, 3) + cbdate_str.Text.Substring(5, 5)));
                      }
                  }
                  else if ((DT.ToString() == "00"))
                  {
                      Str2 = ("12"
                                  + (cbdate_str.Text.Substring(2, 4) + DT3.ToString()));
                  }
                  else
                  {
                      Str2 = (DT.ToString()
                                  + (cbdate_str.Text.Substring(2, 3) + cbdate_str.Text.Substring(5, 5)));
                  }
                  MessageBox.Show(Str2);
                  dsca = ojsql2.GetDataSet("select month(ddate) dmonth,sum(iquantity) qty,sum(isum )amt from salebillvouch a inner join salebillvouchs b on a.sbvid=b.sbvid where cinvcode='" + txtpd_code.Text + "' and ddate>='" + Str2 + "' and ddate<='" + cbdate_str.EditValue + "' group by month(ddate)", "data");
                  gvFile.DataSource = dsca.Tables[0];
              }
        }




Tag : .NET, Ms SQL Server 2008, C#, VS 2008 (.NET 3.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-05-30 13:38:18 By : noopin View : 1482 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ลองใช้พวก DateAdd เพื่อหาวันที่ย้อนหลัง 3 เดือนครับ จากนั้นก็เอาไป WHERE ใน Code ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-30 15:57:13 By : mr.win
 


 

No. 2



โพสกระทู้ ( 2 )
บทความ ( 0 )



สถานะออฟไลน์


ใน c# สามารถเขียนโค้ดแบบ php ได้ไม๊คะ พอดีฟังก์ชั่นนี้ใน php ทำได้แต่ไม่รู้โค้ดของ c#


<? $today = date("m/d/Y"); //เริ่มสร้าง function วันที่ปัจจุบันซึ่งจะตรงตามค่า ของเครื่อง Server
$start3m = date("m/d/Y",strtotime("-3 month",strtotime($today))); //สร้าง function ปัจจุบัน m/d/Y แล้วนำมาลบ -3 month
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-05-30 16:58:16 By : noopin
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ต้องการคำนวณยอดขายย้อนหลัง 3 เดือน ต้องทำอย่างไรคะ เขียนโดยใช้ c#
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่