Ejemplo n.º 1
0
        public AddRealize(DataSetTpos.realizeRow rlzRow, DataSetTpos.realizeviewRow rlvRow, DataSetTpos.productRow productRow)
        {
            prRow = productRow;
            //prRow = productRow;
            //fkRow = faktRow;
            isEdit = true;
            InitializeComponent();
            string sum = "0";


            if (DBclass.DS.balanceview.Rows.Count > 0)
            {
                DataRow[] blncs = DBclass.DS.balanceview.Select("prodId = " + rlvRow.productId);
                if (blncs.Length > 0)
                {
                    sum = ((DataSetTpos.balanceviewRow)blncs[0]).endCount;
                }
            }
            btnAdd.Text          = "Изменить";
            lblSoldPrice.Visible = true;
            tbxSoldPrice.Visible = true;
            lblAllCount.Text     = sum;
            DataView dv = new DataView(DBclass.DS.provider);

            dv.RowFilter     = "providerId = " + rlvRow.providerId.ToString();
            providerLbl.Text = dv[0]["orgName"].ToString();
            tbxPack.isFloat  = true;
            tbxName.Text     = rlvRow.name;
            tbxPack.Text     = 1.ToString();

            pack = float.Parse(rlvRow.count);

            tbxPricePrixod.Text = rlzRow.price.ToString();
            tbxShtrix.Text      = rlvRow.barcode;
            //tbxSoldPrice.Text = productRow.price.ToString();

            DataSetTposTableAdapters.realizeviewTableAdapter rlvda = new DataSetTposTableAdapters.realizeviewTableAdapter();
            DataSetTpos.realizeviewDataTable tablerlv = new DataSetTpos.realizeviewDataTable();
            rlvda.FillByID(tablerlv, rlvRow.productId);
            tbxPricePrixod.Text = (tablerlv.Rows.Count > 0 ? (tablerlv.Rows[0] as DataSetTpos.realizeviewRow).fakturaPrice.ToString() : "0");


            if (rlvRow.barcode != null)
            {
                tbxShtrix.Text = rlvRow.barcode;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;

            tbxKol.Text = rlzRow.count.ToString();

            tbxPack.Enabled        = false;
            tbxPricePrixod.Enabled = false;

            rlviewRow = rlvRow;
            rlRow     = rlzRow;
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }