private void btnSave_Click(object sender, EventArgs e) { try { DispatchNote_DL objDispatchNote_DL = new DispatchNote_DL(ConnectionStringClass.GetConnection()); DispatchNoteList_DL objDispatchNoteList_DL = new DispatchNoteList_DL(ConnectionStringClass.GetConnection()); DispatchNote objDispatchNote = new DispatchNote(); objDispatchNote.DispatchID = txtDiaptchNote.Text; objDispatchNote.DistributorID = cmbDistributor.SelectedValue.ToString(); objDispatchNote.EnteredBy = CurrentUser.EmployeeID; int x = objDispatchNote_DL.Add(objDispatchNote); if (x > 0) { foreach (DispatchNoteList _obj in objCollec) { objDispatchNoteList_DL.Add(_obj, StoreID); } MessageBox.Show("Successfully Saved"); Clear_Data(); } } catch (Exception ex) { } }
private void btnSave_Click(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(txtDispatchID.Text)) { if (cmbCustomer.Text != "") { if (dgvProduct.Rows.Count > 0) { String DISPATCHID = txtDispatchID.Text; if (cmbTerritory.SelectedValue != null) { objDispatchNote.TerritoryID = Convert.ToInt32(cmbTerritory.SelectedValue.ToString()); } else { objDispatchNote.TerritoryID = 0; } objDispatchNote.DispatchID = DISPATCHID; objDispatchNote.DistributorID = cmbCustomer.SelectedValue.ToString(); objDispatchNote.EnteredBy = CurrentUser.UserEmp.EmployeeID; objDispatchNote_DL.Add(objDispatchNote); foreach (DataGridViewRow dr in dgvProduct.Rows) { string tempproduct = dr.Cells[1].Value.ToString(); string tempstore = dr.Cells[3].Value.ToString(); long tempqty = Convert.ToInt64(dr.Cells[4].Value.ToString()); objDispatchNoteList.DispatchID = DISPATCHID; objDispatchNoteList.FinishProduct = tempproduct; objDispatchNoteList.BatchNo = "1"; objDispatchNoteList.Qty = tempqty; objDispatchNoteList_DL.Add(objDispatchNoteList, tempstore); objStock_DL.UpdateFinishProductAvailability(DISPATCHID, tempproduct, Convert.ToInt32(tempqty)); MessageBox.Show(this, "Dispatch Note successfully added", "Successful", MessageBoxButtons.OK, MessageBoxIcon.None); ClearFields(); } } else { MessageBox.Show(this, "Please add product to Order list", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show(this, "Please Select a Customer", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show(this, "Please Enter DispatchID", "Blank Fields", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }