コード例 #1
0
ファイル: AddForm.cs プロジェクト: umidjonv/tposDesktop
        private void AddOrEdit(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tbxName.Text))
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                DataSetTposTableAdapters.productTableAdapter daProduct = new DataSetTposTableAdapters.productTableAdapter();
                if (isAdd)
                {
                    DataSetTpos.productRow prRowN = DBclass.DS.product.NewproductRow();
                    prRowN.name      = tbxName.Text;
                    prRowN.barcode   = tbxShtrix.Text;
                    prRowN.measureId = 2;
                    prRowN.pack      = tbxPack.Text != "0" && tbxPack.Text != ""?Convert.ToInt32(tbxPack.Text):0;
                    prRowN.status    = 0;
                    prRowN.price     = Convert.ToInt32(tbxPrice.Text);
                    DBclass.DS.product.AddproductRow(prRowN);
                    daProduct.Update(prRowN);

                    daProduct.Fill(DBclass.DS.product);
                    int?lId = daProduct.LastID();


                    if (lId != null && tbxShtrix.Text == "")
                    {
                        int id = lId.Value;
                        DataSetTpos.productRow pr = DBclass.DS.product.FindByproductId(id);
                        string barcode            = randNumbers(id);
                        pr.barcode = barcode;
                        pr.status  = 1;
                        daProduct.Update(pr);
                    }
                }
                else
                {
                    prRow.name      = tbxName.Text;
                    prRow.barcode   = tbxShtrix.Text;
                    prRow.measureId = 2;
                    prRow.pack      = tbxPack.Text != "0" && tbxPack.Text != "" ? Convert.ToInt32(tbxPack.Text) : 0;;

                    prRow.price = Convert.ToInt32(tbxPrice.Text);
                    daProduct.Update(DBclass.DS.product);
                    daProduct.Fill(DBclass.DS.product);
                }
            }
        }
コード例 #2
0
ファイル: AddForm.cs プロジェクト: umidjonv/Dilering
        private void AddOrEdit(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tbxName.Text))
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                DataSetTposTableAdapters.productTableAdapter daProduct = new DataSetTposTableAdapters.productTableAdapter();
                if (isAdd)
                {
                    int rbtn = 2;
                    DataSetTpos.productRow prRowN = DBclass.DS.product.NewproductRow();
                    prRowN.name    = tbxName.Text;
                    prRowN.barcode = tbxShtrix.Text;

                    if (measureRadio.Checked)
                    {
                        rbtn = 2;
                    }
                    else
                    if (measureRadio2.Checked)
                    {
                        rbtn = 1;
                    }
                    else
                    {
                        rbtn            = 3;
                        prRowN.extParam = tbxMwidth.Text + "x" + tbxMheight.Text;
                    }
                    prRowN.measureId = rbtn;
                    prRowN.pack      = tbxPack.Text != "0" && tbxPack.Text != "" ? Convert.ToInt32(tbxPack.Text) : 0;
                    prRowN.status    = 0;
                    prRowN.priceRozn = Convert.ToInt32(tbxRozPrice.Text);
                    if (prCmbx.Text == "")
                    {
                        prRowN.providerId = 1;
                    }
                    else
                    {
                        prRowN.providerId = prCmbx.FindStringExact(prCmbx.Text);
                    }
                    prRowN.price = Convert.ToInt32(tbxPrice.Text);
                    DBclass.DS.product.AddproductRow(prRowN);
                    daProduct.Update(prRowN);

                    daProduct.Fill(DBclass.DS.product);
                    int?lId = daProduct.LastID();
                    DataSetTposTableAdapters.balanceTableAdapter bAdapetr = new DataSetTposTableAdapters.balanceTableAdapter();
                    DataSetTpos.balanceRow bRow = DBclass.DS.balance.NewbalanceRow();
                    bRow.balanceDate = Convert.ToDateTime("2000-01-01");
                    bRow.prodId      = Convert.ToInt32(lId);
                    bRow.endCount    = 0;
                    bRow.curEndCount = 0;
                    DBclass.DS.balance.AddbalanceRow(bRow);
                    bAdapetr.Update(bRow);

                    ///Change changeprice

                    if (lId != null && tbxShtrix.Text == "")
                    {
                        int id = lId.Value;
                        DataSetTpos.productRow pr = DBclass.DS.product.FindByproductId(id);
                        string barcode            = randNumbers(id);
                        pr.barcode = barcode;
                        pr.status  = 1;
                        daProduct.Update(pr);
                    }
                }
                else
                {
                    int rbtn = 2;
                    prRow.name    = tbxName.Text;
                    prRow.barcode = tbxShtrix.Text;
                    if (measureRadio.Checked)
                    {
                        rbtn = 2;
                    }
                    else
                    if (measureRadio2.Checked)
                    {
                        rbtn = 1;
                    }
                    else
                    {
                        rbtn           = 3;
                        prRow.extParam = tbxMwidth.Text + "x" + tbxMheight.Text;
                    }
                    prRow.providerId = prCmbx.FindStringExact(prCmbx.Text);
                    prRow.measureId  = rbtn;
                    prRow.pack       = tbxPack.Text != "0" && tbxPack.Text != "" ? Convert.ToInt32(tbxPack.Text) : 0;;

                    prRow.price     = Convert.ToSingle(tbxPrice.Text);
                    prRow.priceRozn = Convert.ToInt32(tbxRozPrice.Text);



                    DataSetTposTableAdapters.realizeviewTableAdapter realzvwDa = new DataSetTposTableAdapters.realizeviewTableAdapter();
                    DataSetTpos.realizeviewDataTable realviewtable             = new DataSetTpos.realizeviewDataTable();
                    realzvwDa.FillByID(realviewtable, prRow.productId);
                    if (realviewtable.Rows.Count > 0)
                    {
                        DataSetTposTableAdapters.changepriceTableAdapter chDa = new DataSetTposTableAdapters.changepriceTableAdapter();
                        DataSetTpos.changepriceRow changepriceRow             = DBclass.DS.changeprice.NewchangepriceRow();

                        changepriceRow.IDFaktura  = (realviewtable.Rows[0] as DataSetTpos.realizeviewRow).fakturaId;
                        changepriceRow.IDProduct  = prRow.productId;
                        changepriceRow.DateChange = DateTime.Now.Date;
                        changepriceRow.Price      = prRow.price;
                        DBclass.DS.changeprice.AddchangepriceRow(changepriceRow);
                        chDa.Update(changepriceRow);
                    }
                    daProduct.Update(DBclass.DS.product);
                    daProduct.Fill(DBclass.DS.product);
                }
            }
        }
コード例 #3
0
ファイル: AddForm.cs プロジェクト: umidjonv/tposDesktop
        private void AddOrEdit(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tbxName.Text))
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                DataSetTposTableAdapters.productTableAdapter daProduct = new DataSetTposTableAdapters.productTableAdapter();
                if (isAdd)
                {
                    int rbtn = 2;
                    DataSetTpos.productRow prRowN = DBclass.DS.product.NewproductRow();
                    prRowN.name    = tbxName.Text;
                    prRowN.barcode = tbxShtrix.Text;
                    if (measureRadio.Checked)
                    {
                        rbtn = 2; //ШТ
                    }
                    else if (measureRadio2.Checked)
                    {
                        rbtn = 1;//КГ
                    }
                    else if (measureRadio3.Checked)
                    {
                        rbtn = 3;//литр
                    }
                    else if (measureRadio4.Checked)
                    {
                        rbtn = 4; //кв.м
                    }
                    prRowN.measureId = rbtn;
                    prRowN.pack      = 0;// tbxPack.Text != "0" && tbxPack.Text != "" ? Convert.ToInt32(tbxPack.Text) : 0;
                    prRowN.status    = 0;
                    if (prCmbx.Text == "")
                    {
                        prRowN.providerId = 1;
                    }
                    else
                    {
                        prRowN.providerId = prCmbx.FindStringExact(prCmbx.Text);
                    }
                    prRowN.price = Convert.ToInt32(tbxPrice.Text);
                    DBclass.DS.product.AddproductRow(prRowN);
                    if (daProduct.Connection.State == ConnectionState.Closed)
                    {
                        daProduct.Connection.Open();
                    }

                    using (MySql.Data.MySqlClient.MySqlTransaction transaction = daProduct.Connection.BeginTransaction())
                    {
                        daProduct.Transaction = transaction;
                        daProduct.Update(prRowN);

                        daProduct.Fill(DBclass.DS.product);
                        int?lId = daProduct.LastID();
                        DataSetTposTableAdapters.balanceTableAdapter bAdapetr = new DataSetTposTableAdapters.balanceTableAdapter();
                        DataSetTpos.balanceRow bRow = DBclass.DS.balance.NewbalanceRow();
                        bRow.balanceDate = Convert.ToDateTime("2000-01-01");
                        bRow.prodId      = Convert.ToInt32(lId);
                        bRow.endCount    = 0;
                        bRow.curEndCount = 0;
                        DBclass.DS.balance.AddbalanceRow(bRow);
                        bAdapetr.Connection  = daProduct.Connection;
                        bAdapetr.Transaction = transaction;
                        bAdapetr.Update(bRow);
                        transaction.Commit();
                        if (lId != null && tbxShtrix.Text == "")
                        {
                            int id = lId.Value;
                            DataSetTpos.productRow pr = DBclass.DS.product.FindByproductId(id);
                            string barcode            = Generator.barcode_generate(id, 1);
                            pr.barcode = barcode;
                            pr.status  = 1;
                            daProduct.Update(pr);
                        }
                    }
                    ///Change changeprice
                }
                else
                {
                    int rbtn = 2;
                    prRow.name    = tbxName.Text;
                    prRow.barcode = tbxShtrix.Text;
                    if (measureRadio.Checked)
                    {
                        rbtn = 2; //ШТ
                    }
                    else if (measureRadio2.Checked)
                    {
                        rbtn = 1;//КГ
                    }
                    else if (measureRadio3.Checked)
                    {
                        rbtn = 3;//литр
                    }
                    else if (measureRadio4.Checked)
                    {
                        rbtn = 4; //кв.м
                    }
                    if (prCmbx.Text == "")
                    {
                        prRow.providerId = 1;
                    }
                    else
                    {
                        prRow.providerId = prCmbx.FindStringExact(prCmbx.Text);
                    }

                    prRow.measureId = rbtn;
                    prRow.pack      = 0;// tbxPack.Text != "0" && tbxPack.Text != "" ? Convert.ToInt32(tbxPack.Text) : 0; ;

                    prRow.price = Convert.ToInt32(tbxPrice.Text);



                    DataSetTposTableAdapters.realizeviewTableAdapter realzvwDa = new DataSetTposTableAdapters.realizeviewTableAdapter();
                    DataSetTpos.realizeviewDataTable realviewtable             = new DataSetTpos.realizeviewDataTable();
                    realzvwDa.FillByID(realviewtable, prRow.productId);
                    if (realviewtable.Rows.Count > 0)
                    {
                        DataSetTposTableAdapters.changepriceTableAdapter chDa = new DataSetTposTableAdapters.changepriceTableAdapter();
                        DataSetTpos.changepriceRow changepriceRow             = DBclass.DS.changeprice.NewchangepriceRow();

                        changepriceRow.IDFaktura  = (realviewtable.Rows[0] as DataSetTpos.realizeviewRow).fakturaId;
                        changepriceRow.IDProduct  = prRow.productId;
                        changepriceRow.DateChange = DateTime.Now.Date;
                        changepriceRow.Price      = prRow.price;
                        DBclass.DS.changeprice.AddchangepriceRow(changepriceRow);
                        chDa.Update(changepriceRow);
                    }
                    daProduct.Update(DBclass.DS.product);
                    daProduct.Fill(DBclass.DS.product);
                }
            }
        }