private void btnSave_Click(object sender, EventArgs e) { try { documentnumber dn = new documentnumber(); DocumentNumberDB DnDB = new DocumentNumberDB(); string[] docmts = txtDocument.Text.Split('-'); dn.rowid = DRowID; dn.fyID = cmbFY.SelectedItem.ToString().Trim().Substring(0, cmbFY.SelectedItem.ToString().Trim().IndexOf(':')).Trim(); dn.DocumentID = docmts[1]; dn.DocumentName = docmts[0]; dn.TemporaryNo = Convert.ToInt32(txtTempno.Text); dn.DocumentNo = Convert.ToInt32(txtDocumentNo.Text); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; if (DnDB.validateDocumentNo(dn)) { if (btnText.Equals("Update")) { if (DnDB.updateDocumentnumber(dn)) { MessageBox.Show("Document Number updated"); closeAllPanels(); ListOffice(); } else { MessageBox.Show("Failed to update Document Number"); } } else if (btnText.Equals("Save")) { if (DnDB.insertDocument(dn)) { MessageBox.Show("Document Number Added"); closeAllPanels(); ListOffice(); } else { MessageBox.Show("Failed to Insert Document Number"); } } } else { MessageBox.Show("Document Number Data Validation failed"); } } catch (Exception) { MessageBox.Show("Failed Adding / Editing Document Number"); } }
private void ListOffice() { try { grdList.Rows.Clear(); DocumentNumberDB dbrecord = new DocumentNumberDB(); List <documentnumber> docnum = dbrecord.getDocumentNo(); foreach (documentnumber doc in docnum) { grdList.Rows.Add(doc.rowid, doc.fyID, doc.DocumentID, doc.DocumentName, doc.TemporaryNo, doc.DocumentNo); } } catch (Exception) { MessageBox.Show("Error in Document Number listing"); } enableBottomButtons(); pnlOfficeList.Visible = true; }
private void btnSave_Click_1(object sender, EventArgs e) { Boolean status = true; try { SMRNDB smrnhDB = new SMRNDB(); smrn smrnh = new smrn(); try { ////////smrnh.CourierID = cmbCourierID.SelectedItem.ToString().Trim().Substring(0,cmbCourierID.SelectedItem.ToString().Trim().IndexOf('-')); smrnh.CourierID = ((Structures.ComboBoxItem)cmbCourierID.SelectedItem).HiddenValue; //////////smrnh.CustomerID = cmbCustomer.SelectedItem.ToString().Trim().Substring(0, cmbCustomer.SelectedItem.ToString().Trim().IndexOf('-')); smrnh.CustomerID = ((Structures.ComboBoxItem)cmbCustomer.SelectedItem).HiddenValue; } catch (Exception) { smrnh.CustomerID = ""; smrnh.CustomerName = ""; } smrnh.DocumentID = docID; smrnh.SMRNDate = dtSMRNDate.Value; smrnh.CustomerDocumentDate = dtCustomerDocDate.Value; smrnh.Remarks = txtRemarks.Text; smrnh.NoOfPackets = Convert.ToInt32(txtNoOfPacket.Text); smrnh.CustomerDocumentNo = txtCuxtomerDocNo.Text; string btnText = btnSave.Text; if (btnText.Equals("Update")) { smrnh.ForwarderList = prevsh.ForwarderList; smrnh.SMRNNo = Convert.ToInt32(txtSMRNNo.Text); if (smrnhDB.validateSMRN(smrnh)) { if (smrnhDB.updateSMRN(smrnh, prevsh)) { MessageBox.Show("SMRN updated"); closeAllPanels(); listOption = 1; ListFilteredSMRN(listOption); } else { status = false; MessageBox.Show("Failed to update SMRN"); } } else { status = false; MessageBox.Show("Smrn DEtail Entered Wrong"); } } else if (btnText.Equals("Save")) { smrnh.DocumentStatus = 1;//created smrnh.SMRNDate = UpdateTable.getSQLDateTime(); smrnh.SMRNNo = DocumentNumberDB.getNewNumber(docID, 1); if (smrnhDB.validateSMRN(smrnh)) { if (smrnhDB.insertSMRN(smrnh)) { MessageBox.Show("SMRN Added"); closeAllPanels(); listOption = 1; ListFilteredSMRN(listOption); } else { MessageBox.Show("Failed to Insert SMRN"); status = false; } } else { status = false; MessageBox.Show("Smrn DEtail Entered Wrong"); } } else { status = false; MessageBox.Show("SMRN Data Operation failed"); } } catch (Exception ex) { MessageBox.Show("Failed Adding / Editing SMRN"); status = false; } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }
private void btnSave_Click(object sender, EventArgs e) { Boolean status = true; try { List <smrnservicedlist> SMRNServList; SMRNServicedListDB ServListDB = new SMRNServicedListDB(); smrnservicedlist ServList = new smrnservicedlist(); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btnSave.Text; try { ServList.DocumentID = docID; smrnservicedlist smrnserv; SMRNServList = new List <smrnservicedlist>(); for (int i = 0; i < grdSMRNServList.Rows.Count; i++) { try { DataGridViewCheckBoxCell cell = grdSMRNServList.Rows[i].Cells["check"] as DataGridViewCheckBoxCell; if (cell.Value != null) { if (Convert.ToBoolean(cell.Value) == true) { smrnserv = new smrnservicedlist(); smrnserv.SMRNHeaderNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["gSMRNHeaderNo"].Value.ToString().Trim()); smrnserv.SMRNHeaderDate = Convert.ToDateTime(grdSMRNServList.Rows[i].Cells["gSMRNHeaderDate"].Value.ToString().Trim()); smrnserv.JobIDNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["JobId"].Value.ToString().Trim()); smrnserv.ListNo = Convert.ToInt32(grdSMRNServList.Rows[i].Cells["gTemporaryNo"].Value.ToString().Trim()); /// For storing TemporaryNo of SMRNDetail smrnserv.ListDate = Convert.ToDateTime(grdSMRNServList.Rows[i].Cells["gTemporaryDate"].Value.ToString().Trim()); ////for storing temporaryDate of SMRNdetail SMRNServList.Add(smrnserv); } } } catch (Exception ex) { MessageBox.Show("createAndUpdateSMRNDetails() : Error creating SMRN Details"); status = false; return; } } ServList.Status = 1; } catch (Exception ex) { MessageBox.Show("Validation failed"); return; } if (btnText.Equals("Save")) { ServList.ListNo = DocumentNumberDB.getNewNumber(docID, 1); ServList.DocumentStatus = 1; ServList.ListDate = UpdateTable.getSQLDateTime(); } else { ServList.ListNo = Convert.ToInt32(txtListNo.Text); ServList.DocumentStatus = prevservlist.DocumentStatus; ServList.ListDate = prevservlist.ListDate; } if (btnText.Equals("Save")) { if (ServListDB.updateSMRNServicedList(ServList, SMRNServList, 1)) { MessageBox.Show("SMRNService List Details Added"); closeAllPanels(); listOption = 1; ListFilteredSMRNServiceList(listOption); } else { status = false; } if (!status) { MessageBox.Show("Failed to Insert SMRNServiceList"); status = false; } } else { MessageBox.Show("SMRNServiceList Validation failed"); status = false; } } catch (Exception ex) { MessageBox.Show("SMRNServiceList Validation failed"); status = false; } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }