private void txtTemporaryNo_TextChanged(object sender, EventArgs e) { try { if (txtTemporaryNo.Text.Trim().Length > 0) { string docid = cmbInvoiceDocument.SelectedItem.ToString(); int tempno = Convert.ToInt32(txtTemporaryNo.Text); List<proformainvoice> custval = ProformaInvoiceDB.getProformaInfo(tempno, docid); if (custval != null) { txtCustomerName.Text = custval.Select(x => x.customername).FirstOrDefault(); txtInvoiceAmount.Text = custval.Select(x => x.InvoiceAmt).FirstOrDefault().ToString(); DocNo = custval.Select(x => x.DocumentNo).FirstOrDefault(); docdate = custval.Select(x => x.DocumentDate).FirstOrDefault(); Tempdate = custval.Select(x => x.TemporaryDate).FirstOrDefault(); } } else { txtCustomerName.Text = ""; txtInvoiceAmount.Text =""; DocNo = 0; docdate = DateTime.MinValue; Tempdate = DateTime.MinValue; } } catch (Exception ex) { } }
private void ListDocument() { try { grdList.Rows.Clear(); ProformaInvoiceDB dbrecord = new ProformaInvoiceDB(); List<proformainvoice> Documents = dbrecord.getProformaDocuments(); foreach (proformainvoice doc in Documents) { grdList.Rows.Add(doc.DocumentID, doc.TemporaryNo, doc.TemporaryDate, doc.DocumentNo, doc.DocumentDate); } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } enableBottomButtons(); pnlDocumentList.Visible = true; }
private void btnSave_Click(object sender, EventArgs e) { try { proformainvoice PI = new proformainvoice(); ProformaInvoiceDB PIDB = new ProformaInvoiceDB(); PI.DocumentID = cmbInvoiceDocument.SelectedItem.ToString(); PI.TemporaryNo = Convert.ToInt32(txtTemporaryNo.Text); PI.TemporaryDate = Tempdate; PI.DocumentDate = docdate; PI.DocumentNo = DocNo; if (PIDB.validateDocument(PI)) { if (PIDB.insertDocument(PI)) { MessageBox.Show("Proforma Invoice data Added"); Tempdate = DateTime.MinValue; docdate = DateTime.MinValue; DocNo = 0; closeAllPanels(); ListDocument(); } else { MessageBox.Show("Failed to Insert Proforma Invoice"); } } else { MessageBox.Show("Please check the temporaryNo Entered!!!"); } } catch (Exception) { MessageBox.Show("Failed Adding / Editing User Data"); } }