/// <summary> /// Function to fill AgainstOrder combobox /// </summary> public void AgainstOrderComboFill() { try { bool isEveryComboFill = false; SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesQuotationBll bllQuotation = new SalesQuotationBll(); List<DataTable> ListObj = new List<DataTable>(); if (cmbCashOrParty.SelectedValue.ToString() != null && cmbDeliveryMode.SelectedValue.ToString() != "System.Data.DataRowView") { cmbOrderNo.Text = string.Empty; if (strTypeOfVoucher == "Sales Order") { ListObj = bllSalesOrder.GetSalesOrderInvoiceNumberCorrespondingToLedgerId(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()), Convert.ToDecimal(cmbDeliveryMode.SelectedValue.ToString())); DataRow dr = ListObj[0].NewRow(); dr[0] = "0"; dr[1] = string.Empty; ListObj[0].Rows.InsertAt(dr, 0); cmbOrderNo.DataSource = ListObj[0]; if (ListObj[0].Rows.Count > 0) { cmbOrderNo.DisplayMember = "invoiceNo"; cmbOrderNo.ValueMember = "salesOrderMasterId"; cmbOrderNo.SelectedIndex = 0; } } else if (strTypeOfVoucher == "Sales Quotation") { ListObj = bllQuotation.GetSalesQuotationNumberCorrespondingToLedger(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()), Convert.ToDecimal(cmbDeliveryMode.SelectedValue.ToString())); DataRow dr = ListObj[0].NewRow(); dr[0] = "0"; dr[1] = string.Empty; ListObj[0].Rows.InsertAt(dr, 0); cmbOrderNo.DataSource = ListObj[0]; if (ListObj[0].Rows.Count > 0) { cmbOrderNo.DisplayMember = "invoiceNo"; cmbOrderNo.ValueMember = "quotationMasterId"; } } else { GridFill(); } } isEveryComboFill = true; } catch (Exception ex) { MessageBox.Show("DNREP06: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Showing Reminder If Any one have /// </summary> public void ShowReminderIfAny() { try { string Purchasereminder = string.Empty; string Salesreminder = string.Empty; string Personalreminder = string.Empty; string NegativeStkreminder = string.Empty; string MinStkreminder = string.Empty; string MaxStkreminder = string.Empty; string ReordrStkreminder = string.Empty; string ShortExpiryReminder = string.Empty; List<DataTable> ListObj = new List<DataTable>(); PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverduePurchaseOrder", "View")) { ListObj = BllPurchaseOrder.PurchaseOrderOverDueReminder(PublicVariables._dtFromDate, PublicVariables._dtToDate, "Due", PublicVariables._dtCurrentDate, "All"); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) Purchasereminder = Purchasereminder + "1 Overdue purchase order\n\n"; else Purchasereminder = Purchasereminder + ListObj[0].Rows.Count + " Overdue purchase orders\n\n"; } } SalesOrderBll bllSalesOrder = new SalesOrderBll(); if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverdueSalesOrder", "View")) { ListObj = bllSalesOrder.SalesOrderOverDueReminder(PublicVariables._dtFromDate, PublicVariables._dtToDate, "Due", PublicVariables._dtCurrentDate, "All"); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) Salesreminder = Salesreminder + "1 Overdue sales order\n\n"; else Salesreminder = Salesreminder + ListObj[0].Rows.Count + " Overdue sales orders\n\n"; } } RemainderBll bllRemainder = new RemainderBll(); if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Delete") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Update") || CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Save")) { string FromDate = Convert.ToString(PublicVariables._dtCurrentDate); string ToDate = Convert.ToString(PublicVariables._dtCurrentDate); ListObj = bllRemainder.ReminderSearch(FromDate, ToDate); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) Personalreminder = Personalreminder + "1 personal reminder \n\n"; else Personalreminder = Personalreminder + ListObj[0].Rows.Count + " Personal reminders\n\n"; } } if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmShortExpiry", "View")) { ListObj = bllRemainder.ShortExpiryReminder(0, 0, 0, 0, 0, 0, 0, 0); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) ShortExpiryReminder = ShortExpiryReminder + "1 Product batch is going to expire"; else ShortExpiryReminder = ShortExpiryReminder + ListObj[0].Rows.Count + " Product batches going to expire"; } } if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmStock", "View")) { ListObj = bllRemainder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Negative Stock"); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) NegativeStkreminder = NegativeStkreminder + "1 Negative stock product \n\n"; else NegativeStkreminder = NegativeStkreminder + ListObj[0].Rows.Count + " Negative stock products\n\n"; } ListObj = bllRemainder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Minimum Level"); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) MinStkreminder = MinStkreminder + "1 Minimum stock product \n\n"; else MinStkreminder = MinStkreminder + ListObj[0].Rows.Count + " Minimum stock products \n\n"; } ListObj = bllRemainder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Maximum Level"); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) MaxStkreminder = MaxStkreminder + "1 Maximum stock product \n\n"; else MaxStkreminder = MaxStkreminder + ListObj[0].Rows.Count + " Maximum stock products \n\n"; } ListObj = bllRemainder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Reorder Level"); if (ListObj[0].Rows.Count > 0) { if (ListObj[0].Rows.Count == 1) ReordrStkreminder = ReordrStkreminder + "1 Reorder Level product \n\n"; else ReordrStkreminder = ReordrStkreminder + ListObj[0].Rows.Count + " Reorder Level products \n\n"; } } if (Salesreminder.Trim() != string.Empty || Purchasereminder.Trim() != string.Empty || Personalreminder.Trim() != string.Empty || NegativeStkreminder.Trim() != string.Empty || MinStkreminder.Trim() != string.Empty || MaxStkreminder.Trim() != string.Empty || ReordrStkreminder.Trim() != string.Empty) { frmReminderPopUp frmReminder = new frmReminderPopUp(); frmReminderPopUp isOpen = Application.OpenForms["frmReminderPopUp"] as frmReminderPopUp; if (isOpen == null) { frmReminder.WindowState = FormWindowState.Normal; frmReminder.MdiParent = formMDI.MDIObj; frmReminder.BringToFront(); frmReminder.ChangeLabel(Salesreminder, Purchasereminder, Personalreminder, ShortExpiryReminder, NegativeStkreminder, MinStkreminder, MaxStkreminder, ReordrStkreminder); } } } catch (Exception ex) { MessageBox.Show("CCD : 13 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Edit Function When update datas in Register or Report /// </summary> public void EditFunction() { try { decimal decSalesOrderSuffixPrefixId = 0; SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo(); infoSalesOrderMaster.VoucherTypeId = decSalesVoucherId; for (int inI = 0; inI < dgvSalesOrder.Rows.Count - 1; inI++) { if (Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) != null && Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) != 0) { //for (int i = 0; i < dgvSalesOrder.Rows.Count - 1; i++) //{ isEditDetails = Convert.ToString(bllSalesOrder.SalesOrderRefererenceCheckForEditDetails(Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value))); //} } } isEditMaster = Convert.ToString(bllSalesOrder.SalesOrderRefererenceCheckForEditMaster(decSalesOrderMasterId)); if (isEditMaster == "False" && isEditDetails == "False") { infoSalesOrderMaster.SalesOrderMasterId = decSalesOrderMasterId; infoSalesOrderMaster.Cancelled = cbxCancelled.Checked; infoSalesOrderMaster.Date = Convert.ToDateTime(txtDate.Text); infoSalesOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text); infoSalesOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoSalesOrderMaster.SuffixPrefixId = Convert.ToDecimal(decSalesOrderSuffixPrefixId); infoSalesOrderMaster.VoucherNo = strVoucherNo; infoSalesOrderMaster.InvoiceNo = txtOrderNo.Text; infoSalesOrderMaster.UserId = PublicVariables._decCurrentUserId; infoSalesOrderMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); infoSalesOrderMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); if (cmbQuotationNo.SelectedIndex == -1) { infoSalesOrderMaster.QuotationMasterId = 0; } else { infoSalesOrderMaster.QuotationMasterId = Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString()); } infoSalesOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoSalesOrderMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoSalesOrderMaster.Narration = txtNarration.Text.Trim(); infoSalesOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoSalesOrderMaster.Extra1 = string.Empty; infoSalesOrderMaster.Extra2 = string.Empty; RemoveSalesOrderDetails(); bllSalesOrder.SalesOrderMasterEdit(infoSalesOrderMaster); SalesOrderDetailsEditFill(); Messages.UpdatedMessage(); if (frmSalesOrderRegisterObj != null) { if (cbxPrintAfterSave.Checked == true) { if (new SettingsBll().SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesOrderMasterId); } else { Print(decSalesOrderMasterId); } } this.Close(); frmSalesOrderRegisterObj.GridFill(); } if (frmSalesOrderReportObj != null) { if (cbxPrintAfterSave.Checked == true) { if (new SettingsBll().SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesOrderMasterId); } else { Print(decSalesOrderMasterId); } } this.Close(); frmSalesOrderReportObj.GridFill(); } if (frmDayBookObj != null) { if (cbxPrintAfterSave.Checked == true) { if (new SettingsBll().SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesOrderMasterId); } else { Print(decSalesOrderMasterId); } } this.Close(); } if (objVoucherSearch != null) { if (cbxPrintAfterSave.Checked == true) { if (new SettingsBll().SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesOrderMasterId); } else { Print(decSalesOrderMasterId); } } this.Close(); objVoucherSearch.GridFill(); } } else { Messages.ReferenceExistsMessageForUpdate(); } } catch (Exception ex) { MessageBox.Show("SO47:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to use print /// </summary> /// <param name="decSalesOrderMasterId"></param> public void Print(decimal decSalesOrderMasterId) { try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); DataSet dsSalesOrder = bllSalesOrder.SalesOrderPrinting(decSalesOrderMasterId, 1); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.SalesOrderPrinting(dsSalesOrder); } catch (Exception ex) { MessageBox.Show("SO36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To fill the Order combo box based on the sales order numbers /// </summary> public void AgainstOrderComboFill() { try { List<DataTable> ListObj = new List<DataTable>(); if (cmbType.SelectedValue.ToString() != "System.Data.DataRowView") { ListObj = new SalesOrderBll().GetSalesOrderNoIncludePendingCorrespondingtoLedgerforDN(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()), Convert.ToDecimal(cmbType.SelectedValue.ToString()), decDelivryNoteIdToEdit); DataRow dr = ListObj[0].NewRow(); dr[0] = "0"; dr[1] = string.Empty; ListObj[0].Rows.InsertAt(dr, 0); cmbOrderNo.DataSource = ListObj[0]; if (ListObj[0].Rows.Count > 0) { cmbOrderNo.ValueMember = "salesOrderMasterId"; cmbOrderNo.DisplayMember = "invoiceNo"; cmbOrderNo.SelectedIndex = 0; } } } catch (Exception ex) { MessageBox.Show("DN14: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo(); DeliveryNoteDetailsInfo infoDeliveryNoteDetails = new DeliveryNoteDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingBll BllStockPosting = new StockPostingBll(); // StockPostingSP spStockPosting = new StockPostingSP(); //DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); //DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP(); DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); infoDeliveryNoteMaster.InvoiceNo = txtDeliveryNoteNo.Text; infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId; infoDeliveryNoteMaster.Date = Convert.ToDateTime(txtDate.Text); infoDeliveryNoteMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoDeliveryNoteMaster.VoucherNo = strVoucherNo; infoDeliveryNoteMaster.SuffixPrefixId = decDeliveryNoteSuffixPrefixId; if (btnSave.Text == "Save") { if (cmbOrderNo.SelectedValue != null) { if (cmbDeliveryMode.Text == "Against Order") { infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesOrderMaster = bllSalesOrder.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesQuotationMaster = bllSalesQuotation.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId); } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } } else { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); if (cmbSalesMan.SelectedIndex != -1) { infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { infoDeliveryNoteMaster.EmployeeId = 0; } infoDeliveryNoteMaster.Narration = txtNarration.Text; infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text); infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId; infoDeliveryNoteMaster.LrNo = txtLRNo.Text; infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text; infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoDeliveryNoteMaster.Extra1 = string.Empty; infoDeliveryNoteMaster.Extra2 = string.Empty; infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); if (decDelivryNoteIdToEdit == 0) { decDeliveryNoteMasterId = Convert.ToDecimal(bllDeliveryNote.DeliveryNoteMasterAdd(infoDeliveryNoteMaster)); } int inRowcount = dgvProduct.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null) { if (cmbDeliveryMode.Text == "Against Order") { if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null) { infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else if (cmbDeliveryMode.Text == "Against Quotation") { if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null) { infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else { if (cmbOrderNo.SelectedText != string.Empty) { if (cmbDeliveryMode.Text == "Against Order") { infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } infoDeliveryNoteDetails.ProductId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtProductId"].Value.ToString()); infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString()); infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString()); infoDeliveryNoteDetails.Extra1 = string.Empty; infoDeliveryNoteDetails.Extra2 = string.Empty; if (decDelivryNoteIdToEdit == 0) { infoDeliveryNoteDetails.DeliveryNoteMasterId = decDeliveryNoteMasterId; bllDeliveryNote.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails); } else { infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit; bllDeliveryNote.DeliveryNoteDetailsEdit(infoDeliveryNoteDetails); } infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null) { if (cmbDeliveryMode.SelectedItem.ToString() != "NA") { if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null) { infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value); } else { infoStockPosting.VoucherTypeId = 0; } if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value != null) { infoStockPosting.VoucherNo = dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value.ToString(); } else { infoStockPosting.VoucherNo = string.Empty; } if (dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value != null) { infoStockPosting.InvoiceNo = dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value.ToString(); } else { infoStockPosting.InvoiceNo = string.Empty; } if (decDeliveryNoteVoucherTypeId != 0) { infoStockPosting.AgainstVoucherTypeId = decDeliveryNoteVoucherTypeId; } else { infoStockPosting.AgainstVoucherTypeId = 0; } if (strVoucherNo != string.Empty) { infoStockPosting.AgainstVoucherNo = strVoucherNo; } else { infoStockPosting.AgainstVoucherNo = string.Empty; } if (txtDeliveryNoteNo.Text != string.Empty) { infoStockPosting.AgainstInvoiceNo = txtDeliveryNoteNo.Text; } else { infoStockPosting.AgainstInvoiceNo = string.Empty; } } } else { infoStockPosting.InvoiceNo = txtDeliveryNoteNo.Text; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decDeliveryNoteVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; } infoStockPosting.ProductId = infoDeliveryNoteDetails.ProductId; infoStockPosting.BatchId = infoDeliveryNoteDetails.BatchId; infoStockPosting.UnitId = infoDeliveryNoteDetails.UnitId; infoStockPosting.GodownId = infoDeliveryNoteDetails.GodownId; infoStockPosting.RackId = infoDeliveryNoteDetails.RackId; infoStockPosting.OutwardQty = infoDeliveryNoteDetails.Qty; infoStockPosting.Rate = infoDeliveryNoteDetails.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } Messages.SavedMessage(); if (cbxPrint.Checked) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDeliveryNoteMasterId); } else { Print(decDeliveryNoteMasterId); } } } if (btnSave.Text == "Update") { SettingsBll BllSettings = new SettingsBll(); infoDeliveryNoteMaster.DeliveryNoteMasterId = decDelivryNoteIdToEdit; infoDeliveryNoteMaster.SuffixPrefixId = Convert.ToDecimal(decDeliveryNoteSuffixPrefixId); infoDeliveryNoteMaster.VoucherNo = strVoucherNo; infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); if (cmbSalesMan.SelectedIndex != -1) { infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { infoDeliveryNoteMaster.EmployeeId = 0; } infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; if (cmbOrderNo.SelectedValue != null) { if (cmbDeliveryMode.Text == "Against Order") { infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesOrderMaster = bllSalesOrder.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesQuotationMaster = bllSalesQuotation.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId); } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } } else { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } infoDeliveryNoteMaster.Narration = txtNarration.Text.Trim(); infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text); infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text; infoDeliveryNoteMaster.LrNo = txtLRNo.Text; infoDeliveryNoteMaster.Extra1 = string.Empty; infoDeliveryNoteMaster.Extra2 = string.Empty; bllDeliveryNote.DeliveryNoteMasterEdit(infoDeliveryNoteMaster); RemoveDeliveryNoteDetails(); infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId; bllDeliveryNote.StockPostDeletingForDeliveryNote(decDeliveryNoteVoucherTypeId, strVoucherNo, txtDeliveryNoteNo.Text); DeliveryNoteDetails(); Messages.UpdatedMessage(); if (frmDeliveryNoteRegisterObj != null) { if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDelivryNoteIdToEdit); } else { Print(decDelivryNoteIdToEdit); } } frmDeliveryNoteRegisterObj.GridFill(); } if (frmDeliveryNoteReportObj != null) { if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDelivryNoteIdToEdit); } else { Print(decDelivryNoteIdToEdit); } } frmDeliveryNoteReportObj.GridFill(); } this.Close(); } Clear(); } catch (Exception ex) { MessageBox.Show("DN35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to use the voucherno Automatic generation /// </summary> public void VoucherNumberGeneration() { string strTableName = "SalesOrderMaster"; string strPrefix = string.Empty; string strSuffix = string.Empty; string strInvoiceNo = string.Empty; try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll(); if (isAutomatic) { strVoucherNo = "0"; if (strVoucherNo == string.Empty) { strVoucherNo = "0"; //strMax; } strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decSalesOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName); if (Convert.ToDecimal(strVoucherNo) != bllSalesOrder.SalesOrderVoucherMasterMaxPlusOne(decSalesOrderTypeId)) { strVoucherNo = bllSalesOrder.SalesOrderVoucherMasterMax(decSalesOrderTypeId).ToString(); strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decSalesOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName); if (bllSalesOrder.SalesOrderVoucherMasterMax(decSalesOrderTypeId).ToString() == "0") { strVoucherNo = "0"; strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decSalesOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName); } } if (isAutomatic) { SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decSalesOrderTypeId, dtpDate.Value); strPrefix = infoSuffixPrefix.Prefix; strSuffix = infoSuffixPrefix.Suffix; strInvoiceNo = strPrefix + strVoucherNo + strSuffix; txtOrderNo.Text = strInvoiceNo; txtOrderNo.ReadOnly = true; } else { txtOrderNo.ReadOnly = false; txtOrderNo.Text = string.Empty; strInvoiceNo = txtOrderNo.Text.Trim(); } } } catch (Exception ex) { MessageBox.Show("SO40:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grid fill function Againest SalseOrderDetails /// </summary> public void gridFillAgainestSalseOrderDetails() { BrandBll BllBrand = new BrandBll(); //SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); ProductInfo infoproduct = new ProductInfo(); //SalesMasterSP spSalesMaster = new SalesMasterSP(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); BrandInfo InfoBrand = new BrandInfo(); TaxInfo infoTax = new TaxInfo(); TaxBll bllTax = new TaxBll(); try { if (cmbSalesModeOrderNo.SelectedIndex > 0) { inMaxCount = 0; isValueChange = false; for (int i = 0; i < dgvSalesInvoice.RowCount - 1; i++) { if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != string.Empty) { lstArrOfRemove.Add(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString()); } } dgvSalesInvoice.Rows.Clear(); isValueChange = true; List<DataTable> ListObj= bllSalesOrder.SalesInvoiceGridfillAgainestSalesOrder(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString())); cmbPricingLevel.SelectedValue = Convert.ToDecimal(ListObj[0].Rows[0]["pricingLevelId"].ToString()); cmbCurrency.SelectedValue = Convert.ToDecimal(ListObj[0].Rows[0]["exchangeRateId"].ToString()); if (ListObj[0].Rows[0]["employeeId"].ToString() != string.Empty) { strSalesManId = ListObj[0].Rows[0]["employeeId"].ToString(); cmbSalesMan.SelectedValue = strSalesManId; if (cmbSalesMan.SelectedValue == null) { salesManComboFill(); cmbSalesMan.SelectedValue = ListObj[0].Rows[0]["employeeId"].ToString(); } } cmbPricingLevel.Enabled = false; btnNewPricingLevel.Enabled = false; cmbCurrency.Enabled = false; ListObj = bllSalesOrder.SalesInvoiceGridfillAgainestSalesOrderUsingSalesDetails(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()), Convert.ToDecimal(decSalesInvoiceIdToEdit), DecSalesInvoiceVoucherTypeId); int inRowIndex = 0; foreach (DataRow drowDetails in ListObj[0].Rows) { dgvSalesInvoice.Rows.Add(); isValueChange = false; IsSetGridValueChange = false; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSISalesOrderDetailsId"].Value = drowDetails["salesOrderDetailsId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductCode"].Value = drowDetails["productCode"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBarcode"].Value = drowDetails["barcode"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = drowDetails["voucherNo"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = drowDetails["invoiceNo"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value = "0"; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInRowIndex"].Value = drowDetails["salesOrderDetailsId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value = drowDetails.ItemArray[2].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = drowDetails["unitConversionId"].ToString(); infoproduct = BllSalesInvoice.ProductViewByProductIdforSalesInvoice(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductName"].Value = infoproduct.ProductName; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceMrp"].Value = infoproduct.Mrp; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = infoproduct.PurchaseRate; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceSalesRate"].Value = infoproduct.SalesRate; InfoBrand = BllBrand.BrandView(infoproduct.BrandId); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBrand"].Value = InfoBrand.BrandName; infoTax = bllTax.TaxViewByProductId(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceTaxName"].Value = infoTax.TaxId; isValueChange = false; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceQty"].Value = drowDetails["Qty"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceRate"].Value = drowDetails["rate"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceAmount"].Value = drowDetails["amount"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceConversionRate"].Value = drowDetails["conversionRate"].ToString(); isFromAgainest = true; gridColumnMakeEnables(); int intIndex = 0; intIndex = Convert.ToInt32(drowDetails["salesOrderDetailsId"].ToString()); if (inMaxCount < intIndex) inMaxCount = intIndex; inRowIndex++; isValueChange = true; isFromAgainest = false; GrossValueCalculation(dgvSalesInvoice.Rows.Count - 2); discountCalculation(dgvSalesInvoice.Rows.Count - 2); taxAndGridTotalAmountCalculation(dgvSalesInvoice.Rows.Count - 2); } IsSetGridValueChange = true; for (int i = inRowIndex; i < dgvSalesInvoice.Rows.Count; ++i) dgvSalesInvoice["dgvtxtSalesInvoiceInRowIndex", i].Value = GetNextinRowIndex().ToString(); SerialNoforSalesInvoice(); strVoucherNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString(); strInvoiceNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString(); decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value); } else { SiGridTotalAmountCalculation(); ClearGridAgainest(); } SiGridTotalAmountCalculation(); } catch (Exception ex) { MessageBox.Show("SI: 51" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to use the SaveItems to table /// </summary> public void SaveFunction() { try { decimal decSalesOrderSuffixPrefixId = 0; SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesOrderBll bllSalesOrderMaster = new SalesOrderBll(); infoSalesOrderMaster.Cancelled = false; infoSalesOrderMaster.Date = Convert.ToDateTime(txtDate.Text); infoSalesOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text); infoSalesOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); if (isAutomatic) { infoSalesOrderMaster.SuffixPrefixId = decSalesOrderSuffixPrefixId; infoSalesOrderMaster.VoucherNo = strVoucherNo; } else { infoSalesOrderMaster.SuffixPrefixId = 0; infoSalesOrderMaster.VoucherNo = bllSalesOrderMaster.VoucherNoMax(decSalesOrderTypeId); } infoSalesOrderMaster.VoucherTypeId = decSalesOrderTypeId; infoSalesOrderMaster.InvoiceNo = txtOrderNo.Text; infoSalesOrderMaster.UserId = PublicVariables._decCurrentUserId; if (cmbSalesMan.SelectedIndex == -1) { infoSalesOrderMaster.SalesOrderMasterId = 0; } else { infoSalesOrderMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } infoSalesOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; if (cmbPricingLevel.SelectedIndex == -1) { infoSalesOrderMaster.PricinglevelId = 0; } else { infoSalesOrderMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } infoSalesOrderMaster.Narration = txtNarration.Text.Trim(); if (cmbQuotationNo.SelectedIndex == -1) { infoSalesOrderMaster.QuotationMasterId = 0; } else { infoSalesOrderMaster.QuotationMasterId = Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString()); } infoSalesOrderMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoSalesOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoSalesOrderMaster.Extra1 = string.Empty; infoSalesOrderMaster.Extra2 = string.Empty; decSalesOrderMasterIdentity = Convert.ToDecimal(bllSalesOrderMaster.SalesOrderMasterAdd(infoSalesOrderMaster)); int inRowcount = dgvSalesOrder.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { infoSalesOrderDetails.SalesOrderMasterId = decSalesOrderMasterIdentity; if (dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != "") { infoProduct = new ProductCreationBll().ProductViewByCode(dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoSalesOrderDetails.ProductId = infoProduct.ProductId; } if (dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != "") { infoSalesOrderDetails.Qty = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); } if (dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != "") { infoSalesOrderDetails.UnitId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoSalesOrderDetails.UnitConversionId = decConversionId; } if (dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString() != "") { infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); } if (dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { infoSalesOrderDetails.BatchId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); } if (dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value == null || dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString() == "") { infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(0); } else { infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value); } infoSalesOrderDetails.Rate = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoSalesOrderDetails.Amount = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoSalesOrderDetails.SlNo = Convert.ToInt32(dgvSalesOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); infoSalesOrderDetails.Extra1 = string.Empty; infoSalesOrderDetails.Extra2 = string.Empty; bllSalesOrder.SalesOrderDetailsAdd(infoSalesOrderDetails); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked == true) { if (new SettingsBll().SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesOrderMasterIdentity); } else { Print(decSalesOrderMasterIdentity); } } Clear(); } catch (Exception ex) { MessageBox.Show("SO46:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to use the invalid entries checking for Save /// </summary> public void SaveOrEdit() { try { SettingsBll BllSettings = new SettingsBll(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); dgvSalesOrder.ClearSelection(); int inRow = dgvSalesOrder.RowCount; if (txtOrderNo.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter voucher number"); txtOrderNo.Focus(); } else if (bllSalesOrder.SalesOrderNumberCheckExistence(txtOrderNo.Text.Trim(), 0, decSalesOrderTypeId) == true && btnSave.Text == "Save") { Messages.InformationMessage("Order number already exist"); txtOrderNo.Focus(); } else if (txtDate.Text.Trim() == string.Empty) { Messages.InformationMessage("Select a date in between financial year"); txtDate.Focus(); } else if (cmbCashOrParty.SelectedValue == null) { Messages.InformationMessage("Select Cash/Party"); cmbCashOrParty.Focus(); } else if (cmbPricingLevel.SelectedValue == null) { Messages.InformationMessage("Select Pricing Level"); cmbPricingLevel.Focus(); } else if (cmbSalesMan.SelectedValue == null) { Messages.InformationMessage("Select SalesMan"); cmbSalesMan.Focus(); } else if (txtDueDate.Text.Trim() == string.Empty) { Messages.InformationMessage("Select due date"); txtDueDate.Focus(); } else if (txtDueDays.Text.Contains("-") && txtDueDays.Text != string.Empty) { Messages.InformationMessage("Due date should not be greater than order date"); txtDueDate.Focus(); } else if (inRow - 1 == 0) { Messages.InformationMessage("Can't save sales order without atleast one product with complete details"); } else if (RemoveIncompleteRowsFromGrid()) { if (dgvSalesOrder.Rows[0].Cells["dgvtxtProductName"].Value == null && dgvSalesOrder.Rows[0].Cells["dgvtxtProductCode"].Value == null) { MessageBox.Show("Can't save sales order without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalesOrder.ClearSelection(); dgvSalesOrder.Focus(); } else { if (btnSave.Text == "Save") { if (dgvSalesOrder.Rows[0].Cells["dgvtxtProductName"].Value == null || dgvSalesOrder.Rows[0].Cells["dgvtxtQty"].Value == null || dgvSalesOrder.Rows[0].Cells["dgvtxtAmount"].Value == null || dgvSalesOrder.Rows[0].Cells["dgvtxtRate"].Value == null) { MessageBox.Show("Can't save sales order without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalesOrder.ClearSelection(); dgvSalesOrder.Focus(); } else { if (PublicVariables.isMessageAdd) { if (Messages.SaveMessage()) { SaveFunction(); } } else { SaveFunction(); } } } if (btnSave.Text == "Update") { if (dgvSalesOrder.Rows[0].Cells["dgvtxtProductName"].Value == null || dgvSalesOrder.Rows[0].Cells["dgvtxtQty"].Value == null || dgvSalesOrder.Rows[0].Cells["dgvtxtAmount"].Value == null || dgvSalesOrder.Rows[0].Cells["dgvtxtRate"].Value == null) { MessageBox.Show("Can't edit sales order without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalesOrder.ClearSelection(); dgvSalesOrder.Focus(); } else { if (PublicVariables.isMessageEdit) { if (Messages.UpdateMessage()) { EditFunction(); } } else { EditFunction(); } } } } } } catch (Exception ex) { MessageBox.Show("SO50:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Editthe sales order details /// </summary> public void SalesOrderDetailsEditFill() { try { SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); //SalesOrderBll spSalesOrdermaster = new SalesOrderMasterSP(); for (int inI = 0; inI < dgvSalesOrder.Rows.Count - 1; inI++) { if (Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) == 0 || dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value == null) { infoSalesOrderDetails.SalesOrderMasterId = decSalesOrderMasterId; infoSalesOrderDetails.SalesOrderDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value); infoProduct = new ProductCreationBll().ProductViewByCode(dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoSalesOrderDetails.ProductId = infoProduct.ProductId; infoSalesOrderDetails.Qty = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value); infoSalesOrderDetails.UnitId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); infoSalesOrderDetails.BatchId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); infoSalesOrderDetails.Rate = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoSalesOrderDetails.Amount = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoSalesOrderDetails.SlNo = Convert.ToInt32(dgvSalesOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); if (dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString() != string.Empty) { infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString()); } else { infoSalesOrderMaster.QuotationMasterId = 0; } infoSalesOrderDetails.Extra1 = string.Empty; infoSalesOrderDetails.Extra2 = string.Empty; bllSalesOrder.SalesOrderDetailsAdd(infoSalesOrderDetails); } else { infoSalesOrderDetails.SalesOrderMasterId = decSalesOrderMasterId; infoSalesOrderDetails.SalesOrderDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value); infoProduct = new ProductCreationBll().ProductViewByCode(dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoSalesOrderDetails.ProductId = infoProduct.ProductId; infoSalesOrderDetails.Qty = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value); infoSalesOrderDetails.UnitId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); infoSalesOrderDetails.BatchId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); infoSalesOrderDetails.Rate = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoSalesOrderDetails.Amount = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoSalesOrderDetails.SlNo = Convert.ToInt32(dgvSalesOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); if (dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString() != string.Empty) { infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString()); } else { infoSalesOrderMaster.QuotationMasterId = 0; } infoSalesOrderDetails.Extra1 = string.Empty; infoSalesOrderDetails.Extra2 = string.Empty; bllSalesOrder.SalesOrderDetailsEdit(infoSalesOrderDetails); } } } catch (Exception ex) { MessageBox.Show("SO43:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to use the cancel the salesOrder /// </summary> public void SalesOrderCancel() { try { SalesOrderBll bllSalesOrderMaster = new SalesOrderBll(); bllSalesOrderMaster.SalesOrderCancel(decSalesOrderMasterId); Messages.InformationMessage("Cancelled successfully"); if (frmSalesOrderRegisterObj != null) { this.Close(); frmSalesOrderRegisterObj.GridFill(); } if (frmSalesOrderReportObj != null) { this.Close(); frmSalesOrderReportObj.GridFill(); } } catch (Exception ex) { MessageBox.Show("SO51:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Remove Product and details in editing mode /// </summary> public void RemoveSalesOrderDetails() { try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); foreach (var strId in lstArrOfRemove) { decimal decDeleteId = Convert.ToDecimal(strId); bllSalesOrder.SalesOrderDetailsDeletee(decDeleteId); } } catch (Exception ex) { MessageBox.Show("SO41:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void GridFill() { try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); if (txtVoucherNo.Text.Trim() == string.Empty) { strInvoiceNo = "-1"; } else { strInvoiceNo = txtVoucherNo.Text; } if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1) { decLedgerId = -1; } else { decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); } if (cmbVoucherType.SelectedIndex == 0 || cmbVoucherType.SelectedIndex == -1) { decVoucherTypeId = -1; } else { decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()); } if (cmbSalesMan.SelectedIndex == 0 || cmbSalesMan.SelectedIndex == -1) { decEmployeeId = -1; } else { decEmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } if (txtProductCode.Text.Trim() == string.Empty) { strProductCode = string.Empty; } else { strProductCode = txtProductCode.Text; } if (cmbArea.SelectedIndex == 0 || cmbArea.SelectedIndex == -1) { decAreaId = -1; } else { decAreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); } if (cmbRoute.SelectedIndex == 0 || cmbRoute.SelectedIndex == -1) { decRouteId = -1; } else { decRouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString()); } if (cmbProductGroup.SelectedIndex == 0 || cmbProductGroup.SelectedIndex == -1) { decGroupId = -1; } else { decGroupId = Convert.ToDecimal(cmbProductGroup.SelectedValue.ToString()); } if (cmbQuotationNo.SelectedIndex == 0) { strSalesQuotationNo = "-1"; } else { strSalesQuotationNo = cmbQuotationNo.SelectedValue.ToString(); } if (cmbStatus.SelectedIndex == 0 || cmbStatus.SelectedIndex == -1) { strStatus = "All"; } else { strStatus = cmbStatus.SelectedItem.ToString(); } DateTime FromDate = this.dtpFromDate.Value; DateTime ToDate = this.dtpToDate.Value; ListObjSOMaster = bllSalesOrder.SalesOrderReportViewAll(strInvoiceNo, decLedgerId, strProductCode, decVoucherTypeId, FromDate, ToDate, strStatus, decEmployeeId, strSalesQuotationNo, decAreaId, decGroupId, decRouteId); if (ListObjSOMaster[0].Rows.Count > 0) { decimal decTotal = 0; for (int i = 0; i < ListObjSOMaster[0].Rows.Count; i++) { if (ListObjSOMaster[0].Rows[i]["totalAmount"].ToString() != null) { decTotal = decTotal + Convert.ToDecimal(ListObjSOMaster[0].Rows[i]["totalAmount"].ToString()); } } decTotal = Math.Round(decTotal, 2); txtTotalAmount.Text = decTotal.ToString(); } else { txtTotalAmount.Text = "0.00"; } dgvSalesOrderReport.DataSource = ListObj[0]; if (dgvSalesOrderReport.Columns.Count > 0) { dgvSalesOrderReport.Columns["dgvtxtTotalAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } } catch (Exception ex) { MessageBox.Show("SORP9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the VoucherTypeCombobox /// </summary> public void VoucherTypeComboFill() { try { string typeOfVoucher = string.Empty; typeOfVoucher = "Sales Quotation"; List<DataTable> ListObj = new List<DataTable>(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); ListObj = bllSalesOrder.VoucherTypesBasedOnTypeOfVouchers(typeOfVoucher); DataRow dr = ListObj[0].NewRow(); dr["voucherTypeId"] = 0; dr["voucherTypeName"] = "NA"; ListObj[0].Rows.InsertAt(dr, 0); cmbType.DataSource = ListObj[0]; cmbType.ValueMember = "voucherTypeId"; cmbType.DisplayMember = "voucherTypeName"; } catch (Exception ex) { MessageBox.Show("SO7" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Against Sales order combofill function /// </summary> public void againstOrderComboFill() { try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); //DeliveryNoteMasterSP spDeliveryNoteMasterSp = new DeliveryNoteMasterSP(); DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll(); SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); List<DataTable> Listobj = new List<DataTable>(); if (cmbCashOrParty.SelectedValue != null) { if (cmbSalesMode.Text == "Against SalesOrder") { Listobj = bllSalesOrder.GetSalesOrderNoIncludePendingCorrespondingtoLedgerforSI(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()), decSalesInvoiceIdToEdit, Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString())); DataRow dr = Listobj[0].NewRow(); dr["invoiceNo"] = ""; dr["salesOrderMasterId"] = 0; Listobj[0].Rows.InsertAt(dr, 0); isFromEditMode = true; cmbSalesModeOrderNo.DataSource = Listobj[0]; cmbSalesModeOrderNo.ValueMember = "salesOrderMasterId"; cmbSalesModeOrderNo.DisplayMember = "invoiceNo"; isFromEditMode = false; } if (cmbSalesMode.Text == "Against Delivery Note") { List<DataTable> listObj = new List<DataTable>(); listObj = bllDeliveryNote.GetDeleveryNoteNoIncludePendingCorrespondingtoLedgerForSI(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()), decSalesInvoiceIdToEdit, Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString())); DataRow dr = listObj[0].NewRow(); dr["invoiceNo"] = ""; dr["deliveryNoteMasterId"] = 0; listObj[0].Rows.InsertAt(dr, 0); isFromEditMode = true; cmbSalesModeOrderNo.DataSource = listObj[0]; cmbSalesModeOrderNo.ValueMember = "deliveryNoteMasterId"; cmbSalesModeOrderNo.DisplayMember = "invoiceNo"; isFromEditMode = false; } if (cmbSalesMode.Text == "Against Quotation") { List<DataTable> listObj = new List<DataTable>(); listObj = bllSalesQuotation.GetSalesQuotationIncludePendingCorrespondingtoLedgerForSI(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()), decSalesInvoiceIdToEdit, Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString())); DataRow dr = listObj[0].NewRow(); dr["invoiceNo"] = ""; dr["quotationMasterId"] = 0; listObj[0].Rows.InsertAt(dr, 0); isFromEditMode = true; cmbSalesModeOrderNo.DataSource = listObj[0]; cmbSalesModeOrderNo.ValueMember = "quotationMasterId"; cmbSalesModeOrderNo.DisplayMember = "invoiceNo"; isFromEditMode = false; } } } catch (Exception ex) { MessageBox.Show("SI: 13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// doing the unit conversion in cell enter /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSalesOrder_CellEnter(object sender, DataGridViewCellEventArgs e) { SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); // decimal decQty =0; try { if (dgvSalesOrder.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewComboBoxCell) { dgvSalesOrder.EditMode = DataGridViewEditMode.EditOnEnter; } else { dgvSalesOrder.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; } if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value != null && dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { if (dgvSalesOrder.Columns[e.ColumnIndex].Name == "dgvcmbUnit") { if (dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtRate"].Value != null && dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty) { decCurrentConversionRate = Convert.ToDecimal(dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString()); } } } } if (dgvSalesOrder.CurrentRow.Cells["dgvtxtProductId"].Value != null) { if (dgvSalesOrder.CurrentRow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { BatchBll BllBatch = new BatchBll(); decimal decBatchId = Convert.ToDecimal(dgvSalesOrder.CurrentRow.Cells["dgvcmbBatch"].Value); string strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId); dgvSalesOrder.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = strBarcode; } } } CheckInvalidEntries(e); } catch (Exception ex) { MessageBox.Show("SO75" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void GridFill() { try { List<DataTable> ListObj = new List<DataTable>(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); if (cmbSalesOrderNo.SelectedIndex == 0 || cmbSalesOrderNo.SelectedIndex == -1) { strInvoiceNo = "All"; } else { strInvoiceNo = cmbSalesOrderNo.Text; } if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1) { decLedgerId = -1; } else { decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); } if (rbtnAll.Checked == true) { strCondition = "All"; } if (rbtnPendingOrder.Checked == true) { strCondition = "Pending"; } if (rbtnOverdue.Checked == true) { strCondition = "Due"; } if (rbtnCancelled.Checked == true) { strCondition = "Cancelled"; } DateTime FromDate = this.dtpFromDate.Value; DateTime ToDate = this.dtpToDate.Value; ListObj = bllSalesOrder.SalesOrderRegisterSearch(strInvoiceNo, decLedgerId, FromDate, ToDate, strCondition); dgvSalesOrderRegister.DataSource = ListObj[0]; if (dgvSalesOrderRegister.Columns.Count > 0) { dgvSalesOrderRegister.Columns["dgvtxtBillAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } } catch (Exception ex) { MessageBox.Show("SOREG2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// function to use Check Cancel Status /// </summary> /// <param name="decId"></param> /// <returns></returns> public bool CheckCancelStatus(decimal decId) { bool isCancelled = false; try { SalesOrderBll spSalesOrder = new SalesOrderBll(); isCancelled = spSalesOrder.SalesOrderCancelCheckStatus(decId); } catch (Exception ex) { MessageBox.Show("SO52:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isCancelled; }
/// <summary> /// To fill the details according to the DeliveryNote master Id from frmDeliveryNoteRegister and frmDeliveryNoteReport /// </summary> public void FillRegisterOrReport() { try { DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo(); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); //DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); //DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP(); DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesQuotationBll bllSalesQuotatin = new SalesQuotationBll(); dgvProduct.Rows.Clear(); isRegisterReportFill = true; btnSave.Text = "Update"; int inRowIndex = 0; btnDelete.Enabled = true; txtDeliveryNoteNo.ReadOnly = true; if (txtDeliveryNoteNo.ReadOnly == true) { txtDate.Focus(); } else { txtDeliveryNoteNo.Focus(); } infoDeliveryNoteMaster = bllDeliveryNote.DeliveryNoteMasterViewAllByMasterId(decDelivryNoteIdToEdit); txtDeliveryNoteNo.Text = infoDeliveryNoteMaster.InvoiceNo; strVoucherNo = infoDeliveryNoteMaster.VoucherNo.ToString(); decDeliveryNoteSuffixPrefixId = Convert.ToDecimal(infoDeliveryNoteMaster.SuffixPrefixId); decDeliveryNoteVoucherTypeId = Convert.ToDecimal(infoDeliveryNoteMaster.VoucherTypeId); isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDeliveryNoteVoucherTypeId); decDeliveryNoteTypeId = decDeliveryNoteVoucherTypeId; cmbCashOrParty.SelectedValue = infoDeliveryNoteMaster.LedgerId; txtDate.Text = infoDeliveryNoteMaster.Date.ToString("dd-MMM-yyyy"); cmbPricingLevel.SelectedValue = infoDeliveryNoteMaster.PricinglevelId; infoVoucherType = BllVoucherType.VoucherTypeView(decDeliveryNoteVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; if (infoDeliveryNoteMaster.OrderMasterId != 0) { cmbDeliveryMode.Text = "Against Order"; infoSalesOrderMaster = bllSalesOrder.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId); cmbType.SelectedValue = infoSalesOrderMaster.VoucherTypeId; AgainstOrderComboFill(); cmbOrderNo.SelectedValue = infoDeliveryNoteMaster.OrderMasterId; } else if (infoDeliveryNoteMaster.QuotationMasterId != 0) { cmbDeliveryMode.Text = "Against Quotation"; infoSalesQuotationMaster = bllSalesQuotatin.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId); cmbType.SelectedValue = infoSalesQuotationMaster.VoucherTypeId; AgainstQuotationComboFill(); cmbOrderNo.SelectedValue = infoDeliveryNoteMaster.QuotationMasterId; } CurrencyComboFill(); cmbSalesMan.SelectedValue = infoDeliveryNoteMaster.EmployeeId; cmbCurrency.SelectedValue = infoDeliveryNoteMaster.ExchangeRateId; txtTraspotationCompany.Text = infoDeliveryNoteMaster.TransportationCompany; txtNarration.Text = infoDeliveryNoteMaster.Narration; txtLRNo.Text = infoDeliveryNoteMaster.LrNo; txtTotalAmnt.Text = infoDeliveryNoteMaster.TotalAmount.ToString("00.00"); List<DataTable> listObjDetails = bllDeliveryNote.DeliveryNoteDetailsViewByDeliveryNoteMasterId(decDelivryNoteIdToEdit); foreach (DataRow drowDetails in listObjDetails[0].Rows) { dgvProduct.Rows.Add(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtDetailsId"].Value = drowDetails["deliveryNoteDetailsId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherNo"].Value = drowDetails["VoucherNo"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtInvoiceNo"].Value = drowDetails["OrderNoOrQuotationNo"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherTypeId"].Value = drowDetails["VoucherTypeId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = drowDetails["productCode"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].Value = drowDetails["productName"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["Col"].Value = drowDetails["slNo"].ToString(); if (Convert.ToDecimal(drowDetails["orderDetails1Id"].ToString()) == 0) { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = 0; } else { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = Convert.ToDecimal(drowDetails["orderDetails1Id"].ToString()); } if (Convert.ToDecimal(drowDetails["quotationDetails1Id"].ToString()) != 0) { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = Convert.ToDecimal(drowDetails["quotationDetails1Id"].ToString()); } BatchComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); UnitComboFill1(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); GridGodownComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(drowDetails["godownId"].ToString()); RackComboFill1(Convert.ToDecimal(drowDetails["godownId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString()); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtQty"].Value = drowDetails["qty"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value = drowDetails["rate"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = drowDetails["unitConversionId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = drowDetails["conversionRate"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtAmount"].Value = drowDetails["amount"].ToString(); if (cmbOrderNo.Visible == true) { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; } if (bllDeliveryNote.DeliveryNoteMasterReferenceCheckRejectionIn(decDelivryNoteIdToEdit)) { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; } dgvProduct.Rows[dgvProduct.Rows.Count - 2].HeaderCell.Value = ""; AmountCalculation("dgvtxtQty", inRowIndex); TotalAmountCalculation(); } if (!isAutomatic) { txtDeliveryNoteNo.ReadOnly = false; txtDeliveryNoteNo.Focus(); } isRegisterReportFill = false; isDoAfterGridFill = true; } catch (Exception ex) { MessageBox.Show("DN19: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete /// </summary> public void Delete() { try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); decimal decResult1 = 0; for (int inI = 0; inI < dgvSalesOrder.Rows.Count - 1; inI++) { if (Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) != 0) { decResult1 = bllSalesOrder.SalesOrderDetailsDeletee(Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value)); } } decimal decResult2 = bllSalesOrder.SalesOrderMasterDelete(decSalesOrderMasterId); if (decResult1 > 0 && decResult2 > 0) { Messages.DeletedMessage(); if (frmSalesOrderRegisterObj != null) { this.Close(); frmSalesOrderRegisterObj.Enabled = true; } if (frmSalesOrderReportObj != null) { this.Close(); frmSalesOrderReportObj.Enabled = true; } if (objVoucherSearch != null) { this.Close(); objVoucherSearch.Enabled = true; } if (frmDayBookObj != null) { this.Close(); } } else { Messages.ReferenceExistsMessage(); } } catch (Exception ex) { MessageBox.Show("SO53:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> ///to change the corresponding values in grid when cells changed /// </summary> private void dgvProduct_CellLeave(object sender, DataGridViewCellEventArgs e) { try { SalesQuotationBll bllQuotation = new SalesQuotationBll(); //DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll(); if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty") { decimal decCurrentQty = 0; decimal decOldQty = 0; if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString() != string.Empty) { if (decDelivryNoteIdToEdit != 0) { if (cmbOrderNo.SelectedIndex != 0) { if (cmbDeliveryMode.Text == "Against Order") { List<DataTable> ListObj = new SalesOrderBll().SalesOrderDetailsViewBySalesOrderMasterIdWithRemaining(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit); decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[0].Cells["dgvtxtQty"].Value.ToString()); decOldQty = Convert.ToDecimal(ListObj[0].Rows[0]["qty"].ToString()); } else if (cmbDeliveryMode.Text == "Against Quotation") { List<DataTable> ListQuotationDetails = bllQuotation.SalesQuotationDetailsViewByquotationMasterIdWithRemainingByNotInCurrDN(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit); if (ListQuotationDetails[0].Rows.Count >= 1) { decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[0].Cells["dgvtxtQty"].Value.ToString()); decOldQty = Convert.ToDecimal(ListQuotationDetails[0].Rows[0]["qty"].ToString()); } } if (bllDeliveryNote.DeliveryNoteMasterReferenceCheckRejectionIn(decDelivryNoteIdToEdit)) { List<DataTable> listObjRejectionInQty = new List<DataTable>(); listObjRejectionInQty = bllDeliveryNote.DeliveryNoteMasterReferenceCheckRejectionInQty(decDelivryNoteIdToEdit); decimal decRejectionInQty = decimal.Parse(listObjRejectionInQty[0].Rows[e.RowIndex]["qty"].ToString()); if (decimal.Parse(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()) > decimal.Parse(listObjRejectionInQty[0].Rows[e.RowIndex]["qty"].ToString())) { decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()); } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = Convert.ToDecimal(decRejectionInQty); } } if (bllDeliveryNote.DeliveryNoteCheckReferenceInSalesInvoice(decDelivryNoteIdToEdit)) { List<DataTable> listObjSalesInvoiceQty = new List<DataTable>(); listObjSalesInvoiceQty = bllDeliveryNote.DeliveryNoteMasterReferenceCheckSalesInvoiceQty(decDelivryNoteIdToEdit); decimal decSalesInvoiceQty = decimal.Parse(listObjSalesInvoiceQty[0].Rows[e.RowIndex]["qty"].ToString()); if (decimal.Parse(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()) > decimal.Parse(listObjSalesInvoiceQty[0].Rows[e.RowIndex]["qty"].ToString())) { decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()); } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = Convert.ToDecimal(decSalesInvoiceQty); } } } else { Messages.InformationMessage("Select OrderNo"); cmbOrderNo.Focus(); } } if (decDelivryNoteIdToEdit == 0) { if (Convert.ToInt32(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value) != 0) { if (cmbDeliveryMode.Text == "Against Quotation") { List<DataTable> ListObj = bllQuotation.SalesQuotationDetailsViewByquotationMasterIdWithRemainingByNotInCurrDN(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit); decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()); decOldQty = Convert.ToDecimal(ListObj[0].Rows[e.RowIndex]["qty"].ToString()); } else if (cmbDeliveryMode.Text == "Against Order") { List<DataTable> ListObj = new SalesOrderBll().SalesOrderDetailsViewBySalesOrderMasterIdWithRemaining(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit); decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()); decOldQty = Convert.ToDecimal(ListObj[0].Rows[e.RowIndex]["qty"].ToString()); } } } } } if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty) { UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> ListObj = new List<DataTable>(); ListObj = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString()); foreach (DataRow drUnitByProduct in ListObj[0].Rows) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); if (isDoAfterGridFill) { decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, 2); } } } } } } if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty") { AmountCalculation("dgvtxtQty", e.RowIndex); } if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate") { AmountCalculation("dgvtxtRate", e.RowIndex); } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtAmount") { TotalAmountCalculation(); } CheckInvalidEntries(e); } catch (Exception ex) { MessageBox.Show("DN70:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to use CashOrParty Combofill /// </summary> public void DueDays() { try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); txtDueDays.Text = bllSalesOrder.DueDays(dtpDate.Value, dtpDueDate.Value).ToString(); } catch (Exception ex) { MessageBox.Show("SO20:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To fill the grid according to the pending Sales order Invoice number /// </summary> public void FillOrderDetails() { decimal decOrderNo = 0; try { DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo(); //DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll(); decOrderNo = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); inMaxCount = 0; string strSalesManId; decimal DefaultRate = 0; dgvProduct.Rows.Clear(); List<DataTable> ListObj = new SalesOrderBll().SalesOrderMasterViewBySalesOrderMasterId(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString())); cmbPricingLevel.SelectedValue = ListObj[0].Rows[0]["pricingLevelId"].ToString(); if (ListObj[0].Rows[0]["employeeId"].ToString() != string.Empty) { strSalesManId = ListObj[0].Rows[0]["employeeId"].ToString(); cmbSalesMan.SelectedValue = strSalesManId; SalesManComboFill(); cmbSalesMan.SelectedValue = ListObj[0].Rows[0]["employeeId"].ToString(); } CurrencyComboFill(); cmbCurrency.SelectedValue = ListObj[0].Rows[0]["exchangeRateId"].ToString(); ListObj = new SalesOrderBll().SalesOrderDetailsViewBySalesOrderMasterIdWithRemaining(decOrderNo, 0); int inRowIndex = 0; isValueChange = false; isDoAfterGridFill = false; infoDeliveryNoteMaster = bllDeliveryNote.DeliveryNoteMasterViewAllByMasterId(decDelivryNoteIdToEdit); foreach (DataRow drowDetails in ListObj[0].Rows) { dgvProduct.Rows.Add(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = drowDetails["productCode"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].Value = drowDetails["productName"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtQty"].Value = drowDetails["qty"].ToString(); string ProductId = drowDetails.ItemArray[2].ToString(); UnitComboFill1(Convert.ToDecimal(ProductId), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); BatchComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value = drowDetails["rate"].ToString(); DefaultRate = Convert.ToDecimal(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value.ToString()); GridGodownComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(drowDetails["godownId"].ToString()); RackComboFill1(Convert.ToDecimal(drowDetails["godownId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ColumnIndex); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString()); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = drowDetails["salesOrderDetailsId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherNo"].Value = drowDetails["voucherNo"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtInvoiceNo"].Value = drowDetails["invoiceNo"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = drowDetails["unitConversionId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = drowDetails["conversionRate"].ToString(); if (cmbOrderNo.Visible == true) { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; } dgvProduct.Rows[dgvProduct.Rows.Count - 2].HeaderCell.Value = ""; AmountCalculation("dgvtxtQty", inRowIndex); int inIndex = 0; int.TryParse(drowDetails["extra1"].ToString(), out inIndex); if (inMaxCount < inIndex) inMaxCount = inIndex; inRowIndex++; isValueChange = true; } for (int i = inRowIndex; i < dgvProduct.Rows.Count; ++i) dgvProduct["inRowIndex", i].Value = GetNextinRowIndex().ToString(); SerialNo(); TotalAmountCalculation(); isDoAfterGridFill = true; } catch (Exception ex) { MessageBox.Show("DN27 :" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to use to fill details to updation when comes register or report /// </summary> public void FillRegisterOrReport() { try { SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); isValueChange = false; btnSave.Text = "Update"; btnDelete.Enabled = true; txtOrderNo.ReadOnly = true; infoSalesOrderMaster = bllSalesOrder.SalesOrderMasterView(decSalesOrderMasterId); txtOrderNo.Text = infoSalesOrderMaster.InvoiceNo; strVoucherNo = infoSalesOrderMaster.VoucherNo.ToString(); decSalesSuffixPrefixId = Convert.ToDecimal(infoSalesOrderMaster.SuffixPrefixId); decSalesVoucherId = Convert.ToDecimal(infoSalesOrderMaster.VoucherTypeId); isAutomatic = new VoucherTypeBll().CheckMethodOfVoucherNumbering(decSalesVoucherId); decSalesOrderTypeId = decSalesVoucherId; txtDate.Text = infoSalesOrderMaster.Date.ToString("dd-MMM-yyyy"); cmbCashOrParty.SelectedValue = infoSalesOrderMaster.LedgerId; decSalesOrderVoucherTypeId = infoSalesOrderMaster.VoucherTypeId; VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); infoVoucherType = BllVoucherType.VoucherTypeView(decSalesOrderVoucherTypeId); string strVoucherTypeName = infoVoucherType.VoucherTypeName; this.Text = strVoucherTypeName; if (infoSalesOrderMaster.QuotationMasterId == 0) { cmbType.SelectedItem = "NA"; } else if (infoSalesOrderMaster.QuotationMasterId != 0) { infoSalesQuotationMaster = new SalesQuotationBll().SalesQuotationMasterView(infoSalesOrderMaster.QuotationMasterId); cmbType.SelectedValue = infoSalesQuotationMaster.VoucherTypeId; AgainstQuotationComboFill(); cmbQuotationNo.SelectedValue = infoSalesOrderMaster.QuotationMasterId; } txtDueDate.Text = infoSalesOrderMaster.DueDate.ToString("dd-MMM-yyyy"); TimeSpan objTs = Convert.ToDateTime(txtDueDate.Text).Subtract(Convert.ToDateTime(txtDate.Text)); txtDueDays.Text = objTs.Days.ToString(); txtNarration.Text = infoSalesOrderMaster.Narration; cmbCurrency.SelectedValue = infoSalesOrderMaster.ExchangeRateId; cmbPricingLevel.SelectedValue = infoSalesOrderMaster.PricinglevelId; SalesManComboFill(); cmbSalesMan.SelectedValue = infoSalesOrderMaster.EmployeeId; txtTotalAmount.Text = infoSalesOrderMaster.TotalAmount.ToString(); List<DataTable> ListObj = new List<DataTable>(); ListObj = bllSalesOrder.SalesOrderDetailsViewByMasterId(decSalesOrderMasterId); if (CheckCancelStatus(decSalesOrderMasterId)) { isCheck = true; cbxCancelled.Checked = true; cbxCancelled.Enabled = false; btnSave.Enabled = false; isCheck = false; } else { isCheck = true; cbxCancelled.Enabled = true; cbxCancelled.Checked = false; isCheck = false; } if (isAutomatic) { txtOrderNo.ReadOnly = true; txtDate.Focus(); } else { txtOrderNo.ReadOnly = false; txtOrderNo.Focus(); } for (int i = 0; i < ListObj[0].Rows.Count; i++) { isAmountcalc = false; isValueChange = false; dgvSalesOrder.Rows.Add(); dgvSalesOrder.Rows[i].HeaderCell.Value = string.Empty; dgvSalesOrder.Rows[i].Cells["dgvtxtSalesOrderDetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["salesOrderDetailsId"].ToString()); dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value = ListObj[0].Rows[i]["productId"].ToString(); dgvSalesOrder.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString(); dgvSalesOrder.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString(); dgvSalesOrder.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString(); UnitComboFill(Convert.ToDecimal(dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value.ToString()), i, dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString()); dgvSalesOrder.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString(); BatchComboFill(Convert.ToDecimal(dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value.ToString()), i, dgvSalesOrder.Rows[i].Cells["dgvcmbBatch"].ColumnIndex); dgvSalesOrder.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString()); dgvSalesOrder.Rows[i].Cells["dgvtxtBarcode"].Value = ListObj[0].Rows[i]["barcode"].ToString(); dgvSalesOrder.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString(); dgvSalesOrder.Rows[i].Cells["dgvtxtUnitConversionId"].Value = ListObj[0].Rows[i]["unitConversionId"].ToString(); dgvSalesOrder.Rows[i].Cells["dgvtxtConversionRate"].Value = ListObj[0].Rows[i]["conversionRate"].ToString(); dgvSalesOrder.Rows[i].Cells["dgvtxtSalesQuotationDetailsId"].Value = ListObj[0].Rows[i]["quotationDetailsId"].ToString(); if (Convert.ToDecimal(ListObj[0].Rows[i]["quotationDetailsId"].ToString()) != 0) { dgvSalesOrder.Rows[i].Cells["dgvtxtProductCode"].ReadOnly = true; dgvSalesOrder.Rows[i].Cells["dgvtxtProductName"].ReadOnly = true; dgvSalesOrder.Rows[i].Cells["dgvtxtBarcode"].ReadOnly = true; } if (cmbQuotationNo.Visible == true) { dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true; } } isAmountcalc = true; isEditFill = false; isValueChange = true; isDoAfterGridFill = true; } catch (Exception ex) { MessageBox.Show("SO30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }