public T_SalesAllocDet Selectt_SalesAllocDetUsingDoc(T_SalesAllocDet objt_SalesAllocDet) { try { strquery = @"select * FROM T_SalesAllocDet WHERE Docno = '" + objt_SalesAllocDet.Docno + "'"; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { objt_SalesAllocDet.Docno = drType["Docno"].ToString(); objt_SalesAllocDet.SalesMan = drType["SalesMan"].ToString(); objt_SalesAllocDet.Customer = drType["Customer"].ToString(); objt_SalesAllocDet.Item = drType["Item"].ToString(); objt_SalesAllocDet.AllowedQTY = decimal.Parse(drType["AllowedQTY"].ToString()); objt_SalesAllocDet.AllocQTY = decimal.Parse(drType["AllocQTY"].ToString()); objt_SalesAllocDet.DateFrom = DateTime.Parse(drType["DateFrom"].ToString()); objt_SalesAllocDet.Dateto = DateTime.Parse(drType["Dateto"].ToString()); objt_SalesAllocDet.Userx = drType["Userx"].ToString(); objt_SalesAllocDet.Datex = DateTime.Parse(drType["Datex"].ToString()); return(objt_SalesAllocDet); } return(null); } catch (Exception ex) { throw ex; } }
/// <summary> /// Saves a record to the T_SalesAllocDet table. /// </summary> public Boolean Savet_SalesAllocDetSP(T_SalesAllocDet t_SalesAllocDet, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "T_SalesAllocDetSave"; scom.Parameters.Add("@Docno", SqlDbType.VarChar, 20).Value = t_SalesAllocDet.Docno; scom.Parameters.Add("@SalesMan", SqlDbType.VarChar, 20).Value = t_SalesAllocDet.SalesMan; scom.Parameters.Add("@Customer", SqlDbType.VarChar, 20).Value = t_SalesAllocDet.Customer; scom.Parameters.Add("@Item", SqlDbType.VarChar, 20).Value = t_SalesAllocDet.Item; scom.Parameters.Add("@AllowedQTY", SqlDbType.Decimal, 9).Value = t_SalesAllocDet.AllowedQTY; scom.Parameters.Add("@AllocQTY", SqlDbType.Decimal, 9).Value = t_SalesAllocDet.AllocQTY; scom.Parameters.Add("@DateFrom", SqlDbType.DateTime, 8).Value = t_SalesAllocDet.DateFrom; scom.Parameters.Add("@Dateto", SqlDbType.DateTime, 8).Value = t_SalesAllocDet.Dateto; scom.Parameters.Add("@Userx", SqlDbType.VarChar, 20).Value = t_SalesAllocDet.Userx; scom.Parameters.Add("@Datex", SqlDbType.DateTime, 8).Value = t_SalesAllocDet.Datex; scom.Parameters.Add("@InsMode", SqlDbType.Int).Value = formMode; // For insert scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0; u_DBConnection dbcon = new u_DBConnection(); retvalue = dbcon.RunQuery(scom); return(retvalue); } catch (Exception ex) { throw (ex); } }
public List <T_SalesAllocDet> SelectT_SalesAllocDetMulti(T_SalesAllocDet objt_SalesAllocDet2) { List <T_SalesAllocDet> retval = new List <T_SalesAllocDet>(); try { strquery = @"select * from t_SalesAllocDet where Docno = '" + objt_SalesAllocDet2.Docno + "'"; DataTable dtt_SalesAllocDet = u_DBConnection.ReturnDataTable(strquery, CommandType.Text); foreach (DataRow drType in dtt_SalesAllocDet.Rows) { if (drType != null) { T_SalesAllocDet objt_SalesAllocDet = new T_SalesAllocDet(); objt_SalesAllocDet.Docno = drType["Docno"].ToString(); objt_SalesAllocDet.SalesMan = drType["SalesMan"].ToString(); objt_SalesAllocDet.Customer = drType["Customer"].ToString(); objt_SalesAllocDet.Item = drType["Item"].ToString(); objt_SalesAllocDet.AllowedQTY = decimal.Parse(drType["AllowedQTY"].ToString()); objt_SalesAllocDet.AllocQTY = decimal.Parse(drType["AllocQTY"].ToString()); objt_SalesAllocDet.DateFrom = DateTime.Parse(drType["DateFrom"].ToString()); objt_SalesAllocDet.Dateto = DateTime.Parse(drType["Dateto"].ToString()); objt_SalesAllocDet.Userx = drType["Userx"].ToString(); objt_SalesAllocDet.Datex = DateTime.Parse(drType["Datex"].ToString()); retval.Add(objt_SalesAllocDet); } } return(retval); } catch (Exception ex) { throw ex; } }
private void button1_Click(object sender, EventArgs e) { if (0 < commonFunctions.ToDecimal(txt_qtyremain.Text.Trim())) { errorProvider1.SetError(txt_fullqty, "You must allocate full amount for the selected customer."); commonFunctions.SetMDIStatusMessage("You must allocate full amount for the selected customer.", 1); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { try { T_SalesAllocHead alloc = new T_SalesAllocHead(); alloc.Docno = selecteddoc; alloc = new T_SalesAllocHeadDL().Selectt_SalesAllocHead(alloc); decimal cumilative = decimal.Zero; foreach (DataGridViewRow drow in dgcustomer.Rows) { cumilative = commonFunctions.ToDecimal(drow.Cells[2].Value.ToString()); T_SalesAllocDet objt_SalesAllocDet = new T_SalesAllocDet(); objt_SalesAllocDet.Docno = selecteddoc; objt_SalesAllocDet.SalesMan = alloc.Salesman; objt_SalesAllocDet.Customer = drow.Cells[0].Value.ToString(); objt_SalesAllocDet.Item = alloc.Item; objt_SalesAllocDet.AllowedQTY = alloc.AllocQTY; objt_SalesAllocDet.AllocQTY = commonFunctions.ToDecimal(cumilative.ToString()); objt_SalesAllocDet.DateFrom = alloc.DateFrom.Value; objt_SalesAllocDet.Dateto = alloc.Dateto.Value; objt_SalesAllocDet.Userx = commonFunctions.Loginuser; objt_SalesAllocDet.Datex = DateTime.Now; T_SalesAllocDetDL bal = new T_SalesAllocDetDL(); bal.Savet_SalesAllocDetSP(objt_SalesAllocDet, 1); } LoadDataSavedALLOCATIONS(); } catch (Exception ex) { } } }
private void dgsaved_RowsRemoved_1(object sender, DataGridViewRowsRemovedEventArgs e) { try { T_SalesAllocDet det = new T_SalesAllocDet(); det.Docno = dcomming.Cells[0].Value.ToString(); det.SalesMan = dcomming.Cells[1].Value.ToString(); det.Customer = dcomming.Cells[2].Value.ToString(); det = new T_SalesAllocDetDL().Selectt_SalesAllocDet(det); ////new T_SalesAllocDetDL().Savet_SalesAllocDetSP(det, 4); ////LoadDataSavedALLOCATIONS(); //if ((dgsaved.SelectedRows.Count == 0) || ((dgsaved.SelectedRows.Count == 1) && (dgsaved.SelectedRows[0].IsNewRow))) //{ // MessageBox.Show("Set of rows deleted" + dgsaved.SelectedRows[0].Cells[2].Value.ToString()); //} } catch (Exception ex) { } }
private void button3_Click(object sender, EventArgs e) { try { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { string x = dgsaved.SelectedRows[0].Cells[0].Value.ToString(); T_SalesAllocDet det = new T_SalesAllocDet(); det.Docno = x.ToString(); List <T_SalesAllocDet> dets = new List <T_SalesAllocDet>(); dets = new T_SalesAllocDetDL().SelectT_SalesAllocDetMulti(det); foreach (T_SalesAllocDet de in dets) { new T_SalesAllocDetDL().Savet_SalesAllocDetSP(de, 4); } LoadDataSavedALLOCATIONS(); UserDefineMessages.ShowMsg1("All allocation breakdown Detleted for header allocation NO: " + x, UserDefineMessages.Msg_Information); } } catch (Exception ex) { } }
private void btn_save_Click(object sender, EventArgs e) { try { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { if (dgsaved.SelectedRows.Count > 0) { bool exists = false; List <string> itemsx = new List <string>(); foreach (DataGridViewRow rowx in dgsaved.SelectedRows) { string x = rowx.Cells[0].Value.ToString(); T_SalesAllocDet det = new T_SalesAllocDet(); det.Docno = x.ToString(); List <T_SalesAllocDet> dets = new List <T_SalesAllocDet>(); dets = new T_SalesAllocDetDL().SelectT_SalesAllocDetMulti(det); if (dets.Count > 0) { itemsx.Add(x); exists = true; } else { T_SalesAllocHead head = new T_SalesAllocHead(); head.Docno = rowx.Cells[0].Value.ToString(); head = new T_SalesAllocHeadDL().Selectt_SalesAllocHead(head); new T_SalesAllocHeadDL().Savet_SalesAllocHeadSP(head, 4); } } GetAllocations(selectedsalesman); if (exists == true) { string numbers = ""; foreach (string x in itemsx) { numbers += "\n" + x; } UserDefineMessages.ShowMsg1("Selected Allocation headers deleted except these " + numbers + " \nbecouse they have breakdowns", UserDefineMessages.Msg_Warning); } else { UserDefineMessages.ShowMsg1("Selected Allocation headers were deleted ", UserDefineMessages.Msg_Information); } } else { string x = dgsaved.SelectedRows[0].Cells[0].Value.ToString(); T_SalesAllocDet det = new T_SalesAllocDet(); det.Docno = x.ToString(); List <T_SalesAllocDet> dets = new List <T_SalesAllocDet>(); dets = new T_SalesAllocDetDL().SelectT_SalesAllocDetMulti(det); if (dets.Count > 0) { UserDefineMessages.ShowMsg1("Cannot delete the allocation master: " + x + ". becouse it has breakdowns ", UserDefineMessages.Msg_Warning); } else { T_SalesAllocHead head = new T_SalesAllocHead(); head.Docno = dgsaved.SelectedRows[0].Cells[0].Value.ToString(); head = new T_SalesAllocHeadDL().Selectt_SalesAllocHead(head); new T_SalesAllocHeadDL().Savet_SalesAllocHeadSP(head, 4); GetAllocations(selectedsalesman); UserDefineMessages.ShowMsg1("Allocation header detleted NO: " + x, UserDefineMessages.Msg_Information); } } } } catch (Exception ex) { } }