示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string username          = Utils.getusername();
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            // ghi file   [tbl_MKT_Programe]


            var Programelist = from pp in dc.tbl_MKT_IO_ProgrameTMPs
                               where pp.Username == username
                               select pp;


            if (Programelist.Count() <= 0)
            {
                MessageBox.Show("Please setup IO of this progarme !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                //       btiosetup.Focus();
                return;
            }

            var programelist = from pp in dc.tbl_MKT_IO_ProgrameTMPs
                               where pp.Username == username
                               select pp;


            //if (programelist.Count() <= 0)
            //{
            //    MessageBox.Show("Please setup product of this progarme !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            //    btprodutadd.Focus();
            //    return;
            //}

            tbl_MKT_Programe newprograme = new tbl_MKT_Programe();

            //if (Utils.IsValidnumber(txttotalbudget.Text))
            //{
            //    newprograme.TotalBudget = double.Parse(txttotalbudget.Text);
            //    newprograme.BalanceBudget = double.Parse(txttotalbudget.Text);
            //}
            //else
            //{
            //    MessageBox.Show("Budget must be a munber ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    newprograme = null;
            //    txttotalbudget.Focus();
            //    return;
            //}


            newprograme.tenCT = txttenct.Text;

            newprograme.ProgrameIDDocno = txtsohieuct.Text;


            dc.tbl_MKT_Programes.InsertOnSubmit(newprograme);
            dc.SubmitChanges();



            // ghi file  [tbl_MKT_Programepriceproduct]
            var productlist = from pp in dc.tbl_MKT_ProgramepriceproductTMPs
                              where pp.Username == username
                              select pp;


            foreach (var item in productlist)
            {
                tbl_MKT_Programepriceproduct newitem2 = new tbl_MKT_Programepriceproduct();

                newitem2.Description     = item.Description;
                newitem2.ITEM_Code       = item.ITEM_Code;
                newitem2.MATERIAL        = item.MATERIAL;
                newitem2.Price           = item.Price;
                newitem2.ProgrameIDDocno = item.ProgrameIDDocno;
                newitem2.SAP_CODE        = item.SAP_CODE;
                newitem2.UNIT            = item.UNIT;

                dc.tbl_MKT_Programepriceproducts.InsertOnSubmit(newitem2);
                dc.SubmitChanges();
            }



            // ghi file   [tbl_MKT_IO_Programe]

            var programe = from pp in dc.tbl_MKT_IO_ProgrameTMPs
                           where pp.Username == username
                           select pp;


            foreach (var item in programe)
            {
                tbl_MKT_IO_Programe newitem = new tbl_MKT_IO_Programe();

                newitem.Budget          = item.Budget;
                newitem.ChannelGroup    = item.ChannelGroup;
                newitem.ghichu          = item.ghichu;
                newitem.IO_Name         = item.IO_Name;
                newitem.IO_number       = item.IO_number;
                newitem.ProgrameIDDocno = item.ProgrameIDDocno;
                newitem.Region          = item.Region;
                newitem.Sales_Org       = item.Sales_Org;

                dc.tbl_MKT_IO_Programes.InsertOnSubmit(newitem);
                dc.SubmitChanges();
            }



            this.Close();
        }
示例#2
0
        private void btnew_Click(object sender, EventArgs e)
        {
            if (Utils.IsValidnumber(txtbudget.Text))
            {
                this.budget = double.Parse(txtbudget.Text.ToString());
            }
            else
            {
                MessageBox.Show("Budget must be a number", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtbudget.Focus();

                return;
            }

            this.maCT  = this.txtma.Text;
            this.tenCT = this.txtten.Text;

            this.ghichu = txtghichu.Text;

            this.salesorg = (cbsales_org.SelectedItem as ComboboxItem).Value.ToString();
            this.region   = (cbregion.SelectedItem as ComboboxItem).Value.ToString();

            this.channelgroup    = txtchannelgroup.Text;
            this.ProgrameIDDocno = txtsohieuct.Text;

            if (txtsohieuct.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập số hiệu chương trình", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }



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


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

            if (cbregion.Text == "")
            {
                MessageBox.Show("Bạn chưa có mã Region", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtchannelgroup.Text == "")
            {
                MessageBox.Show("Bạn chưa có 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_IO_Programe p = new tbl_MKT_IO_Programe();

            p.IO_number = this.maCT;  //= this.txtma.Text;
            p.IO_Name   = this.tenCT; //= this.txtten.Text;

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

            p.ProgrameIDDocno = this.ProgrameIDDocno;
            p.Budget          = this.budget;// = txtdiachitaikhoannganhang.Text;
            p.Region          = this.region;
            p.Sales_Org       = this.salesorg;
            p.ChannelGroup    = this.channelgroup;


            db.tbl_MKT_IO_Programes.InsertOnSubmit(p);
            db.SubmitChanges();
            this.Close();
        }