public static string FindProgarmebymessageandmaterial(string message, string material)
        {
            //  #region // kiem tra xem co sai mesage
            //    bool kq = true;
            string maprogarme = "";

            string connection_string = Utils.getConnectionstr();

            var    db      = new LinqtoSQLDataContext(connection_string);
            string enduser = Utils.getusername();
            var    rs      = from p in db.tbl_CTKMs

                             where p.Mã_SP_KM.Trim() == material &&
                             p.enduser == enduser
                             //    && message.IndexOf(p.PO_Message) > 0
                             select p;

            foreach (var item in rs)
            {
                if (message.Contains(item.PO_Message.Trim()))
                {
                    // message dung
                    // order message sai
                    //     kq = false;
                    maprogarme = item.Mã_CT;

                    //    return true;
                }
            }


            return(maprogarme);
            //      return kq;
        }
Beispiel #2
0
        private void btnew_Click(object sender, EventArgs e)
        {
            this.region = this.txtma.Text;

            this.ghichu = txtghichu.Text;



            if (region == "")
            {
                MessageBox.Show("Bạn chưa có mã channel", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            chon = true;
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext db  = new LinqtoSQLDataContext(connection_string);

            tbl_MKT_Region p = new tbl_MKT_Region();

            p.Region = this.region;//= this.txtma.Text;


            p.Note = this.ghichu;// = txtdiachitaikhoannganhang.Text;



            db.tbl_MKT_Regions.InsertOnSubmit(p);
            db.SubmitChanges();
            this.Close();
        }
        public static bool Iswrongmessage(string message, string maCTKM)
        {
            //  #region // kiem tra xem co sai mesage
            bool   kq = true;
            string connection_string = Utils.getConnectionstr();
            string enduser           = Utils.getusername();
            var    db = new LinqtoSQLDataContext(connection_string);

            var rs = from p in db.tbl_CTKMs
                     where p.enduser == enduser
                     where p.Mã_CT == maCTKM
                     //    && message.IndexOf(p.PO_Message) > 0
                     select p;

            foreach (var item in rs)
            {
                if (message.Contains(item.PO_Message.Trim()))
                {
                    // message dung
                    // order message sai
                    kq = false;
                    //    return true;
                }
            }



            return(kq);
        }
        public static void UpdateMaCTKMchodonhangmua(string material, DateTime dlv_Date, string nhomKHKM, int id)
        {
            string connection_string = Utils.getConnectionstr();
            string enduser           = Utils.getusername();
            var    db = new LinqtoSQLDataContext(connection_string);

            var rs = from p in db.tbl_CTKMs
                     where p.enduser == enduser
                     select p;

            foreach (var item in rs)
            {
                if (item.Mã_SP_Mua == material && item.Từ_ngày <= dlv_Date && item.Đến_Ngày >= dlv_Date && (item.Nhóm_khách_hàng == nhomKHKM || item.Nhóm_khách_hàng == ""))
                {
                    var rs2 = from kh in db.tbl_Salesorders
                              where kh.id == id
                              select kh;

                    foreach (var item2 in rs2)
                    {
                        item2.maCTKM           = item.Mã_CT;
                        item2.Ma_SP_Duoc_KM    = item.Mã_SP_KM;
                        item2.So_luong_duoc_KM = item2.ConfirmQty / item.Tỷ_lệ_CTKM;
                        db.SubmitChanges();
                    }
                }
            }



            //   throw new NotImplementedException();
        }
        private void button6_Click(object sender, EventArgs e)
        {
            string connection_string = Utils.getConnectionstr();
            string Username          = Utils.getusername();

            if (Utils.IsValidnumber(this.txt_batchno.Text) == false)
            {
                MessageBox.Show("Please check Batchno doc. " + this.txt_batchno.Text, "Thông báo !", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            int BatchNo = int.Parse(this.txt_batchno.Text);

            LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);

            var viewrs = from tbl_kacontractsdetailpayment in dc.tbl_kacontractsdetailpayments
                         where tbl_kacontractsdetailpayment.ContractNo == contractno && tbl_kacontractsdetailpayment.PayControl == "REQ" && tbl_kacontractsdetailpayment.CRDUSR == Username && tbl_kacontractsdetailpayment.BatchNo == BatchNo
                         select new
            {
                tbl_kacontractsdetailpayment.ContractNo,
                PayType = tbl_kacontractsdetailpayment.PayType.Trim(),
                tbl_kacontractsdetailpayment.PayID,
                tbl_kacontractsdetailpayment.SubID,
                tbl_kacontractsdetailpayment.PayControl,
                tbl_kacontractsdetailpayment.PaidRequestAmt,
                //     tbl_kacontractsdetailpayment.Balance,
                //   tbl_kacontractsdetailpayment.BalanceAft,
                tbl_kacontractsdetailpayment.BatchNo,
                tbl_kacontractsdetailpayment.Remark,
            };

            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
            this.dataGridView1.DataSource     = viewrs;
        }
        private void Createpayment_FormClosed(object sender, FormClosedEventArgs e)
        {
            string connection_string = Utils.getConnectionstr();
            string Username          = Utils.getusername();

            LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);

            var viewrs = from tbl_kacontractsdetailpayment in dc.tbl_kacontractsdetailpayments
                         where tbl_kacontractsdetailpayment.ContractNo == contractno && tbl_kacontractsdetailpayment.CRDUSR == Username && tbl_kacontractsdetailpayment.BatchNo == 0// && tbl_kacontractsdetailpayment.PayControl == "REQ
                         select tbl_kacontractsdetailpayment;

            //{
            //    tbl_kacontractsdetailpayment.ContractNo,
            //    PayType = tbl_kacontractsdetailpayment.PayType.Trim(),
            //    tbl_kacontractsdetailpayment.PayID,
            //    tbl_kacontractsdetailpayment.SubID,
            //    tbl_kacontractsdetailpayment.PayControl,
            //    tbl_kacontractsdetailpayment.PaidRequestAmt,
            //    //     tbl_kacontractsdetailpayment.Balance,
            //    //   tbl_kacontractsdetailpayment.BalanceAft,
            //    tbl_kacontractsdetailpayment.BatchNo,
            //    tbl_kacontractsdetailpayment.Remark,


            //};

            //   dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
            //    this.dataGridView1.DataSource = viewrs;
            dc.tbl_kacontractsdetailpayments.DeleteAllOnSubmit(viewrs);
            dc.SubmitChanges();
        }
        public void loaddatagriviewpayment()
        {
            string connection_string = Utils.getConnectionstr();
            string Username          = Utils.getusername();

            LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);

            var viewrs = from tbl_kacontractsdetailpayment in dc.tbl_kacontractsdetailpayments
                         where tbl_kacontractsdetailpayment.ContractNo == contractno && tbl_kacontractsdetailpayment.CRDUSR == Username && tbl_kacontractsdetailpayment.BatchNo == 0 && tbl_kacontractsdetailpayment.PayControl == "REQ"
                         select new
            {
                tbl_kacontractsdetailpayment.ContractNo,
                tbl_kacontractsdetailpayment.ContracName,
                PayType = tbl_kacontractsdetailpayment.PayType.Trim(),
                tbl_kacontractsdetailpayment.PayID,
                tbl_kacontractsdetailpayment.SubID,
                tbl_kacontractsdetailpayment.PayControl,
                tbl_kacontractsdetailpayment.PaidRequestAmt,
                //     tbl_kacontractsdetailpayment.Balance,
                //   tbl_kacontractsdetailpayment.BalanceAft,
                tbl_kacontractsdetailpayment.BatchNo,
                tbl_kacontractsdetailpayment.Remark,
            };

            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
            this.dataGridView1.DataSource     = viewrs;
        }
Beispiel #8
0
        private void txtname_KeyPress(object sender, KeyPressEventArgs e)
        {
            txtname.Focus();
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            string username = Utils.getusername();

            var regioncode = (from tbl_Temp in dc.tbl_Temps
                              where tbl_Temp.username == username
                              select tbl_Temp.RegionCode).FirstOrDefault();

            var rscode = from tbl_KaCustomer in dc.tbl_KaCustomers

                         where tbl_KaCustomer.FullNameN.Contains(txtname.Text.ToString().Trim()) &&
                         ((int)tbl_KaCustomer.Customer).ToString().Contains(txtcode.Text.ToString())

                         && (from Tka_RegionRight in dc.Tka_RegionRights where Tka_RegionRight.RegionCode == regioncode select Tka_RegionRight.Region
                             ).Contains(tbl_KaCustomer.SalesOrg)

                         select new
            {
                Region = tbl_KaCustomer.Region,
                Code   = tbl_KaCustomer.Customer,
                Name   = tbl_KaCustomer.FullNameN,
                //  tbl_KaCustomer.SapCode,
            };

            icount = rscode.Count();

            dataGridView1.DataSource = rscode;
        }
Beispiel #9
0
        public void exportexceldatagridtofile(IQueryable iquery, LinqtoSQLDataContext db, string tittle)
        {
            System.Data.DataTable datatable1 = new System.Data.DataTable();
            //

            Utils ul = new Utils();

            datatable1 = ul.ToDataTable(db, iquery);
            SaveFileDialog thedialog = new SaveFileDialog();

            //


            //   datagridview datagridview1 = new datagridview();
            //   datagridview1.datasource = datagrid.datasource;

            thedialog.Title            = "export to excel file";
            thedialog.Filter           = "excel files|*.xlsx; *.xls";
            thedialog.InitialDirectory = @"c:\";


            if (thedialog.ShowDialog() == DialogResult.OK)
            {
                string filename = thedialog.FileName.ToString();
                Thread t1       = new Thread(exportsexcel);
                t1.IsBackground = true;
                t1.Start(new datatoExport()
                {
                    dataGrid1 = datatable1, filename = filename, tittle = tittle
                });
                // t1.join();
            }
        }
Beispiel #10
0
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            string name = e.Node.Name;
            string connection_string = Utils.getConnectionstr();

            LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);
            //bangsoducd
            //     bangnhapsodulctt



            //     npdanhsachxe



            //dsxenp



            //            dsloaitk

            //            dstaikhoanketoan


            //hethongtk

            //phanquyen



            //btoanth


            // dsnhacungcap
        }
Beispiel #11
0
 public static DriveLesson Save(DateTime shortDate, int hour, string instruktorID,string DriverID ,LinqtoSQLDataContext db)
 {
     Guid guid = Guid.NewGuid();
     DriveLesson driv = new DriveLesson { Date = shortDate, Hour = hour, ID = guid, Instructor = instruktorID, Driver = DriverID };
     db.DriveLesson.InsertOnSubmit(driv);
     LINQConnections.Save(db); return driv;
 }
Beispiel #12
0
        private void button2_Click_2(object sender, EventArgs e)
        {
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            var Programelist = from pp in dc.tbl_MKT_Payment_AprovalTMPs
                               where pp.username == username
                               select new
            {
                //      pp.IO_number,
                //      pp.ProgrameIDDocno,
                //     pp.Account,
                //     pp.costcenter,
                pp.Customercode,
                pp.CustomerName,

                pp.CustomerAddress,
                pp.AprovalBudget,

                pp.id,

                pp.username,
            };


            if (Programelist.Count() > 0)
            {
                this.totalBudget = (float)Programelist.Sum(x => x.AprovalBudget);

                txttotalbudget.Text = this.totalBudget.ToString("#,#", CultureInfo.InvariantCulture);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //    string username = Utils.getusername();



            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            var channelisttmp = from pp in dc.tbl_MKT_CustomerChaneltmps
                                where pp.username == username
                                select pp;

            foreach (var item in channelisttmp)
            {
                if (item.Select_channel == true)
                {
                    if (kqstring != "")
                    {
                        this.kqstring = item.Chanel_code + ";" + this.kqstring;
                    }
                    else
                    {
                        this.kqstring = item.Chanel_code;
                    }
                }
            }

            this.Close();
        }
Beispiel #14
0
        private void reportViewer1_PrintingBegin(object sender, ReportPrintEventArgs e)
        {
            // MessageBox.Show("In payment request !");

            string connection_string = Utils.getConnectionstr();

            LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);
            var rschangepritcheck   = from tbl_kacontractsdetailpayment in dc.tbl_kacontractsdetailpayments
                                      where tbl_kacontractsdetailpayment.BatchNo == BatchNo// &&  tbl_kacontractsdatadetail.ContractNo == contractno
                                      select tbl_kacontractsdetailpayment;


            if (rschangepritcheck != null)
            {
                foreach (var item in rschangepritcheck)
                {
                    item.PrintChk  = true;
                    item.PrintDate = DateTime.Today;
                    //      item.
                    dc.SubmitChanges();

                    if (formcreatCtract != null)
                    {
                        this.formcreatCtract.loadDetailContractView(contractno);
                    }
                }
            }


            //      this.Close();
        }
Beispiel #15
0
        public ActionResult About()
        {
            //LinqtoSQL Example
            LinqtoSQLDataContext nw = new LinqtoSQLDataContext();

            var empQuery =
                from emp in nw.Employees
                where emp.Id == 1
                select emp.Name;

            foreach (var _emp in empQuery)
            {
                //capture SQL statement of LinqToSQL
                Trace.TraceInformation(string.Format("{0}", empQuery.ToString()));
            }

            //PageView
            _ai.Pageview("Exception");

            ViewBag.Message = "";

            //capture type conversion error
            try
            {
                if (ViewBag.Message)
                {
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.StackTrace);
            }

            return(View());
        }
 public void DrawDataTable(int startHourRange, int endHourRange, int jumpHour, int startWidth, int startHeight)
 {
     using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
     {
         int tempWidth = startWidth;
         foreach (Instruktor instruktor in db.Instruktor.Where(x => x.Visible == true))
         {
             tempWidth += buttonRectangleSize;
             labellist.Add(MakeInstructorLabel(tempWidth, instruktor.First_Name + "\n" + instruktor.Second_Name));
             int tempHeight = startHeight;
             form.Width += buttonRectangleSize;
             for (int i = startHourRange; i <= endHourRange; i += jumpHour)
             {
                 string buttonText = string.Empty;
                 DriveLesson checkLesson = DrivesListModel.Load(i, form.date, instruktor.InstructorID);
                 if (checkLesson.Driver != null)
                 {
                    buttonText = DriverSeterController.GetText(checkLesson.Driver);
                 }
                 buttonList.Add(makeButton(tempWidth, tempHeight, instruktor.InstructorID, i.ToString(),
                     buttonRectangleSize, buttonText));
                 tempHeight += buttonRectangleSize;
             }
         }
     }
     AddToColection();
 }
        public void loaddetailinventoryforapproval()
        {
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);
            string urs = Utils.getusername();

            var rs = from pp in dc.tbl_MKT_Stockcounts
                     where pp.Store_code == this.storelocation &&
                     pp.CountingDate == this.CountingDate &&
                     pp.Idsub == this.Countingtimes
                     select new
            {
                Store             = pp.Store_code,
                SAP_CODE          = pp.SAP_CODE,
                ITEM_Code         = pp.ITEM_Code,
                Material_name     = pp.MATERIAL,
                Description       = pp.Description,
                UNIT              = pp.UNIT,
                END_STOCK         = pp.END_STOCK,
                Counting_Quantity = pp.CountQuantity,
                Balance           = pp.CountQuantity - pp.END_STOCK,

                //     Real_issue = 0,
            };

            if (rs.Count() > 0)
            {
                dataGridViewLoaddetail.DataSource = rs;
                this.rs          = rs;
                this.datacontext = dc;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            btAproval.Enabled = false;
            btreject.Enabled  = false;

            #region change status approval
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            var rs = from pp in dc.tbl_MKT_Stockcounts
                     where pp.CountingDate == this.CountingDate &&
                     pp.Idsub == this.Countingtimes &&
                     pp.Store_code == this.storelocation
                     select pp;
            if (rs.Count() > 0)
            {
                foreach (var item in rs)
                {
                    item.Aproved     = true;
                    item.Aprovedby   = txtnguoinhan.Text;
                    item.AprovedDate = DateTime.Today;
                    item.Status      = "Reject";
                    dc.SubmitChanges();
                }
            }
            MessageBox.Show("Done !", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //   loaddetailinventoryforapproval();
            //   btAproval.Enabled = false;
            // btreject.Enabled = false;

            #endregion
        }
Beispiel #19
0
        public int getStatus()
        {
            string Name = Utils.getusername();
            int    kq   = -1;


            string connection_string = Utils.getConnectionstr();

            LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);

            var rs = (from pp in dc.tbl_Temps
                      where pp.username == Name

                      select pp).FirstOrDefault();

            if (rs != null)
            {
                if (rs.status != null)
                {
                    kq = rs.status.Value;
                }
                else
                {
                    rs.status = -1;
                    //   dc.SubmitChanges();
                    //    Username.setStatus(-1);
                }
            }

            return(kq);
        }
Beispiel #20
0
        public List <Viewtable.ComboboxItem> Getcomboudata()
        {
            List <Viewtable.ComboboxItem> dataCollection = new List <Viewtable.ComboboxItem>();
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            var rs = from tblCustomer in dc.tblCustomers
                     where tblCustomer.Reportsend == true
                     select tblCustomer;


            string drowdowvalue = "";

            if (rs.Count() > 0)
            {
                foreach (var item in rs)
                {
                    drowdowvalue = item.Customer.ToString() + " " + item.Name_1;


                    Viewtable.ComboboxItem itemcb = new Viewtable.ComboboxItem();
                    itemcb.Text  = drowdowvalue;
                    itemcb.Value = item.Customer.ToString();



                    dataCollection.Add(itemcb);
                }

                return(dataCollection);
            }
            return(null);
        }
Beispiel #21
0
        public static void Save(string FirstName, string SecondName, string InstructorID, PictureBox picture)
        {
            using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
                {
                    if (db.Instruktor.Any(x => x.InstructorID == InstructorID))
                    {
                        var Instructor = from Instruktor in db.Instruktor
                                         where Instruktor.InstructorID == InstructorID
                                         select Instruktor;
                        foreach (Instruktor instructor in Instructor)
                        {
                            instructor.First_Name = FirstName;
                            instructor.Second_Name = SecondName;
                            instructor.InstructorID = InstructorID;

                        }
                    }
                    else
                    {
                        Guid ID = System.Guid.NewGuid();
                        Instruktor newInstruktor = new Instruktor {Visible = true, First_Name = FirstName, Second_Name = SecondName, InstructorID = InstructorID, ID = ID };
                        db.Instruktor.InsertOnSubmit(newInstruktor);
                    }
                LINQConnections.Save(db);
            }
        }
Beispiel #22
0
        private void btupdate_Click(object sender, EventArgs e)
        {
            //



            this.makho  = this.txtmakho.Text;
            this.tenkho = this.txttenkho.Text;


            this.diachi = this.txtdiachi.Text;

            this.ghichu     = this.txtghichu.Text;
            this.storeright = this.txtstoright.Text;

            //this.usertao = Utils.getusername();

            //this.ngaytao = DateTime.Today;


            if (makho == "")
            {
                MessageBox.Show("Bạn chưa có mã nhà cung cấp", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }



            if (makho != "")
            {
                chon = true;
                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext db  = new LinqtoSQLDataContext(connection_string);

                //   tbl_dstaikhoan tk = new tbl_dstaikhoan();


                //    MeasureItemEventArgs.re
                var rs = (from p in db.tbl_MKT_khoMKTs
                          where p.makho == makho
                          //  orderby tbl_dstaikhoan.matk
                          select p).FirstOrDefault();


                if (rs != null)
                {
                    rs.makho  = this.makho;          // = this.txtmaNCC.Text;
                    rs.tenkho = this.tenkho;         // this.txttenNCC.Text;

                    rs.diachikho = this.diachi;      // this.txtMasothue.Text;

                    rs.ghichu     = this.ghichu;     // this.txtNganhnghe.Text;
                    rs.storeright = this.storeright; // this.txtNganhnghe.Text;


                    db.SubmitChanges();
                    this.Close();
                }
            }
        }
Beispiel #23
0
 public static void Save(string firstName, string secondName, string driverID,
         string adress, string telephone, int amountOfDrives, bool isRegularClient)
 {
     using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
         {
             if (db.Driver.Any(x => x.DriverID == driverID))
             {
                 var drivers = from driver in db.Driver
                               where driver.DriverID == driverID
                               select driver;
                 foreach (Driver driver in drivers)
                 {
                     driver.First_Name = firstName;
                     driver.Last_Name = secondName;
                     driver.DriverID = driverID;
                     driver.Adress = adress;
                     driver.TelephoneNumber = telephone;
                     driver.IsRegularClient = isRegularClient;
                     driver.Drives_Amount = amountOfDrives;
                 }
             }
             else
             {
                 Guid ID = System.Guid.NewGuid();
                 Driver newDriver = new Driver {First_Name = firstName, Last_Name = secondName,
                     Adress = adress,ID = ID, IsRegularClient = isRegularClient,DriverID = driverID,
                     TelephoneNumber = telephone, Drives_Amount = amountOfDrives
                 };
                 db.Driver.InsertOnSubmit(newDriver);
             }
              LINQConnections.Save(db);
         }
 }
        private void btnew_Click(object sender, EventArgs e)
        {
            this.maNVT     = this.txtma.Text;
            this.tenNVT    = this.txtten.Text;
            this.diachinvt = this.txtdiachi.Text;
            //    this.masothuenvt = txtmasothue.Text;
            this.dienthoai = txtdienthoai.Text;
            //   this.tknganhangso = dienthoai.Text;


            if (maNVT == "")
            {
                MessageBox.Show("Bạn chưa có mã nhà cung cấp", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            chon = true;
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext db  = new LinqtoSQLDataContext(connection_string);

            tbl_MKT_Nhacungungvantai p = new tbl_MKT_Nhacungungvantai();

            p.maNVT     = this.maNVT;        //= this.txtma.Text;
            p.tenNVT    = this.tenNVT;       //= this.txtten.Text;
            p.diachiNVT = this.diachinvt;    // = this.txtdiachi.Text;
            //       p.masothueNVT = this.masothuenvt;// = txtmasothue.Text;
            p.dienthoaiNVT = this.dienthoai; //= txtdienthoai.Text;



            db.tbl_MKT_Nhacungungvantais.InsertOnSubmit(p);
            db.SubmitChanges();
            this.Close();
        }
Beispiel #25
0
        public kaPriodandcustomerpicker()
        {
            InitializeComponent();

            kq = false;
            checkbonlycust.Checked   = false;
            checkbokfromcode.Checked = false;

            string connection_string = Utils.getConnectionstr();

            LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);

            var rs2 = from tbl_Kapriod in dc.tbl_Kapriods
                      where tbl_Kapriod.block == false
                      select tbl_Kapriod;

            string drowdownshow = "";

            foreach (var item in rs2)
            {
                drowdownshow = item.Priod;
                cb_priod.Items.Add(drowdownshow);
            }
            priod        = "";
            customercode = "";

            cbcustomer.Text = "";
            //     lbcustomername.Text = "";
            lb_priods.Text    = "";
            lb_fromdates.Text = "";
            lbtodates.Text    = "";
            // cb_priod.SelectedIndex = 1;
            //   priod = null;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //     nut ok


            tbl_kacontractCustcode cust = new tbl_kacontractCustcode();
            string connection_string    = Utils.getConnectionstr();
            LinqtoSQLDataContext dc     = new LinqtoSQLDataContext(connection_string);



            string username = Utils.getusername();
            double codetemp = this.addcode; // (double)this.dataGridView1.Rows[0].Cells["Code"].Value;
            string codename = this.addname; //  (string)this.dataGridView1.Rows[0].Cells["Name"].Value;

            //this.valuetext = textBox1.Text;
            //this.field = this.label1.Text;



            cust.ContractNo   = this.Contactno;
            cust.CustomerCode = codetemp;
            cust.Name         = codename;
            cust.Addedby      = username;

            dc.tbl_kacontractCustcodes.InsertOnSubmit(cust);
            dc.SubmitChanges();
            MessageBox.Show("Code :" + codetemp + " add to Groupcode done !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);



            this.kq = true;
            this.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            var contractproductconvert = from tbl_kaConvertProductlist in dc.tbl_kaConvertProductlists
                                         where tbl_kaConvertProductlist.ContractNo == ContractNo &&
                                         tbl_kaConvertProductlist.PayID == contractitem
                                         select tbl_kaConvertProductlist;

            dc.tbl_kaConvertProductlists.DeleteAllOnSubmit(contractproductconvert);
            dc.SubmitChanges();

            // view detail datagview

            var contractproductconvert2 = from tbl_kaConvertProductlist in dc.tbl_kaConvertProductlists
                                          where tbl_kaConvertProductlist.ContractNo == ContractNo &&
                                          tbl_kaConvertProductlist.PayID == contractitem
                                          select tbl_kaConvertProductlist;


            this.dataGridView1.DataSource = contractproductconvert2;



            //viewdetail datagview
        }
Beispiel #28
0
        public static DriveLesson Load(int hour,DateTime shortDate, string instruktorID)
        {
            using (LinqtoSQLDataContext db  = new LinqtoSQLDataContext())
            {
                DriveLesson driv = null;
                try
                {
                   driv = db.DriveLesson.Where(x => x.Date == shortDate && x.Hour == hour && x.Instructor == instruktorID).First();
                }
                catch (Exception x)
                {

                    Console.WriteLine(x.ToString());

                }

                if (driv == null)
                {

                    driv = Save(shortDate, hour, instruktorID, db);
                    Console.WriteLine(driv.Hour);

                }
                return driv;
            }
        }
Beispiel #29
0
        private void btxoa_Click(object sender, EventArgs e)
        {
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);



            if (!Model.Username.getDeleteProductright())
            {
                View.MKTNoouthourise view = new MKTNoouthourise();
                view.ShowDialog();
                return;
            }


            var rs1 = (from p in dc.tbl_MKT_Stockends
                       where p.id == this.id
                       select p).FirstOrDefault();

            if (rs1 != null)
            {
                dc.tbl_MKT_Stockends.DeleteOnSubmit(rs1);
                dc.SubmitChanges();
                this.Close();
            }
        }
Beispiel #30
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int id = (int)this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["id"].Value;


                //   MessageBox.Show(id.ToString());

                double Codegroup = double.Parse(txtcustgroup.Text.ToString());

                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);



                var rscode = (from tbl_kaCustomerGroup in dc.tbl_kaCustomerGroups
                              where tbl_kaCustomerGroup.id == id
                              select tbl_kaCustomerGroup).FirstOrDefault();

                dc.tbl_kaCustomerGroups.DeleteOnSubmit(rscode);
                dc.SubmitChanges();

                var rscode2 = from tbl_kaCustomerGroup in dc.tbl_kaCustomerGroups
                              where tbl_kaCustomerGroup.Customergropcode == Codegroup//&& (tbl_KaCustomer.SapCode == true)
                              select tbl_kaCustomerGroup;

                dataGridView1.DataSource = rscode2;
            }
            catch (Exception)
            {
                //  throw;
            }
        }
        //  IQueryable rs, LinqtoSQLDataContext d
        public MKTProgramemake2()
        {
            InitializeComponent();


            txtsohieuct.Text = "";

            txttenct.Text       = "";
            txtfromdate.Value   = DateTime.Today;
            txttodate.Value     = DateTime.Today;
            txttotalbudget.Text = "";



            this.ProgrameIDDocno = txtsohieuct.Text;
            // label7.Text = "Select one or more channel ";

            this.username = Utils.getusername();



            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            Model.MKT.DeleteALLIOTMP(dc);



            var Programelist = from pp in dc.tbl_MKT_IO_ProgrameTMPs
                               where pp.Username == username
                               select new
            {
                pp.IO_number,
                pp.ChannelGroup,
                pp.Budget,
                pp.Region,
                pp.Sales_Org,
                pp.Username,
                pp.id,
            };



            Model.MKT.DeleteALLIPricelistIOTMP(dc);


            var priceIOlist = from pp in dc.tbl_MKT_ProgramepriceproductTMPs
                              where pp.Username == username
                              select new
            {
                pp.ITEM_Code,
                pp.MATERIAL,
                pp.Price,
                pp.SAP_CODE,
                pp.Description,
                pp.id,
                pp.Username,
            };
        }
Beispiel #32
0
        private void button1_Click(object sender, EventArgs e)
        {
            View.valueinput inputval = new valueinput("Input some text in Name to seach code", "");

            inputval.ShowDialog();

            bool   chon       = inputval.kq;
            string valueinput = inputval.valuetext;

            if (valueinput == null)
            {
                valueinput = "";
            }
            if (chon)
            {
                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

                var rscode = from tbl_KaCustomer in dc.tbl_KaCustomers
                             where tbl_KaCustomer.FullNameN.Contains(valueinput) && (tbl_KaCustomer.SapCode == true)
                             select new
                {
                    tbl_KaCustomer.Region,
                    tbl_KaCustomer.Customer,
                    tbl_KaCustomer.FullNameN,
                    tbl_KaCustomer.SapCode,
                };



                Utils ut          = new Utils();
                var   tblcustomer = ut.ToDataTable(dc, rscode);

                Viewdatatable viewtb = new Viewdatatable(tblcustomer, "Please,Choose one code !");
                viewtb.ShowDialog();
                string codetemp = viewtb.valuecode;
                string region   = viewtb.region;

                if (codetemp != "0" && chon == true && codetemp != null)
                {
                    custcode.Text    = codetemp;
                    custcode.Enabled = false;

                    textregion.Text = region;
                    cbcust.Checked  = true;
                    //  groupBox1.Enabled = true;
                    //     cbcust.Checked = true;
                }
            }
            else
            {
                custcode.Text    = "";
                custcode.Enabled = true;
                textregion.Text  = "";
                cbcust.Checked   = true;
                //     groupBox1.Enabled = false;
                //   cbcust.Checked = false;
            }
        }
Beispiel #33
0
        public IQueryable Funtionsetlect_all(LinqtoSQLDataContext db)
        {
            //var db = new LinqtoSQLDataContext(connection_string);
            var rs = from tbl_Kafuctionlist in db.tbl_Kafuctionlists
                     select tbl_Kafuctionlist;

            return(rs);
        }
        public IQueryable Edlpsetlect_all(LinqtoSQLDataContext db)
        {
            //    var db = new LinqtoSQLDataContext(connection_string);
            var rs = from tblEDLP in db.tblEDLPs
                     select tblEDLP;

            return(rs);
        }
Beispiel #35
0
        public IQueryable product_select_all(LinqtoSQLDataContext dblink)
        {
            // var db = new LinqtoSQLDataContext(connection_string);
            var rs = from tbl_kaProductlist in dblink.tbl_kaProductlists
                     select tbl_kaProductlist;

            return(rs);
        }
Beispiel #36
0
 public static void Delete(string matchID)
 {
     using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
     {
         db.Driver.DeleteAllOnSubmit(db.Driver.Where(x => x.DriverID == matchID));
         LINQConnections.Save(db);
     }
 }
Beispiel #37
0
 public static Instruktor Load(LinqtoSQLDataContext db, string IDMatch)
 {
     var ins = db.Instruktor.Where(x => x.InstructorID == IDMatch);
     if (ins.Any() == false)
     {
         return null;
     }               else
     return ins.First();
 }
Beispiel #38
0
        public static void Delete(string IDMatch)
        {
            using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
                {

                    db.Instruktor.DeleteAllOnSubmit(db.Instruktor.Where(x=>x.InstructorID == IDMatch));

                    LINQConnections.Save(db);
                }
        }
Beispiel #39
0
 public static void Load(ListBox listbox)
 {
     using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
         {
             foreach (Instruktor instructor in db.Instruktor)
             {
                 listbox.Items.Add(instructor.First_Name + " " + instructor.Second_Name + " ," + instructor.InstructorID);
             }
         }
 }
Beispiel #40
0
 public static void Load(ListBox listbox,string SearchBase)
 {
     using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
         {
             listbox.Items.Clear();
             foreach (Driver driver in db.Driver.Where(x => (x.First_Name + x.Last_Name).Contains(SearchBase)))
             {
                 listbox.Items.Add(driver.First_Name.Trim(' ') + " " + driver.Last_Name.Trim(' ') + "," + driver.DriverID);
             }
         }
 }
Beispiel #41
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
            {
                Button thisbutton = sender as Button;
                string DriverID = DriverModel.Load(Driver_listbox.Text.Split(',').Last()).DriverID;
                DrivesListModel.Save(date, hour, trainerid,DriverID , db);

            }
            ReturnValue = Driver_listbox.Text;
            this.Visible = false;
        }
Beispiel #42
0
 public static Driver Load(string IDMatch)
 {
     using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
         {
             if (IDMatch != null)
             {
                 try
                 {
                     return db.Driver.First(x => x.DriverID == IDMatch);
                 }
                 catch (InvalidOperationException x)
                 {
                     Console.WriteLine(x.ToString());
                 }
             }
         }
         return null;
 }
        public static string GetText(string driverID)
        {
            //// Get First and Second name of Driver based at driverID, if driverID doesn't match any driver
            //// returns string.Empty;
            Driver driver;
            using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
            {
                driver = DriverModel.Load(driverID);
            }

            if (driver == null)
            {
                return string.Empty;
            }
            else
            {
                return driver.First_Name + " " + driver.Last_Name;
            }
        }
Beispiel #44
0
 public static void Load(TextBox FirstName, TextBox LastName, TextBox InstructorID, PictureBox picturebox, string IDMatch)
 {
     using (LinqtoSQLDataContext db = new LinqtoSQLDataContext())
         {
             if (IDMatch != null)
             {
                 try
                 {
                 Instruktor ins = Load(db, IDMatch);
                 FirstName.Text = ins.First_Name.Trim(' ');
                 LastName.Text = ins.Second_Name.Trim(' ');
                 InstructorID.Text = ins.InstructorID.Trim(' ');
                 }
                 catch (InvalidOperationException x)
                 {
                     Console.WriteLine(x.ToString());
                 }
             }
         }
 }
Beispiel #45
0
 public static void Save(LinqtoSQLDataContext db)
 {
     try
     {
         db.SubmitChanges();
     }
     catch (Exception exc)
     {
         Console.WriteLine(exc);
     }
 }