private void button4_Click(object sender, EventArgs e) { FormCollection fc = System.Windows.Forms.Application.OpenForms; bool kq = false; foreach (Form frm in fc) { if (frm.Text == "kaPriod and Customer code picker") { kq = true; frm.Focus(); } } if (!kq) { View.kaPriodandcustomerpicker kaPriodpicker = new View.kaPriodandcustomerpicker(); // Datepick kaPriodpicker.ShowDialog(); string priod = kaPriodpicker.priod; string customercode = kaPriodpicker.customercode; DateTime fromdate = kaPriodpicker.fromdate; DateTime todate = kaPriodpicker.todate; bool chon = kaPriodpicker.kq; if (chon) { string connection_string = Utils.getConnectionstr(); LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string); #region // view sales volume var rs33 = from tbl_kasale in dc.tbl_kasales where tbl_kasale.Priod == priod && tbl_kasale.Sold_to == double.Parse(customercode) && tbl_kasale.Cogs != null select new { tbl_kasale.Priod, tbl_kasale.Sold_to, tbl_kasale.Sales_Org, tbl_kasale.Sales_District, tbl_kasale.Sales_District_desc, tbl_kasale.Cust_Name, tbl_kasale.Outbound_Delivery, tbl_kasale.Delivery_Date, tbl_kasale.Invoice_Doc_Nr, tbl_kasale.Invoice_Date, tbl_kasale.Key_Acc_Nr, ///tbl_kasale.c, tbl_kasale.Mat_Group, tbl_kasale.Mat_Group_Text, tbl_kasale.Mat_Number, tbl_kasale.Mat_Text, tbl_kasale.Currency, PCs = tbl_kasale.EC, tbl_kasale.UoM, // tbl_kasalesTemp.EmptyCountValue, COGS = tbl_kasale.Cogs, // tbl_kasalesTemp.Litter, // tbl_kasalesTemp.NETP, // tbl_kasalesTemp.NSR, // tbl_kasalesTemp. // EC = tbl_kasalesTemp.PC, // tbl_kasalesTemp.UC, UserUpdate = tbl_kasale.Username, tbl_kasale.id, }; if (rs33.Count() >= 0) { Viewtable viewtbl = new Viewtable(rs33, dc, "COGS DATA PRIOD: " + priod + " OF CUSTOMER CODE " + customercode, 00);// view code 22 la can viet cogs viewtbl.ShowDialog(); // viewtbl.Focus(); } #endregion } } }
private void button3_Click_1(object sender, EventArgs e) { // kaPriodandcustomerpicker // XmlReadMode FormCollection fc = System.Windows.Forms.Application.OpenForms; bool kq = false; foreach (Form frm in fc) { if (frm.Text == "kaPriod and Customer code picker") { kq = true; frm.Focus(); } } if (!kq) { string connection_string = Utils.getConnectionstr(); LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string); dc.CommandTimeout = 0; View.kaPriodandcustomerpicker kaPriodpicker = new View.kaPriodandcustomerpicker(); kaPriodpicker.ShowDialog(); string priod = kaPriodpicker.priod; string customercode = kaPriodpicker.customercode; string fromcode = kaPriodpicker.fromcode; string tocode = kaPriodpicker.tocode; bool onlycust = kaPriodpicker.onlycust; bool fromcodeto = kaPriodpicker.fromcodeto; bool chon = kaPriodpicker.kq; if (chon & onlycust == true) { #region show so da chon var rs = from tbl_kasale in dc.tbl_kasales where tbl_kasale.Priod == priod && tbl_kasale.Sold_to == double.Parse(customercode) select new { tbl_kasale.Priod, tbl_kasale.Sales_District, tbl_kasale.Sales_District_desc, tbl_kasale.Sales_Org, tbl_kasale.Sold_to, tbl_kasale.Cust_Name, tbl_kasale.Outbound_Delivery, tbl_kasale.Key_Acc_Nr, tbl_kasale.Delivery_Date, tbl_kasale.Invoice_Doc_Nr, tbl_kasale.Invoice_Date, tbl_kasale.Currency, tbl_kasale.Mat_Group, tbl_kasale.Mat_Group_Text, tbl_kasale.Mat_Number, tbl_kasale.Mat_Text, PCs = tbl_kasale.EC, tbl_kasale.UoM, EC = tbl_kasale.PC, tbl_kasale.UC, tbl_kasale.Litter, tbl_kasale.GSR, tbl_kasale.NSR, tbl_kasale.Username, tbl_kasale.id }; Viewtable viewtbl = new Viewtable(rs, dc, "SALES DATA PRIOD: " + priod + " OF CUSTOMER " + customercode, 55);// view code 1 la can viet them lenh viewtbl.ShowDialog(); #endregion } if (chon & fromcodeto == true) { #region show so da chon var rs = from tbl_kasale in dc.tbl_kasales where tbl_kasale.Priod == priod && tbl_kasale.Sold_to >= double.Parse(fromcode) && tbl_kasale.Sold_to <= double.Parse(tocode) select new { tbl_kasale.Priod, tbl_kasale.Sales_District, tbl_kasale.Sales_District_desc, tbl_kasale.Sales_Org, tbl_kasale.Sold_to, tbl_kasale.Cust_Name, tbl_kasale.Outbound_Delivery, tbl_kasale.Key_Acc_Nr, tbl_kasale.Delivery_Date, tbl_kasale.Invoice_Doc_Nr, tbl_kasale.Invoice_Date, tbl_kasale.Currency, tbl_kasale.Mat_Group, tbl_kasale.Mat_Group_Text, tbl_kasale.Mat_Number, tbl_kasale.Mat_Text, PCs = tbl_kasale.EC, tbl_kasale.UoM, EC = tbl_kasale.PC, tbl_kasale.UC, tbl_kasale.Litter, tbl_kasale.GSR, tbl_kasale.NSR, tbl_kasale.Username, tbl_kasale.id }; Viewtable viewtbl = new Viewtable(rs, dc, "SALES DATA PRIOD: " + priod + " FROM CODE " + fromcode + " TO CODE " + tocode, 55);// view code 1 la can viet them lenh viewtbl.ShowDialog(); #endregion } } }