private void AddOrEdit(object sender, EventArgs e) { if (!string.IsNullOrEmpty(tbxName.Text)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; DataSetTposTableAdapters.realizeTableAdapter daReal = new DataSetTposTableAdapters.realizeTableAdapter(); DBclass db = new DBclass(); DataSetTpos.realizeRow[] rlRows = (DataSetTpos.realizeRow[])DBclass.DS.realize.Select("prodid = " + prRow.productId + " and fakturaId = " + fkRow.fakturaId); DataSetTpos.realizeRow rlRow; if (rlRows.Length > 0) { float cnt; rlRow = rlRows[0]; if (pack != 0) { cnt = Convert.ToInt32(tbxPack.Text) * pack + Convert.ToInt32(tbxKol.Text); } else { System.Globalization.NumberFormatInfo format = new System.Globalization.NumberFormatInfo(); cnt = Convert.ToSingle(tbxPack.Text.Replace(",", format.CurrencyDecimalSeparator).Replace(".", format.CurrencyDecimalSeparator), format); } rlRow.count += cnt; rlRow.price = Convert.ToInt32(tbxPricePrixod.Text); rlRow.soldPrice = Convert.ToInt32(tbxSoldPrice.Text); //db.triggerExecute() db.calcProc("plus", prRow.productId, cnt); } else { float cnt; rlRow = DBclass.DS.realize.NewrealizeRow(); if (pack != 0) { cnt = Convert.ToInt32(Math.Round(Convert.ToDouble(tbxPack.Text) * pack, 2) + Convert.ToInt32(tbxKol.Text)); } else { System.Globalization.NumberFormatInfo format = new System.Globalization.NumberFormatInfo(); cnt = Convert.ToSingle(tbxPack.Text.Replace(",", format.CurrencyDecimalSeparator).Replace(".", format.CurrencyDecimalSeparator), format); } rlRow.count = cnt; rlRow.price = Convert.ToInt32(tbxPricePrixod.Text); rlRow.soldPrice = Convert.ToInt32(tbxSoldPrice.Text); rlRow.fakturaId = fkRow.fakturaId; rlRow.prodId = prRow.productId; DBclass.DS.realize.AddrealizeRow(rlRow); db.calcProc("plus", prRow.productId, cnt); } //if(prRow.price==0) prRow.price = rlRow.soldPrice; daReal.Update(DBclass.DS.realize); daReal.Fill(DBclass.DS.realize); } }
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; }
private void AddOrEdit(object sender, EventArgs e) { if (!string.IsNullOrEmpty(tbxName.Text)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; DataSetTposTableAdapters.realizeTableAdapter daReal = new DataSetTposTableAdapters.realizeTableAdapter(); DataSetTpos.realizeRow[] rlRows = (DataSetTpos.realizeRow[])DBclass.DS.realize.Select("prodid = " + prRow.productId + " and fakturaId = " + fkRow.fakturaId); DataSetTpos.realizeRow rlRow; if (rlRows.Length > 0) { rlRow = rlRows[0]; if (pack != 0) { rlRow.count += Convert.ToInt32(tbxPack.Text) * pack + Convert.ToInt32(tbxKol.Text); } else { rlRow.count += Convert.ToInt32(tbxPack.Text); } rlRow.price = Convert.ToInt32(tbxPricePrixod.Text); rlRow.soldPrice = Convert.ToInt32(tbxSoldPrice.Text); } else { rlRow = DBclass.DS.realize.NewrealizeRow(); if (pack != 0) { rlRow.count = Convert.ToInt32(Math.Round(Convert.ToDouble(tbxPack.Text) * pack, 2) + Convert.ToInt32(tbxKol.Text)); } else { rlRow.count = Convert.ToInt32(tbxPack.Text); } rlRow.price = Convert.ToInt32(tbxPricePrixod.Text); rlRow.soldPrice = Convert.ToInt32(tbxSoldPrice.Text); rlRow.fakturaId = fkRow.fakturaId; rlRow.prodId = prRow.productId; DBclass.DS.realize.AddrealizeRow(rlRow); } if (prRow.price == 0) { prRow.price = rlRow.soldPrice; } daReal.Update(DBclass.DS.realize); daReal.Fill(DBclass.DS.realize); } }