public void triggerExecute(string trigger, int id) { productTableAdapter productDa = new productTableAdapter(); MySqlCommand command = new MySqlCommand("CALL `" + trigger + "`('" + id + "')", productDa.Connection); if (command.Connection.State == ConnectionState.Closed) { try { //getPriceTableAdapter gpDa = new getPriceTableAdapter(); //switch (trigger) //{ // case "FakturaTrigger": // gpDa.FakturaTrigger(id); // break; // case "BackTrigger": // gpDa.BackTrigger(id); // break; // case "ExpenseTrigger": // gpDa.ExpenseTrigger(id); // break; //} command.Connection.Open(); command.CommandTimeout = 200; int i = command.ExecuteNonQuery(); command.Connection.Close(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } } }
static Purchase() { receiptTableAdapter daReceipt = new receiptTableAdapter(); daReceipt.Fill(dsReceipt.receipt); employeeTableAdapter daEmployee = new employeeTableAdapter(); daEmployee.Fill(dsReceipt.employee); productTableAdapter daProducts = new productTableAdapter(); productTable = daProducts.GetData(); order_lineTableAdapter daLine = new order_lineTableAdapter(); daLine.Fill(dsReceipt.order_line); service_orderTableAdapter daService = new service_orderTableAdapter(); daService.Fill(dsReceipt.service_order); equipmentTableAdapter daEqu = new equipmentTableAdapter(); daEqu.Fill(dsReceipt.equipment); }
public bool AddProduct(DataRow[] dr, bool isBarcode, string barcode) { bool next = false; float kg = -1; if (isBarcode && dr.Length == 0) { //object[] obj = getProductWithMassa(barcode); //dr = (DataRow[])obj[0]; //kg = (float)obj[1]; dr = getProductWithMassa(barcode); } if (dr.Length != 0) { DataSetTpos.productRow drP = (DataSetTpos.productRow)dr[0]; DataRow[] existRows = DBclass.DS.orders.Select("expenseId=-1 and prodId = " + drP.productId); if (existRows.Length > 0) { DataSetTpos.ordersRow ordrow = (DataSetTpos.ordersRow)existRows[0]; ordrow.packCount = ordrow.packCount + (drP.pack == 0 ? 1 : drP.pack); DataRow drOrder = ordrow; drOrder["sumProduct"] = ordrow.packCount * drP.price / (drP.pack == 0 ? 1 : drP.pack);//ordrow.AcceptChanges(); } else { DataSetTpos.ordersRow ordrow = DBclass.DS.orders.NewordersRow(); ordrow.prodId = drP.productId; if (drP.pack == 0) { drP.pack = 1; } ordrow.expenseId = -1; int curPrice = drP.price; OrderForm oform = new OrderForm(drP); System.Windows.Forms.DialogResult result = oform.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { ordrow.packCount = (float)oform.count; DataRow drOrder = ordrow; drOrder["sumProduct"] = oform.sum;//ordrow.packCount * drP.price / (drP.pack == 0 ? 1 : drP.pack); ordrow.orderSumm = Convert.ToSingle(drOrder["sumProduct"]); //grid.Rows[e.RowIndex].Cells["sumProduct"].Value = (Convert.ToInt32(grid.Rows[e.RowIndex].Cells["packCount"].Value) * Convert.ToInt32(grid.Rows[e.RowIndex].Cells["productPrice"].Value)).ToString(); } else if (result == System.Windows.Forms.DialogResult.Cancel) { //ordrow.RejectChanges(); drP.RejectChanges(); return(false); } else { if (drP.price == 0) { System.Windows.Forms.MessageBox.Show("Товар на складе отсутствует"); drP.RejectChanges(); } return(false); } DBclass.DS.orders.AddordersRow(ordrow); if (curPrice != drP.price && drP.price != 0) { productTableAdapter prda = new productTableAdapter(); prda.Update(drP); return(true); } } if (isNewExpense) { //dgvExpense.Columns["productName"].Visible = true; //dgvExpense.Columns["productPrice"].Visible = true; isNewExpense = false; } //sumTable(); } else if (isBarcode && UserValues.role == "admin") { AddForm addForm = new AddForm(barcode); if (addForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //productTableAdapter daProduct = new productTableAdapter(); //daProduct.Fill(DBclass.DS.product); } } next = true; return(true); }