void AddUpdatePackingSlip() { try { ep1.Clear(); if (string.IsNullOrEmpty(cmbName.Text.Trim())) { ep1.SetError(cmbName, "This field is required."); cmbName.Focus(); return; } if (dgDisplayData.Rows.Count == 0) { Datalayer.InformationMessageBox("Record is required.."); } int T010_PACKINGSLIPID = Datalayer.T010_PACKINGSLIPID; // int TM01_CUSTOMERID = 0; string T010_NO = "", T010_TRANSPORT = "", T010_LRNO = ""; int T001_ACCOUNTID = 0; DateTime T003_DATE = dtpDate.Value; // int.TryParse(cmbCustomerName.SelectedValue.ToString(), out TM01_CUSTOMERID); T010_NO = txtBillNo.Text.Trim(); T010_TRANSPORT = txtTransport.Text.Trim(); T010_LRNO = txtLRNo.Text.Trim(); int.TryParse(cmbName.SelectedValue.ToString(), out T001_ACCOUNTID); if (T010_PACKINGSLIPID > 0) { int?iDeletePurchaseItem_out = 0; MyDa = new MyDabaseDataContext(Properties.Settings.Default.Style_King_Dev); MyDa.USP_VP_DELETE_ALL_PACKINGSLIPORDER(T010_PACKINGSLIPID, ref iDeletePurchaseItem_out); } int?T010_PACKINGSLIPID_out = 0; Cursor.Current = Cursors.WaitCursor; MyDa = new MyDabaseDataContext(Properties.Settings.Default.Style_King_Dev); MyDa.USP_VP_ADDUPDATE_PACKING_SLIP(T010_PACKINGSLIPID, T001_ACCOUNTID, T010_NO, T003_DATE, T010_TRANSPORT, T010_LRNO, Datalayer.iT001_COMPANYID, ref T010_PACKINGSLIPID_out); if (T010_PACKINGSLIPID_out > 0) { T010_PACKINGSLIPID = int.Parse(T010_PACKINGSLIPID_out.Value.ToString()); int? @T011_PACKINGSLIPORDERID_OUT = 0; for (int i = 0; i < dgDisplayData.Rows.Count; i++) { if (!string.IsNullOrEmpty(Convert.ToString(dgDisplayData.Rows[i].Cells["T004_ORDERID"].Value))) { int T004_ORDERID = 0, T011_QTY = 0; int.TryParse(Convert.ToString(dgDisplayData.Rows[i].Cells["T004_ORDERID"].Value), out T004_ORDERID); int.TryParse(Convert.ToString(dgDisplayData.Rows[i].Cells["T004_PENDING_QTY"].Value), out T011_QTY); if (T011_QTY > 0) { int?T002_PURCHASEITEMID_Out = 0; MyDa = new MyDabaseDataContext(Properties.Settings.Default.Style_King_Dev); MyDa.USP_VP_ADDUPDATE_PACKINGSLIPORDER(0, T010_PACKINGSLIPID, T004_ORDERID, T011_QTY, Datalayer.iT001_COMPANYID, ref T002_PURCHASEITEMID_Out); } } } if (Datalayer.T010_PACKINGSLIPID == 0) { Datalayer.InsertMessageBox(sPageName); ResteData(); if (Datalayer.ShowQuestMsg("are you sure do you want to print this bill ?")) { DAL dl = new DAL(); DataTable dt = new DataTable(); dt = dl.SelectMethod("exec USP_VP_GET_PRINT_PACKING_SLIP_ONID '" + T010_PACKINGSLIPID + "'"); if (dt.Rows.Count > 0) { ReportDocument RptDoc = new ReportDocument(); RptDoc.Load(Application.StartupPath + @"\Report\rptPackingSlip.rpt"); RptDoc.SetDataSource(dt); Datalayer.RptReport = RptDoc; Datalayer.sReportName = "Packing Slip Bill"; Report.frmReportViwer fmReport = new Report.frmReportViwer(); fmReport.Show(); } else { Datalayer.InformationMessageBox("No Record.."); } } //DataTable dt = new DataTable(); //dt = dl.SelectMethod("exec USP_VP_GET_FULLSALEBILL '" + T003_SALEID + "'"); //if (dt.Rows.Count > 0) //{ // ReportDocument RptDoc = new ReportDocument(); // RptDoc.Load(Application.StartupPath + @"\Report\rptRetailInvoice.rpt"); // RptDoc.SetDataSource(dt); // Datalayer.RptReport = RptDoc; // Datalayer.sReportName = "Invoice"; // frmReportViewer fmReport = new frmReportViewer(); // fmReport.Show(); //} } else { Datalayer.UpdateMessageBox(sPageName); this.Close(); } } else { if (Datalayer.T010_PACKINGSLIPID == 0) { Datalayer.DosenotInsertMessageBox(sPageName); } else { Datalayer.DosenotUpdateMessageBox(sPageName); } return; } } catch (Exception ex) { Datalayer.WorningMessageBox(ex.Message.ToString(), "Error"); } }