/// <summary> /// Function to call this form from frmFeeProcessing /// </summary> /// <param name="frmAccountledger"></param> public void CallFromLedgerPopup(decimal ledgerId, frmLedgerPopup frm) { try { base.Show(); frmLedgerPopupObj = frm; FeeProcessingSP spFeeProcessing = new FeeProcessingSP(); AccountLedgerInfo ledgerInfo = new AccountLedgerInfo(); ledgerInfo = spFeeProcessing.AccountLedgerViewFilter(ledgerId); txtFirstName.Text = ledgerInfo.LedgerName; txtLastName.Text = ledgerInfo.OtherName; txtAdminNumber.Text = ledgerInfo.AdminNumber; txtClassNo.Text = ledgerInfo.Extra1; txtHomeEmail.Text = ledgerInfo.Email; txtHomePhone.Text = ledgerInfo.HomePhone; txtOpeningBalance.Text = Convert.ToString(ledgerInfo.OpeningBalance); ledgerID = ledgerId; classId = ledgerInfo.ClassNo; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
///<summary> ///Function to update values to tblAccountLedger /// </summary> public void AccountLedgerUpdate(AccountLedgerInfo accountLedgerInfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } MySqlCommand sqlcmd = new MySqlCommand("AccountLedgerUpdate", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; MySqlParameter sqlparam = new MySqlParameter(); sqlparam = sqlcmd.Parameters.Add("?ledgerId", MySqlDbType.VarChar); sqlparam.Value = accountLedgerInfo.LedgerId; sqlparam = sqlcmd.Parameters.Add("?ledgerName", MySqlDbType.VarChar); sqlparam.Value = accountLedgerInfo.LedgerName; sqlparam = sqlcmd.Parameters.Add("?accountGroupId", MySqlDbType.Decimal); sqlparam.Value = accountLedgerInfo.AccountGroupId; sqlparam = sqlcmd.Parameters.Add("?openingBalance", MySqlDbType.Decimal); sqlparam.Value = accountLedgerInfo.OpeningBalance; sqlparam = sqlcmd.Parameters.Add("?crOrDr", MySqlDbType.VarChar); sqlparam.Value = accountLedgerInfo.CrOrDr; sqlparam = sqlcmd.Parameters.Add("?active", MySqlDbType.Bit); sqlparam.Value = accountLedgerInfo.Active; sqlcmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlcon.Close(); } }
public void SaveFunction() { try { AccountLedgerInfo studentInfo = new AccountLedgerInfo(); StudentSP spStudent = new StudentSP(); for (int i = 0; i < dgvPromotion.RowCount; i++) { DataGridViewCheckBoxCell chkchecking = dgvPromotion.Rows[i].Cells["dgv_promoted"] as DataGridViewCheckBoxCell; if (dgvPromotion.Rows[i].Cells["dgvtxtStudentId"].Value.ToString() != string.Empty && dgvPromotion.Rows[i].Cells["dgvtxtStudentId"].Value != null) { studentInfo.LedgerId = Convert.ToInt32(dgvPromotion.Rows[i].Cells["dgvtxtStudentId"].Value.ToString()); } if (Convert.ToInt32(chkchecking.Value) >= 1) { spStudent.PromotedStudentAdd(studentInfo); Messages.SavedMessage(); } } } catch (Exception ex) { MessageBox.Show(" SaveFunction " + ex.Message); } }
public void FillControls() { try { AccountLedgerSP spAccountLedger = new AccountLedgerSP(); AccountLedgerInfo accountLedgerInfo = new AccountLedgerInfo(); accountLedgerInfo = spAccountLedger.AccountLedgerViewOne(ledgerId); txtLedgerName.Text = accountLedgerInfo.LedgerName; cmbGroup.SelectedValue = accountLedgerInfo.AccountGroupId; txtOpeningBalance.Text = Convert.ToString(accountLedgerInfo.OpeningBalance); cmbOpeningBalanceCrOrDr.Text = accountLedgerInfo.CrOrDr; if (accountLedgerInfo.Active) { chkactive.Checked = true; } else { chkactive.Checked = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SaveOrEdit() { try { if (txtLedgerName.Text == string.Empty) { MessageBox.Show("Enter a ledger name"); } else if (cmbGroup.SelectedIndex == -1) { MessageBox.Show("Select an accountGroup"); } else { AccountLedgerInfo accountLedgerInfo = new AccountLedgerInfo(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); accountLedgerInfo.LedgerName = txtLedgerName.Text.Trim(); accountLedgerInfo.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString()); accountLedgerInfo.CrOrDr = cmbOpeningBalanceCrOrDr.Text; accountLedgerInfo.OpeningBalance = Convert.ToDecimal(txtOpeningBalance.Text.Trim()); if (chkactive.Checked) { accountLedgerInfo.Active = true; } else { accountLedgerInfo.Active = false; } if (btnSave.Text == "Save") { if (Messages.SaveConfirmation()) { spAccountLedger.AccountLedgerAdd(accountLedgerInfo); ClearFunction(); Messages.SavedMessage(); } } else { if (Messages.UpdateMessage()) { accountLedgerInfo.LedgerId = ledgerId; spAccountLedger.AccountLedgerUpdate(accountLedgerInfo); ClearFunction(); Messages.UpdatedMessage(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Function to fill the values in curresponding controls for updation /// </summary> public void FillControls() { try { AccountLedgerInfo student = new AccountLedgerInfo(); StudentSP studentSP = new StudentSP(); student = studentSP.StudentView(studentId); if (student.Active) { cbxActive.Checked = true; } else { cbxActive.Checked = false; } txtFirstName.Text = student.LedgerName; txtLastName.Text = student.OtherName; txtDateOfBirth.Text = student.DateOfBirth.ToString("dd-MMM-yyyy"); txtPhone.Text = student.HomePhone; txtEmail.Text = student.Email; txtAdmision.Text = student.AdminNumber; cboLevel.SelectedValue = student.ClassNo; txtDateJoined.Text = student.DateJoined.ToString("dd-MMM-yyyy"); cboGender.SelectedItem = student.Gender; txtOpeningBalance.Text = Convert.ToString(student.OpeningBalance); cmbDrorCr.SelectedItem = student.CrOrDr; if (student.Photo != string.Empty && student.Photo != null) { photoPath = student.Photo; pictureBox.Image = Image.FromFile(photoPath); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; } else { pictureBox.Image = null; } txtGuardianName.Text = student.GuardianName; txtGuardianEmail.Text = student.GuardianEmail; txtRelatioship.Text = student.GuardianRelationship; txtGuardianPhone.Text = student.GuardianPhone; } catch (Exception ex) { MessageBox.Show("FillControlMthd " + ex.Message); } }
/// <summary> /// Function to get particular values from tblStudents table based on the parameter /// </summary> /// <param name="studentId"></param> /// <returns></returns> public AccountLedgerInfo StudentView(decimal ledgerId) { AccountLedgerInfo studentinfo = new AccountLedgerInfo(); MySqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } string sql = "SELECT * FROM tblaccountLedger WHERE (ledgerId=@_ledgerId);"; MySqlCommand sccmd = new MySqlCommand(sql, sqlcon); MySqlParameter sprmparam = new MySqlParameter(); sprmparam = sccmd.Parameters.Add("?_ledgerId", MySqlDbType.Int32); sprmparam.Value = ledgerId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { studentinfo.LedgerName = sdrreader["ledgerName"].ToString(); studentinfo.OtherName = sdrreader["otherName"].ToString(); studentinfo.DateOfBirth = DateTime.Parse(sdrreader["dateOfBirth"].ToString()); studentinfo.Active = bool.Parse(sdrreader["active"].ToString()); studentinfo.Photo = sdrreader["photo"].ToString(); studentinfo.AdminNumber = sdrreader["adminNumber"].ToString(); studentinfo.DateJoined = DateTime.Parse(sdrreader["dateJoined"].ToString()); studentinfo.Email = sdrreader["email"].ToString(); studentinfo.HomePhone = sdrreader["homePhone"].ToString(); studentinfo.Gender = sdrreader["gender"].ToString(); studentinfo.GuardianEmail = sdrreader["guardianEmail"].ToString(); studentinfo.GuardianName = sdrreader["guardianName"].ToString(); studentinfo.GuardianRelationship = sdrreader["guardianRelationship"].ToString(); studentinfo.GuardianPhone = sdrreader["guardianPhone"].ToString(); studentinfo.ClassNo = Int32.Parse(sdrreader["classNo"].ToString()); studentinfo.OpeningBalance = Convert.ToDecimal(sdrreader["openingBalance"].ToString()); studentinfo.CrOrDr = sdrreader["crOrDr"].ToString(); } } catch (Exception ex) { MessageBox.Show(" " + ex.Message); } finally { sdrreader.Close(); sqlcon.Close(); } return(studentinfo); }
public void AccountLedgerEditForCustomer(AccountLedgerInfo accountledgerinfo) { try { spAccountLedger.AccountLedgerEditForCustomer(accountledgerinfo); } catch (Exception ex) { MessageBox.Show("AL21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void AccountLedgerEditForSalesman(AccountLedgerInfo infoAccountLedger) { try { spAccountLedger.AccountLedgerEditForSalesman(infoAccountLedger); } catch (Exception ex) { MessageBox.Show("AL32:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public AccountLedgerInfo AccountLedgerViewForCustomer(decimal decLedgerId) { AccountLedgerInfo infoAccountledger = new AccountLedgerInfo(); try { infoAccountledger = spAccountLedger.AccountLedgerViewForCustomer(decLedgerId); } catch (Exception ex) { MessageBox.Show("AL15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(infoAccountledger); }
/// <summary> /// /// </summary> /// <param name="infoAccountLedger"></param> /// <returns></returns> public decimal AccountLedgerAddWithIdentity(AccountLedgerInfo infoAccountLedger) { decimal decLedgerId = 0; try { decLedgerId = spAccountLedger.AccountLedgerAddWithIdentity(infoAccountLedger); } catch (Exception ex) { MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decLedgerId); }
public AccountLedgerInfo accountLedgerviewbyId(decimal decledgerId) { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); try { infoAccountLedger = spAccountLedger.accountLedgerviewbyId(decledgerId); } catch (Exception ex) { MessageBox.Show("AL38:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(infoAccountLedger); }
///<summary> ///Function to fill the /// </summary> public AccountLedgerInfo AccountLedgerViewFilter(decimal ledgerId) { AccountLedgerInfo ledgerInfo = new AccountLedgerInfo(); MySqlDataReader sqlreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } MySqlCommand sqlcmd = new MySqlCommand("AccountLedgerViewFilter", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; MySqlParameter sqlparam = new MySqlParameter(); sqlparam = sqlcmd.Parameters.Add("?ledgerId", MySqlDbType.Int32); sqlparam.Value = ledgerId; sqlreader = sqlcmd.ExecuteReader(); while (sqlreader.Read()) { ledgerInfo.LedgerName = sqlreader["ledgerName"].ToString(); ledgerInfo.OtherName = sqlreader["otherName"].ToString(); ledgerInfo.AdminNumber = sqlreader["adminNumber"].ToString(); ledgerInfo.Extra1 = sqlreader["classNo"].ToString(); ledgerInfo.ClassNo = Convert.ToInt32(sqlreader["classNo"].ToString()); ledgerInfo.HomePhone = sqlreader["homePhone"].ToString(); ledgerInfo.Email = sqlreader["email"].ToString(); ledgerInfo.OpeningBalance = Convert.ToDecimal(sqlreader["openingBalance"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlreader.Close(); sqlcon.Close(); } return(ledgerInfo); }
///<summary> ///Function to get values from tblAccountLedger based on parameter ///<param name="ledgerId" ></param> /// </summary> public AccountLedgerInfo AccountLedgerViewOne(decimal ledgerId) { AccountLedgerInfo accountLedgerInfo = new AccountLedgerInfo(); MySqlDataReader sqlreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } MySqlCommand sqlcmd = new MySqlCommand("AccountLedgerViewOne", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; MySqlParameter sqlparam = new MySqlParameter(); sqlparam = sqlcmd.Parameters.Add("?ledgerId", MySqlDbType.Int32); sqlparam.Value = ledgerId; sqlreader = sqlcmd.ExecuteReader(); while (sqlreader.Read()) { accountLedgerInfo.LedgerName = sqlreader["ledgerName"].ToString(); accountLedgerInfo.OpeningBalance = Convert.ToDecimal(sqlreader["openingBalance"].ToString()); accountLedgerInfo.CrOrDr = sqlreader["crOrDr"].ToString(); accountLedgerInfo.AccountGroupId = Convert.ToDecimal(sqlreader["accountGroupId"].ToString()); accountLedgerInfo.Active = bool.Parse(sqlreader["active"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlreader.Close(); sqlcon.Close(); } return(accountLedgerInfo); }
/// <summary> /// Function to insert values to tblstudents /// </summary> /// <param name="Studentinfo"></param> public void PromotedStudentAdd(AccountLedgerInfo Studentinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } MySqlCommand sccmd = new MySqlCommand("PromoteStudent", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; MySqlParameter sprmparam = new MySqlParameter(); sprmparam = sccmd.Parameters.Add("?ledgerId", MySqlDbType.Int32); sprmparam.Value = Studentinfo.LedgerId; //sprmparam = sccmd.Parameters.Add("?ledgerName", MySqlDbType.VarChar); //sprmparam.Value = Studentinfo.LedgerName; // sprmparam = sccmd.Parameters.Add("?adminNumber", MySqlDbType.VarChar); // sprmparam.Value = Studentinfo.AdminNumber; // sprmparam = sccmd.Parameters.Add("?classNo", MySqlDbType.Int32); // sprmparam.Value = Studentinfo.ClassNo; // sprmparam = sccmd.Parameters.Add("?isPromoted", MySqlDbType.Bit); // sprmparam.Value = Studentinfo.IsPromoted; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlcon.Close(); } }
/// <summary> /// Cash or party combo changed, call the order combofill function and fill the basic functions /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbCashOrParty_SelectedIndexChanged(object sender, EventArgs e) { try { GetSalesDetailsIdToDelete(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo InfoAccountLedger = new AccountLedgerInfo(); if (isFromEditMode == false) { if (cmbCashOrParty.Text != string.Empty) { if (cmbCashOrParty.SelectedValue.ToString() != "System.Data.DataRowView" && cmbCashOrParty.Text != "System.Data.DataRowView") { InfoAccountLedger = bllAccountLedger.accountLedgerviewbyId(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString())); txtCustomer.Text = InfoAccountLedger.LedgerName; cmbPricingLevel.SelectedValue = InfoAccountLedger.PricinglevelId == 0 ? 1 : InfoAccountLedger.PricinglevelId; if (InfoAccountLedger.PricinglevelId == 0) { cmbPricingLevel.SelectedIndex = 0; } txtCreditPeriod.Text = InfoAccountLedger.CreditPeriod.ToString(); } } } else if (cmbSalesMode.SelectedIndex != 0) { Clear(); } againstOrderComboFill(); } catch (Exception ex) { MessageBox.Show("SI: 98" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print function for dotmatrix printer /// </summary> /// <param name="decSalesMasterId"></param> public void PrintForDotMatrix(decimal decSalesMasterId) { try { DataTable dtblOtherDetails = new DataTable(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); dtblOtherDetails = bllCompanyCreation.CompanyViewForDotMatrix(); DataTable dtblGridDetails = new DataTable(); dtblGridDetails.Columns.Add("SlNo"); dtblGridDetails.Columns.Add("BarCode"); dtblGridDetails.Columns.Add("ProductCode"); dtblGridDetails.Columns.Add("ProductName"); dtblGridDetails.Columns.Add("Qty"); dtblGridDetails.Columns.Add("Unit"); dtblGridDetails.Columns.Add("Godown"); dtblGridDetails.Columns.Add("Brand"); dtblGridDetails.Columns.Add("Tax"); dtblGridDetails.Columns.Add("TaxAmount"); dtblGridDetails.Columns.Add("NetAmount"); dtblGridDetails.Columns.Add("DiscountAmount"); dtblGridDetails.Columns.Add("DiscountPercentage"); dtblGridDetails.Columns.Add("SalesRate"); dtblGridDetails.Columns.Add("PurchaseRate"); dtblGridDetails.Columns.Add("MRP"); dtblGridDetails.Columns.Add("Rack"); dtblGridDetails.Columns.Add("Batch"); dtblGridDetails.Columns.Add("Rate"); dtblGridDetails.Columns.Add("Amount"); int inRowCount = 0; foreach (DataGridViewRow dRow in dgvSalesInvoice.Rows) { if (!dRow.IsNewRow) { DataRow dr = dtblGridDetails.NewRow(); dr["SlNo"] = ++inRowCount; if (dRow.Cells["dgvtxtSalesInvoiceBarcode"].Value != null) { dr["BarCode"] = dRow.Cells["dgvtxtSalesInvoiceBarcode"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceProductCode"].Value != null) { dr["ProductCode"] = dRow.Cells["dgvtxtSalesInvoiceProductCode"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceProductName"].Value != null) { dr["ProductName"] = dRow.Cells["dgvtxtSalesInvoiceProductName"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceQty"].Value != null) { dr["Qty"] = dRow.Cells["dgvtxtSalesInvoiceQty"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoicembUnitName"].Value != null) { dr["Unit"] = dRow.Cells["dgvtxtSalesInvoicembUnitName"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceGodown"].Value != null) { dr["Godown"] = dRow.Cells["dgvcmbSalesInvoiceGodown"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceRack"].Value != null) { dr["Rack"] = dRow.Cells["dgvcmbSalesInvoiceRack"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceBatch"].Value != null) { dr["Batch"] = dRow.Cells["dgvcmbSalesInvoiceBatch"].FormattedValue.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceRate"].Value != null) { dr["Rate"] = dRow.Cells["dgvtxtSalesInvoiceRate"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceAmount"].Value != null) { dr["Amount"] = dRow.Cells["dgvtxtSalesInvoiceAmount"].Value.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceTaxName"].Value != null) { dr["Tax"] = dRow.Cells["dgvcmbSalesInvoiceTaxName"].FormattedValue.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceBrand"].Value != null) { dr["Brand"] = dRow.Cells["dgvtxtSalesInvoiceBrand"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceTaxAmount"].Value != null) { dr["TaxAmount"] = dRow.Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceNetAmount"].Value != null) { dr["NetAmount"] = dRow.Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceDiscountAmount"].Value != null) { dr["DiscountAmount"] = dRow.Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value != null) { dr["DiscountPercentage"] = dRow.Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceSalesRate"].Value != null) { dr["SalesRate"] = dRow.Cells["dgvtxtSalesInvoiceSalesRate"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoicePurchaseRate"].Value != null) { dr["PurchaseRate"] = dRow.Cells["dgvtxtSalesInvoicePurchaseRate"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceMrp"].Value != null) { dr["MRP"] = dRow.Cells["dgvtxtSalesInvoiceMrp"].Value.ToString(); } dtblGridDetails.Rows.Add(dr); } } dtblOtherDetails.Columns.Add("voucherNo"); dtblOtherDetails.Columns.Add("date"); dtblOtherDetails.Columns.Add("ledgerName"); dtblOtherDetails.Columns.Add("SalesMode"); dtblOtherDetails.Columns.Add("SalesAccount"); dtblOtherDetails.Columns.Add("SalesMan"); dtblOtherDetails.Columns.Add("CreditPeriod"); dtblOtherDetails.Columns.Add("VoucherType"); dtblOtherDetails.Columns.Add("PricingLevel"); dtblOtherDetails.Columns.Add("Customer"); dtblOtherDetails.Columns.Add("CustomerAddress"); dtblOtherDetails.Columns.Add("CustomerTIN"); dtblOtherDetails.Columns.Add("CustomerCST"); dtblOtherDetails.Columns.Add("Narration"); dtblOtherDetails.Columns.Add("Currency"); dtblOtherDetails.Columns.Add("TotalAmount"); dtblOtherDetails.Columns.Add("BillDiscount"); dtblOtherDetails.Columns.Add("GrandTotal"); dtblOtherDetails.Columns.Add("AmountInWords"); dtblOtherDetails.Columns.Add("Declaration"); dtblOtherDetails.Columns.Add("Heading1"); dtblOtherDetails.Columns.Add("Heading2"); dtblOtherDetails.Columns.Add("Heading3"); dtblOtherDetails.Columns.Add("Heading4"); DataRow dRowOther = dtblOtherDetails.Rows[0]; dRowOther["voucherNo"] = txtInvoiceNo.Text; dRowOther["date"] = txtDate.Text; dRowOther["ledgerName"] = cmbCashOrParty.Text; dRowOther["Narration"] = txtNarration.Text; dRowOther["Currency"] = cmbCurrency.Text; dRowOther["SalesMode"] = cmbSalesMode.Text; dRowOther["SalesAccount"] = cmbSalesAccount.Text; dRowOther["SalesMan"] = cmbSalesMan.SelectedText; dRowOther["CreditPeriod"] = (txtCreditPeriod.Text) + " Days"; dRowOther["PricingLevel"] = cmbPricingLevel.Text; dRowOther["Customer"] = txtCustomer.Text; dRowOther["BillDiscount"] = txtBillDiscount.Text; dRowOther["GrandTotal"] = txtGrandTotal.Text; dRowOther["TotalAmount"] = txtTotalAmount.Text; dRowOther["VoucherType"] = cmbVoucherType.Text; dRowOther["address"] = (dtblOtherDetails.Rows[0]["address"].ToString().Replace("\n", ", ")).Replace("\r", ""); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); infoAccountLedger = bllAccountLedger.AccountLedgerView(Convert.ToDecimal(cmbCashOrParty.SelectedValue)); dRowOther["CustomerAddress"] = (infoAccountLedger.Address.ToString().Replace("\n", ", ")).Replace("\r", ""); dRowOther["CustomerTIN"] = infoAccountLedger.Tin; dRowOther["CustomerCST"] = infoAccountLedger.Cst; dRowOther["AmountInWords"] = new NumToText().AmountWords(Convert.ToDecimal(txtGrandTotal.Text), PublicVariables._decCurrencyId); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); DataTable dtblDeclaration = BllVoucherType.DeclarationAndHeadingGetByVoucherTypeId(DecSalesInvoiceVoucherTypeId); dRowOther["Declaration"] = dtblDeclaration.Rows[0]["Declaration"].ToString(); dRowOther["Heading1"] = dtblDeclaration.Rows[0]["Heading1"].ToString(); dRowOther["Heading2"] = dtblDeclaration.Rows[0]["Heading2"].ToString(); dRowOther["Heading3"] = dtblDeclaration.Rows[0]["Heading3"].ToString(); dRowOther["Heading4"] = dtblDeclaration.Rows[0]["Heading4"].ToString(); int inFormId = BllVoucherType.FormIdGetForPrinterSettings(Convert.ToInt32(dtblDeclaration.Rows[0]["masterId"].ToString())); PrintWorks.DotMatrixPrint.PrintDesign(inFormId, dtblOtherDetails, dtblGridDetails, dtblOtherDetails); } catch (Exception ex) { MessageBox.Show("SI: 74" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// editing the ledger on update /// </summary> public void LedgerEdit() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.LedgerId = decLedgerId; infoAccountLedger.AccountGroupId = 20; infoAccountLedger.LedgerName = txtTaxName.Text; infoAccountLedger.OpeningBalance = 0; infoAccountLedger.IsDefault = false; infoAccountLedger.CrOrDr = "Cr"; infoAccountLedger.Narration = string.Empty; infoAccountLedger.MailingName = txtTaxName.Text; infoAccountLedger.Address = string.Empty; infoAccountLedger.Phone = string.Empty; infoAccountLedger.Mobile = string.Empty; infoAccountLedger.Email = string.Empty; infoAccountLedger.CreditPeriod = 0; infoAccountLedger.CreditLimit = 0; infoAccountLedger.PricinglevelId = 0; infoAccountLedger.BillByBill = false; infoAccountLedger.Tin = string.Empty; infoAccountLedger.Cst = string.Empty; infoAccountLedger.Pan = string.Empty; infoAccountLedger.RouteId = 1; infoAccountLedger.BankAccountNumber = string.Empty; infoAccountLedger.BranchCode = string.Empty; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.ExtraDate = DateTime.Now; infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.AreaId = 1; bllAccountLedger.AccountLedgerEdit(infoAccountLedger); } catch(Exception ex) { MessageBox.Show("TAX:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to update values to tblstudents /// </summary> /// <param name="Studentinfo"></param> public void StudentEdit(AccountLedgerInfo Studentinfo, decimal studentId) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } string sql = "UPDATE tblaccountLedger SET ledgerName=@firstName,otherName=@lastName,openingBalance=@openingBalance,crOrDr=@crOrDr,dateOfBirth=@dateOfBirth,active=@active,photo=@photo,adminNumber=@adminNumber,dateJoined=@dateJoined,email=@email,homePhone=@homePhone,guardianEmail=@guardianEmail,guardianName=@guardianName,guardianRelationship=@guardianRelationship,guardianPhone=@guardianPhone,classNo=@level WHERE ledgerId=@studentId;"; MySqlCommand sccmd = new MySqlCommand(sql, sqlcon); MySqlParameter sprmparam = new MySqlParameter(); sprmparam = sccmd.Parameters.Add("?firstName", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.LedgerName; sprmparam = sccmd.Parameters.Add("?lastName", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.OtherName; sprmparam = sccmd.Parameters.Add("?openingBalance", MySqlDbType.Decimal); sprmparam.Value = Studentinfo.OpeningBalance; sprmparam = sccmd.Parameters.Add("?crOrDr", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.CrOrDr; sprmparam = sccmd.Parameters.Add("?email", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.Email; sprmparam = sccmd.Parameters.Add("?dateOfBirth", MySqlDbType.DateTime); sprmparam.Value = Studentinfo.DateOfBirth; sprmparam = sccmd.Parameters.Add("?homePhone", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.HomePhone; sprmparam = sccmd.Parameters.Add("?adminNumber", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.AdminNumber; sprmparam = sccmd.Parameters.Add("?level", MySqlDbType.Int24); sprmparam.Value = Studentinfo.ClassNo; sprmparam = sccmd.Parameters.Add("?dateJoined", MySqlDbType.DateTime); sprmparam.Value = Studentinfo.DateJoined; sprmparam = sccmd.Parameters.Add("?photo", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.Photo; sprmparam = sccmd.Parameters.Add("?active", MySqlDbType.Bit); sprmparam.Value = Studentinfo.Active; sprmparam = sccmd.Parameters.Add("?guardianEmail", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianEmail; sprmparam = sccmd.Parameters.Add("?guardianName", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianName; sprmparam = sccmd.Parameters.Add("?guardianRelationship", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianRelationship; sprmparam = sccmd.Parameters.Add("?guardianPhone", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianPhone; sprmparam = sccmd.Parameters.Add("?studentId", MySqlDbType.Decimal); sprmparam.Value = studentId; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlcon.Close(); } }
/// <summary> ///Function to edit account ledger /// </summary> public void EditFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.LedgerName = txtLedgerName.Text.Trim(); infoAccountLedger.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString()); infoAccountLedger.OpeningBalance = Convert.ToDecimal(((txtOpeningBalance.Text == "") ? "0" : txtOpeningBalance.Text.Trim())); infoAccountLedger.CrOrDr = cmbOpeningBalanceCrOrDr.Text.Trim(); infoAccountLedger.Narration = txtNarration.Text.Trim(); if (isBankAccount) { infoAccountLedger.BankAccountNumber = txtAcNo.Text.Trim(); infoAccountLedger.BranchName = txtBranchName.Text.Trim(); infoAccountLedger.BranchCode = txtBranchCode.Text.Trim(); } else { if (isSundryDebtorOrCreditor) { infoAccountLedger.BankAccountNumber = txtAccountNo.Text; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } else { infoAccountLedger.BankAccountNumber = string.Empty; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } } if (!isDefault) { infoAccountLedger.IsDefault = false; } else { infoAccountLedger.IsDefault = true; } if (isSundryDebtorOrCreditor) { infoAccountLedger.MailingName = txtMailingName.Text.Trim(); infoAccountLedger.Address = txtAddress.Text.Trim(); infoAccountLedger.Phone = txtPhone.Text.Trim(); infoAccountLedger.Mobile = txtMobile.Text.Trim(); infoAccountLedger.Email = txtEmail.Text.Trim(); infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim()); infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.Trim()); if (cmbPricingLevel.SelectedIndex <= 0) { infoAccountLedger.PricinglevelId = 1; } else { infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } if (cmbBillByBill.Text == "Yes") { infoAccountLedger.BillByBill = true; } else { infoAccountLedger.BillByBill = false; } infoAccountLedger.Tin = txtTin.Text.Trim(); infoAccountLedger.Cst = txtCst.Text.Trim(); infoAccountLedger.Pan = txtPan.Text.Trim(); if (cmbArea.SelectedIndex <= 0) { infoAccountLedger.AreaId = 1; } else { infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); } if (cmbRoute.SelectedIndex < 0) { infoAccountLedger.RouteId = 1; } else { infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString()); } infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; } else { infoAccountLedger.MailingName = string.Empty; infoAccountLedger.Address = string.Empty; infoAccountLedger.State = string.Empty; infoAccountLedger.Phone = string.Empty; infoAccountLedger.Mobile = string.Empty; infoAccountLedger.Email = string.Empty; infoAccountLedger.CreditPeriod = 0; infoAccountLedger.CreditLimit = 0; infoAccountLedger.PricinglevelId = 1; infoAccountLedger.BillByBill = false; infoAccountLedger.Tin = string.Empty; infoAccountLedger.Cst = string.Empty; infoAccountLedger.Pan = string.Empty; infoAccountLedger.RouteId = 1; infoAccountLedger.AreaId = 1; infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; } infoAccountLedger.LedgerId = decAccountLedgerId; if (bllAccountLedger.AccountLedgerCheckExistence(txtLedgerName.Text.Trim(), decLedger) == false) { bllAccountLedger.AccountLedgerEdit(infoAccountLedger); LedgerPostingEdit(); if (cmbBillByBill.Text == "Yes" && isSundryDebtorOrCreditor) { PartyBalanceEdit(); } else { bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decAccountLedgerId.ToString(), 1); } Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage("Ledgername already exist"); txtLedgerName.Focus(); } } catch (Exception ex) { MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// fill controlls here for editing /// </summary> public void FillControls() { try { AccountLedgerInfo infoAccountledger = new AccountLedgerInfo(); AccountLedgerBll bllAccountledger = new AccountLedgerBll(); infoAccountledger = bllAccountledger.AccountLedgerViewForSupplier(Convert.ToDecimal(strLedgerId.ToString())); txtSupplierName.Text = infoAccountledger.LedgerName; txtMailingName.Text = infoAccountledger.MailingName; txtOpeningBalance.Text = Convert.ToString(Math.Round(infoAccountledger.OpeningBalance, PublicVariables._inNoOfDecimalPlaces)); cmbDrOrCr.Text = infoAccountledger.CrOrDr.ToString(); txtAcNo.Text = infoAccountledger.BankAccountNumber; txtBranchName.Text = infoAccountledger.BranchName; txtBranchCode.Text = infoAccountledger.BranchCode; txtMobile.Text = infoAccountledger.Mobile.ToString(); txtPhone.Text = infoAccountledger.Phone.ToString(); txtAddress.Text = infoAccountledger.Address; txtEmail.Text = infoAccountledger.Email; if (infoAccountledger.BillByBill) { cmbBillbyBill.Text = "Yes"; } else { cmbBillbyBill.Text = "No"; } txtTin.Text = infoAccountledger.Tin; txtPan.Text = infoAccountledger.Pan; txtCst.Text = infoAccountledger.Cst; cmbArea.SelectedValue = infoAccountledger.AreaId.ToString(); cmbRoute.SelectedValue = infoAccountledger.RouteId.ToString(); txtNarration.Text = infoAccountledger.Narration; decLedger = infoAccountledger.LedgerId; } catch (Exception ex) { MessageBox.Show("SUP6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save purchase invoice /// </summary> public void Save() { decimal decPurchaseMasterId = 0; PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo(); PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll(); PurchaseDetailsInfo infoPurchaseDetails = new PurchaseDetailsInfo(); MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll(); PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingBll BllStockPosting = new StockPostingBll(); //StockPostingSP spStockPosting = new StockPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); //PartyBalanceSP spPartyBalance = new PartyBalanceSP(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AditionalCostBll bllAdditionalCost = new AditionalCostBll(); PurchaseBillTaxInfo infoPurchaseBillTax = new PurchaseBillTaxInfo(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { /*-----------------------------------------Purchase Master Add----------------------------------------------------*/ infoPurchaseMaster.AdditionalCost = Convert.ToDecimal(lblAdditionalCostAmount.Text); infoPurchaseMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text); infoPurchaseMaster.CreditPeriod = txtCreditPeriod.Text; infoPurchaseMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPurchaseMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoPurchaseMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoPurchaseMaster.InvoiceNo = txtVoucherNo.Text.Trim(); if (isAutomatic) { infoPurchaseMaster.SuffixPrefixId = decPurchaseInvoiceSuffixPrefixId; infoPurchaseMaster.VoucherNo = strVoucherNo; } else { infoPurchaseMaster.SuffixPrefixId = 0; infoPurchaseMaster.VoucherNo = strVoucherNo; } infoPurchaseMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPurchaseMaster.LrNo = txtLRNo.Text; if (cmbPurchaseMode.Text == "Against MaterialReceipt") { infoPurchaseMaster.MaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); } else { infoPurchaseMaster.MaterialReceiptMasterId = 0; } infoPurchaseMaster.Narration = txtNarration.Text; infoPurchaseMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString()); if (cmbPurchaseMode.Text == "Against PurchaseOrder") { infoPurchaseMaster.PurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); } else { infoPurchaseMaster.PurchaseOrderMasterId = 0; } infoPurchaseMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoPurchaseMaster.TotalTax = Convert.ToDecimal(lblTaxAmount.Text); infoPurchaseMaster.TransportationCompany = txtTransportationCompany.Text; infoPurchaseMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseMaster.VendorInvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text); infoPurchaseMaster.VendorInvoiceNo = txtVendorInvoiceNo.Text; infoPurchaseMaster.VoucherTypeId = decPurchaseInvoiceVoucherTypeId; infoPurchaseMaster.Extra1 = string.Empty; infoPurchaseMaster.Extra2 = string.Empty; infoPurchaseMaster.ExtraDate = Convert.ToDateTime(DateTime.Now); decPurchaseMasterId = BllPurchaseInvoice.PurchaseMasterAdd(infoPurchaseMaster); infoPurchaseOrderMaster = BllPurchaseOrder.PurchaseOrderMasterView(infoPurchaseMaster.PurchaseOrderMasterId); infoMaterialReceiptMaster = bllMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId); foreach (DataGridViewRow dgvrow in dgvProductDetails.Rows) { if (dgvrow.Cells["dgvtxtProductId"].Value != null) { if (dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { /*-----------------------------------------Purchase Details Add----------------------------------------------------*/ infoPurchaseDetails.Amount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAmount"].Value.ToString()); infoPurchaseDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString()); infoPurchaseDetails.Discount = Convert.ToDecimal(dgvrow.Cells["dgvtxtDiscount"].Value.ToString()); infoPurchaseDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString()); infoPurchaseDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtGrossValue"].Value.ToString()); infoPurchaseDetails.NetAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtNetValue"].Value.ToString()); infoPurchaseDetails.OrderDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString()); infoPurchaseDetails.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString()); infoPurchaseDetails.PurchaseMasterId = decPurchaseMasterId; infoPurchaseDetails.Qty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString()); infoPurchaseDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString()); infoPurchaseDetails.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString()); infoPurchaseDetails.ReceiptDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtMaterialReceiptDetailsId"].Value.ToString()); infoPurchaseDetails.SlNo = Convert.ToInt32(dgvrow.Cells["dgvtxtSlNo"].Value.ToString()); infoPurchaseDetails.TaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxAmount"].Value.ToString()); infoPurchaseDetails.TaxId = Convert.ToDecimal(dgvrow.Cells["dgvcmbTax"].Value.ToString()); infoPurchaseDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value.ToString()); infoPurchaseDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); infoPurchaseDetails.Extra1 = string.Empty; infoPurchaseDetails.Extra2 = string.Empty; infoPurchaseDetails.ExtraDate = Convert.ToDateTime(DateTime.Today); BllPurchaseInvoice.PurchaseDetailsAdd(infoPurchaseDetails); /*-----------------------------------------Stock Posting----------------------------------------------------*/ infoStockPosting.BatchId = infoPurchaseDetails.BatchId; infoStockPosting.Date = infoPurchaseMaster.Date; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = infoPurchaseDetails.GodownId; infoStockPosting.InwardQty = infoPurchaseDetails.Qty; /// spUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.ProductId = infoPurchaseDetails.ProductId; infoStockPosting.RackId = infoPurchaseDetails.RackId; infoStockPosting.Rate = infoPurchaseDetails.Rate; infoStockPosting.UnitId = infoPurchaseDetails.UnitId; if (infoPurchaseDetails.OrderDetailsId != 0) { infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; } else if (infoPurchaseDetails.ReceiptDetailsId != 0) { infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; } else if (infoPurchaseDetails.OrderDetailsId == 0 && infoPurchaseDetails.ReceiptDetailsId == 0) { infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; } infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.ExtraDate = Convert.ToDateTime(DateTime.Today); BllStockPosting.StockPostingAdd(infoStockPosting); if (infoPurchaseDetails.ReceiptDetailsId != 0) { infoStockPosting.InvoiceNo = infoMaterialReceiptMaster.InvoiceNo; infoStockPosting.VoucherNo = infoMaterialReceiptMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoMaterialReceiptMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = infoPurchaseDetails.Qty;/// spUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseDetails.UnitConversionId); BllStockPosting.StockPostingAdd(infoStockPosting); } } } } /*-----------------------------------------Ledger Posting----------------------------------------------------*/ infoLedgerPosting.Credit = Convert.ToDecimal(txtGrandTotal.Text) * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Debit = 0; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = infoPurchaseMaster.LedgerId; infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); decimal decBilldiscount = Convert.ToDecimal(txtBillDiscount.Text.ToString()); if (decBilldiscount > 0) { infoLedgerPosting.Credit = decBilldiscount * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Debit = 0; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = 9;//ledger id of discount received infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = TotalNetAmount(); //* spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = infoPurchaseMaster.PurchaseAccount;//ledger posting of purchase account infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows) { if (dgvrow.Cells["dgvcmbLedger"].Value != null) { if (dgvrow.Cells["dgvcmbLedger"].Value.ToString() != string.Empty) { if (dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString() != string.Empty) { /*-----------------------------------------Additional Cost Add----------------------------------------------------*/ infoAdditionalCost.Credit = 0; infoAdditionalCost.Debit = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString()); infoAdditionalCost.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvcmbLedger"].Value.ToString()); infoAdditionalCost.VoucherNo = infoPurchaseMaster.VoucherNo; infoAdditionalCost.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; infoAdditionalCost.ExtraDate = DateTime.Now; bllAdditionalCost.AdditionalCostAdd(infoAdditionalCost); /*-----------------------------------------Additional Cost Ledger Posting----------------------------------------------------*/ infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = infoAdditionalCost.Debit * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = infoAdditionalCost.LedgerId; infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } } } } if (dgvTax.Visible) { foreach (DataGridViewRow dgvrow in dgvTax.Rows) { if (dgvrow.Cells["dgvtxtTaxId"].Value != null) { if (dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty) { /*-----------------------------------------PurchaseBillTax Add----------------------------------------------------*/ infoPurchaseBillTax.PurchaseMasterId = decPurchaseMasterId; infoPurchaseBillTax.TaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTotalTax"].Value.ToString()); infoPurchaseBillTax.TaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxId"].Value.ToString()); infoPurchaseBillTax.Extra1 = string.Empty; infoPurchaseBillTax.Extra2 = string.Empty; infoPurchaseBillTax.ExtraDate = DateTime.Now; BllPurchaseInvoice.PurchaseBillTaxAdd(infoPurchaseBillTax); /*-----------------------------------------Tax Ledger Posting----------------------------------------------------*/ infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = infoPurchaseBillTax.TaxAmount * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtLedgerId"].Value.ToString()); infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } } } /*-----------------------------------------PartyBalance Posting----------------------------------------------------*/ infoAccountLedger = bllAccountLedger.AccountLedgerView(infoPurchaseMaster.LedgerId); if (infoAccountLedger.BillByBill == true) { infoPartyBalance.Credit = Convert.ToDecimal(txtGrandTotal.Text); infoPartyBalance.Debit = 0; if (txtCreditPeriod.Text != string.Empty) { infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); } infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.ExchangeRateId = infoPurchaseMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.LedgerId = infoPurchaseMaster.LedgerId; infoPartyBalance.ReferenceType = "NEW"; infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo; infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; infoPartyBalance.ExtraDate = DateTime.Now; BllPartyBalance.PartyBalanceAdd(infoPartyBalance); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseMasterId); } else { Print(decPurchaseMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("PI38:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Edit /// </summary> public void EditFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.LedgerName = txtCustomerName.Text.Trim(); infoAccountLedger.MailingName = txtMailingName.Text.Trim(); if (txtOpeningBalance.Text.Trim() != string.Empty) { infoAccountLedger.OpeningBalance = Convert.ToDecimal(txtOpeningBalance.Text.Trim()); } else { infoAccountLedger.OpeningBalance = 0; } infoAccountLedger.CrOrDr = cmbDrorCr.Text.ToString(); infoAccountLedger.BankAccountNumber = txtAccountNo.Text.Trim(); infoAccountLedger.BranchName = txtBranchName.Text.Trim(); infoAccountLedger.BranchCode = txtBranchCode.Text.Trim(); infoAccountLedger.Mobile = txtMobile.Text.Trim(); infoAccountLedger.Address = txtAddress.Text.Trim(); if (cmbBillbyBill.Text == "Yes") { infoAccountLedger.BillByBill = true; } else { infoAccountLedger.BillByBill = false; } if (txtCreditLimit.Text.Trim() != string.Empty) { infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.Trim()); } else { infoAccountLedger.CreditLimit = 0; } if (txtCreditPeriod.Text.Trim() != string.Empty) { infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim()); } else { infoAccountLedger.CreditPeriod = 0; } infoAccountLedger.Cst = txtCST.Text.Trim(); if (cmbArea.SelectedValue != null) { infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); } else { infoAccountLedger.AreaId = 1m; } if(cmbRoute.SelectedValue != null) { infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString()); } else { infoAccountLedger.RouteId = 1m; } infoAccountLedger.MailingName = txtMailingName.Text.Trim(); infoAccountLedger.Phone = txtphone.Text.Trim(); infoAccountLedger.Email = txtEmail.Text.Trim(); if (cmbPricingLevel.SelectedValue != null) { infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } else { infoAccountLedger.PricinglevelId = 0; } infoAccountLedger.Tin = txtTin.Text.Trim(); infoAccountLedger.Pan = txtPan.Text.Trim(); infoAccountLedger.Narration = txtNarration.Text.Trim(); infoAccountLedger.LedgerId = decLedgerIdForEdit; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; decOpeningBlnc = infoAccountLedger.OpeningBalance; if (bllAccountLedger.AccountLedgerCheckExistenceForCustomer(txtCustomerName.Text.Trim(), decLedger) == false) { bllAccountLedger.AccountLedgerEditForCustomer(infoAccountLedger); ledgerUpdate(); if (cmbBillbyBill.Text == "Yes") { partyBalanceUpdate(); } else { bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decLedgerIdForEdit.ToString(), 1); } Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage("Customer name already exist"); txtCustomerName.Focus(); } } catch (Exception ex) { MessageBox.Show("Cus7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save data to the database /// </summary> public void SaveFunction() { try { int inRowcount = dgvMultipleAccountLedger.RowCount;//edited by Runali int inRowcountDec = (dgvMultipleAccountLedger.RowCount) - 1; decimal decOpeningBalance = 0; decimal decLedgerId = 0; bool isSave = false; AccountLedgerInfo infoAccountledger = new AccountLedgerInfo(); AccountLedgerSP spAccountledger = new AccountLedgerSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); FinancialYearSP spFinancialYear = new FinancialYearSP(); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); for (int i = 0; i < inRowcount - 1; i++) { infoAccountledger.AccountGroupId = Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString()); infoAccountledger.LedgerName = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtLedgerName"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null) { infoAccountledger.OpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); } else { infoAccountledger.OpeningBalance = 0; } infoAccountledger.CrOrDr = dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value != null) { infoAccountledger.Narration = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value.ToString(); } else { infoAccountledger.Narration = string.Empty; } infoAccountledger.MailingName = string.Empty; infoAccountledger.Address = string.Empty; infoAccountledger.State = string.Empty; infoAccountledger.Phone = string.Empty; infoAccountledger.Mobile = string.Empty; infoAccountledger.Email = string.Empty; infoAccountledger.CreditPeriod = 0; infoAccountledger.CreditLimit = 0; infoAccountledger.PricinglevelId = 0; infoAccountledger.BillByBill = false; infoAccountledger.Tin = string.Empty; infoAccountledger.Cst = string.Empty; infoAccountledger.Pan = string.Empty; infoAccountledger.RouteId = 0; infoAccountledger.BankAccountNumber = string.Empty; infoAccountledger.BranchName = string.Empty; infoAccountledger.BranchCode = string.Empty; infoAccountledger.Extra1 = string.Empty; infoAccountledger.Extra2 = string.Empty; infoAccountledger.AreaId = 0; infoAccountledger.IsDefault = false; decLedgerId = spAccountledger.AccountLedgerAddWithIdentity(infoAccountledger); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null && dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != "0") { if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != string.Empty) { string strfinancialId; decOpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); infoFinancialYear = spFinancialYear.FinancialYearViewForAccountLedger(1); strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy"); infoLedgerPosting.VoucherTypeId = 1; infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString()); infoLedgerPosting.LedgerId = decLedgerId; infoLedgerPosting.VoucherNo = decLedgerId.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString() == "Dr") { infoLedgerPosting.Debit = decOpeningBalance; } else { infoLedgerPosting.Credit = decOpeningBalance; } infoLedgerPosting.DetailsId = 0; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = decLedgerId.ToString(); infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } isSave = true; } if (isSave) { Messages.SavedMessage(); cmbAccountGroup.Focus(); cmbAccountGroup.SelectedIndex = -1; dgvMultipleAccountLedger.Rows.Clear(); } else { } } catch (Exception ex) { MessageBox.Show("MAL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// delete function /// </summary> public void DeleteFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (bllAccountLedger.SupplierCheckreferenceAndDelete(Convert.ToDecimal(strLedgerId.ToString())) == -1) { Messages.ReferenceExistsMessage(); } else { bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decLedger.ToString(), 1); bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decLedger.ToString(), 1); bllAccountLedger.AccountLedgerDelete(decLedger); Messages.DeletedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("SUP11" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Adding columns to print /// </summary> /// <param name="decDeliveryNoteMasterId"></param> public void PrintForDotMatrix(decimal decDeliveryNoteMasterId) { try { DataTable dtblOtherDetails = new DataTable(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); dtblOtherDetails = bllCompanyCreation.CompanyViewForDotMatrix(); //-------------Grid Details-------------------\\ DataTable dtblGridDetails = new DataTable(); dtblGridDetails.Columns.Add("SlNo"); dtblGridDetails.Columns.Add("BarCode"); dtblGridDetails.Columns.Add("ProductCode"); dtblGridDetails.Columns.Add("ProductName"); dtblGridDetails.Columns.Add("Qty"); dtblGridDetails.Columns.Add("Unit"); dtblGridDetails.Columns.Add("Godown"); dtblGridDetails.Columns.Add("Rack"); dtblGridDetails.Columns.Add("Batch"); dtblGridDetails.Columns.Add("Rate"); dtblGridDetails.Columns.Add("Amount"); int inRowCount = 0; foreach (DataGridViewRow dRow in dgvProduct.Rows) { if (!dRow.IsNewRow) { DataRow dr = dtblGridDetails.NewRow(); dr["SlNo"] = ++inRowCount; if (dRow.Cells["dgvtxtBarcode"].Value != null) { dr["BarCode"] = dRow.Cells["dgvtxtBarcode"].Value.ToString(); } if (dRow.Cells["dgvtxtProductCode"].Value != null) { dr["ProductCode"] = dRow.Cells["dgvtxtProductCode"].Value.ToString(); } if (dRow.Cells["dgvtxtProductName"].Value != null) { dr["ProductName"] = dRow.Cells["dgvtxtProductName"].Value.ToString(); } if (dRow.Cells["dgvtxtQty"].Value != null) { dr["Qty"] = dRow.Cells["dgvtxtQty"].Value.ToString(); } if (dRow.Cells["dgvcmbUnit"].Value != null) { dr["Unit"] = dRow.Cells["dgvcmbUnit"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbGodown"].Value != null) { dr["Godown"] = dRow.Cells["dgvcmbGodown"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbRack"].Value != null) { dr["Rack"] = dRow.Cells["dgvcmbRack"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbBatch"].Value != null) { dr["Batch"] = dRow.Cells["dgvcmbBatch"].FormattedValue.ToString(); } if (dRow.Cells["dgvtxtRate"].Value != null) { dr["Rate"] = dRow.Cells["dgvtxtRate"].Value.ToString(); } if (dRow.Cells["dgvtxtAmount"].Value != null) { dr["Amount"] = dRow.Cells["dgvtxtAmount"].Value.ToString(); } dtblGridDetails.Rows.Add(dr); } } //-------------Other Details-------------------\\ dtblOtherDetails.Columns.Add("voucherNo"); dtblOtherDetails.Columns.Add("date"); dtblOtherDetails.Columns.Add("ledgerName"); dtblOtherDetails.Columns.Add("Narration"); dtblOtherDetails.Columns.Add("Currency"); dtblOtherDetails.Columns.Add("TotalAmount"); dtblOtherDetails.Columns.Add("DeliveryMode"); dtblOtherDetails.Columns.Add("PricingLevel"); dtblOtherDetails.Columns.Add("Type"); dtblOtherDetails.Columns.Add("SalesMan"); dtblOtherDetails.Columns.Add("CustomerAddress"); dtblOtherDetails.Columns.Add("CustomerTIN"); dtblOtherDetails.Columns.Add("CustomerCST"); dtblOtherDetails.Columns.Add("AmountInWords"); dtblOtherDetails.Columns.Add("Declaration"); dtblOtherDetails.Columns.Add("Heading1"); dtblOtherDetails.Columns.Add("Heading2"); dtblOtherDetails.Columns.Add("Heading3"); dtblOtherDetails.Columns.Add("Heading4"); DataRow dRowOther = dtblOtherDetails.Rows[0]; dRowOther["voucherNo"] = txtDeliveryNoteNo.Text; dRowOther["date"] = txtDate.Text; dRowOther["ledgerName"] = cmbCashOrParty.Text; dRowOther["Narration"] = txtNarration.Text; dRowOther["Currency"] = cmbCurrency.Text; dRowOther["TotalAmount"] = txtTotalAmnt.Text; dRowOther["DeliveryMode"] = cmbDeliveryMode.Text; dRowOther["PricingLevel"] = cmbPricingLevel.Text; dRowOther["Type"] = cmbType.Text; dRowOther["SalesMan"] = cmbSalesMan.Text; dRowOther["address"] = (dtblOtherDetails.Rows[0]["address"].ToString().Replace("\n", ", ")).Replace("\r", ""); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); infoAccountLedger = bllAccountLedger.AccountLedgerView(Convert.ToDecimal(cmbCashOrParty.SelectedValue)); dRowOther["CustomerAddress"] = (infoAccountLedger.Address.ToString().Replace("\n", ", ")).Replace("\r", ""); dRowOther["CustomerTIN"] = infoAccountLedger.Tin; dRowOther["CustomerCST"] = infoAccountLedger.Cst; dRowOther["AmountInWords"] = new NumToText().AmountWords(Convert.ToDecimal(txtTotalAmnt.Text), PublicVariables._decCurrencyId); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); DataTable dtblDeclaration = BllVoucherType.DeclarationAndHeadingGetByVoucherTypeId(decDeliveryNoteVoucherTypeId); dRowOther["Declaration"] = dtblDeclaration.Rows[0]["Declaration"].ToString(); dRowOther["Heading1"] = dtblDeclaration.Rows[0]["Heading1"].ToString(); dRowOther["Heading2"] = dtblDeclaration.Rows[0]["Heading2"].ToString(); dRowOther["Heading3"] = dtblDeclaration.Rows[0]["Heading3"].ToString(); dRowOther["Heading4"] = dtblDeclaration.Rows[0]["Heading4"].ToString(); int inFormId = BllVoucherType.FormIdGetForPrinterSettings(Convert.ToInt32(dtblDeclaration.Rows[0]["masterId"].ToString())); PrintWorks.DotMatrixPrint.PrintDesign(inFormId, dtblOtherDetails, dtblGridDetails, dtblOtherDetails); } catch (Exception ex) { MessageBox.Show("DN41:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnSave_Click(object sender, EventArgs e) { if (txbExcelPath.Text.Trim() == string.Empty) { MessageBox.Show("Browse for the excel path"); txbExcelPath.Focus(); } if (textSheetName.Text.Trim() == string.Empty) { MessageBox.Show("Enter Sheet Name"); textSheetName.Focus(); } else { AccountLedgerInfo student = new AccountLedgerInfo(); StudentSP studentSP = new StudentSP(); int rowcounter = dataGridView1.RowCount; try { for (int i = 0; i < rowcounter; i++) { if (dataGridView1.Rows[i].Cells["FirstName"].Value != null && dataGridView1.Rows[i].Cells["FirstName"].Value.ToString() != string.Empty) { student.LedgerName = Convert.ToString(dataGridView1.Rows[i].Cells["FirstName"].Value); } if (dataGridView1.Rows[i].Cells["LastName"].Value != null && dataGridView1.Rows[i].Cells["LastName"].Value.ToString() != string.Empty) { student.OtherName = Convert.ToString(dataGridView1.Rows[i].Cells["LastName"].Value); } if (dataGridView1.Rows[i].Cells["gender"].Value != null && dataGridView1.Rows[i].Cells["gender"].Value.ToString() != string.Empty) { student.Gender = Convert.ToString(dataGridView1.Rows[i].Cells["gender"].Value); } if (dataGridView1.Rows[i].Cells["dateOfBirth"].Value != null && dataGridView1.Rows[i].Cells["dateOfBirth"].Value.ToString() != string.Empty) { student.DateOfBirth = Convert.ToDateTime(dataGridView1.Rows[i].Cells["dateOfBirth"].Value.ToString()); } if (dataGridView1.Rows[i].Cells["AdminNumber"].Value != null && dataGridView1.Rows[i].Cells["AdminNumber"].Value.ToString() != string.Empty) { student.AdminNumber = Convert.ToString(dataGridView1.Rows[i].Cells["AdminNumber"].Value); } if (dataGridView1.Rows[i].Cells["Class"].Value != null && dataGridView1.Rows[i].Cells["Class"].Value.ToString() != string.Empty) { student.ClassNo = Convert.ToInt32(dataGridView1.Rows[i].Cells["Class"].Value.ToString()); } if (dataGridView1.Rows[i].Cells["AdmissionDate"].Value != null && dataGridView1.Rows[i].Cells["AdmissionDate"].Value.ToString() != string.Empty) { student.DateJoined = Convert.ToDateTime(dataGridView1.Rows[i].Cells["AdmissionDate"].Value); } student.AccountGroupId = 15; student.CrOrDr = "Cr"; studentSP.StudentAdd(student); } MessageBox.Show("Saved succesfully"); btnSave.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> ///Function to fill data in to controls when click on datagridview /// </summary> public void FillControls() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger = bllAccountLedger.AccountLedgerViewForEdit(decAccountLedgerId); txtAccountNo.Text = infoAccountLedger.BankAccountNumber; txtAcNo.Text = infoAccountLedger.BankAccountNumber; txtAddress.Text = infoAccountLedger.Address; txtBranchName.Text = infoAccountLedger.BranchName; txtBranchCode.Text = infoAccountLedger.BranchCode; txtCst.Text = infoAccountLedger.Cst; txtEmail.Text = infoAccountLedger.Email; txtLedgerName.Text = infoAccountLedger.LedgerName; txtMailingName.Text = infoAccountLedger.MailingName; txtMobile.Text = infoAccountLedger.Mobile; txtNarration.Text = infoAccountLedger.Narration; txtPan.Text = infoAccountLedger.Pan; txtPhone.Text = infoAccountLedger.Phone; txtTin.Text = infoAccountLedger.Tin; txtCreditLimit.Text = infoAccountLedger.CreditLimit.ToString(); txtCreditPeriod.Text = infoAccountLedger.CreditPeriod.ToString(); AreaComboFill(); cmbArea.SelectedValue = infoAccountLedger.AreaId.ToString(); if (infoAccountLedger.BillByBill) { cmbBillByBill.Text = "Yes"; } else { cmbBillByBill.Text = "No"; } cmbGroup.SelectedValue = infoAccountLedger.AccountGroupId.ToString(); PrlicingLevelComboFill(); cmbPricingLevel.SelectedValue = infoAccountLedger.PricinglevelId; cmbRoute.SelectedValue = infoAccountLedger.RouteId.ToString(); decimal decBalance = infoAccountLedger.OpeningBalance; txtOpeningBalance.Text = decBalance.ToString(); cmbOpeningBalanceCrOrDr.Text = infoAccountLedger.CrOrDr.ToString(); if (infoAccountLedger.IsDefault == true) { cmbGroup.Enabled = false; txtLedgerName.ReadOnly = true; btnAccountGroupAdd.Enabled = false; txtLedgerName.BackColor = Color.WhiteSmoke; } else if (infoAccountLedger.IsDefault == false && decBalance > 0) { cmbGroup.Enabled = false; btnAccountGroupAdd.Enabled = false; txtLedgerName.ReadOnly = false; txtLedgerName.BackColor = Color.White; } else { cmbGroup.Enabled = true; txtLedgerName.ReadOnly = false; txtLedgerName.BackColor = Color.White; btnAccountGroupAdd.Enabled = true; } if (bllAccountLedger.PartyBalanceAgainstReferenceCheck(decAccountLedgerId.ToString(), 1)) { cmbGroup.Enabled = false; txtLedgerName.ReadOnly = false; txtOpeningBalance.Enabled = false; cmbOpeningBalanceCrOrDr.Enabled = false; cmbBillByBill.Enabled = false; txtLedgerName.BackColor = Color.White; } decLedger = infoAccountLedger.LedgerId; isDefault = infoAccountLedger.IsDefault; tbctrlLedger.SelectedTab = tbMainDetails; } catch (Exception ex) { MessageBox.Show("AL26:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill controls to update /// </summary> public void FillControls() { try { AccountLedgerInfo infoAccountledger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountledger = bllAccountLedger.AccountLedgerViewForCustomer(decLedgerIdForEdit); txtCustomerName.Text = infoAccountledger.LedgerName; txtMailingName.Text = infoAccountledger.MailingName; txtOpeningBalance.Text = infoAccountledger.OpeningBalance.ToString(); cmbDrorCr.Text = infoAccountledger.CrOrDr.ToString(); txtAccountNo.Text = infoAccountledger.BankAccountNumber; txtBranchName.Text = infoAccountledger.BranchName; txtBranchCode.Text = infoAccountledger.BranchCode; txtMobile.Text = infoAccountledger.Mobile.ToString(); txtphone.Text = infoAccountledger.Phone.ToString(); txtAddress.Text = infoAccountledger.Address; txtEmail.Text = infoAccountledger.Email; cmbPricingLevel.SelectedValue = infoAccountledger.PricinglevelId.ToString(); if (infoAccountledger.BillByBill) { cmbBillbyBill.Text = "Yes"; } else { cmbBillbyBill.Text = "No"; } if (bllAccountLedger.PartyBalanceAgainstReferenceCheck(decLedgerIdForEdit.ToString(), 1)) { txtOpeningBalance.Enabled = false; cmbDrorCr.Enabled = false; cmbBillbyBill.Enabled = false; } txtCreditPeriod.Text = infoAccountledger.CreditPeriod.ToString(); txtCreditLimit.Text = infoAccountledger.CreditLimit.ToString(); txtTin.Text = infoAccountledger.Tin; txtPan.Text = infoAccountledger.Pan; txtCST.Text = infoAccountledger.Cst; cmbArea.SelectedValue = infoAccountledger.AreaId.ToString(); cmbRoute.SelectedValue = infoAccountledger.RouteId.ToString(); txtNarration.Text = infoAccountledger.Narration; decLedger = infoAccountledger.LedgerId; } catch (Exception ex) { MessageBox.Show("Cus11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values to tblstudents /// </summary> /// <param name="Studentinfo"></param> public void StudentAdd(AccountLedgerInfo Studentinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } MySqlCommand sccmd = new MySqlCommand("AccountLedgerAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; MySqlParameter sprmparam = new MySqlParameter(); sprmparam = sccmd.Parameters.Add("?accountGroupId", MySqlDbType.Int32); sprmparam.Value = Studentinfo.AccountGroupId; sprmparam = sccmd.Parameters.Add("?ledgerName", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.LedgerName; sprmparam = sccmd.Parameters.Add("?otherName", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.OtherName; sprmparam = sccmd.Parameters.Add("?openingBalance", MySqlDbType.Decimal); sprmparam.Value = Studentinfo.OpeningBalance; sprmparam = sccmd.Parameters.Add("?crOrDr", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.CrOrDr; sprmparam = sccmd.Parameters.Add("?active", MySqlDbType.Bit); sprmparam.Value = Studentinfo.Active; sprmparam = sccmd.Parameters.Add("?narration", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.Narration; sprmparam = sccmd.Parameters.Add("?email", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.Email; sprmparam = sccmd.Parameters.Add("?gender", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.Gender; sprmparam = sccmd.Parameters.Add("?dateOfBirth", MySqlDbType.Date); sprmparam.Value = Studentinfo.DateOfBirth; sprmparam = sccmd.Parameters.Add("?homePhone", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.HomePhone; sprmparam = sccmd.Parameters.Add("?adminNumber", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.AdminNumber; sprmparam = sccmd.Parameters.Add("?classNo", MySqlDbType.Int32); sprmparam.Value = Studentinfo.ClassNo; sprmparam = sccmd.Parameters.Add("?dateJoined", MySqlDbType.Date); sprmparam.Value = Studentinfo.DateJoined; sprmparam = sccmd.Parameters.Add("?photo", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.Photo; sprmparam = sccmd.Parameters.Add("?guardianEmail", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianEmail; sprmparam = sccmd.Parameters.Add("?guardianName", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianName; sprmparam = sccmd.Parameters.Add("?guardianRelationship", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianRelationship; sprmparam = sccmd.Parameters.Add("?guardianPhone", MySqlDbType.VarChar); sprmparam.Value = Studentinfo.GuardianPhone; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlcon.Close(); } }
/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.AccountGroupId = 26; infoAccountLedger.LedgerName = txtCustomerName.Text.Trim(); if (txtOpeningBalance.Text.Trim() != string.Empty) { infoAccountLedger.OpeningBalance = Convert.ToDecimal(txtOpeningBalance.Text.Trim()); decOpeningBlnc = infoAccountLedger.OpeningBalance; } else { infoAccountLedger.OpeningBalance = 0; } infoAccountLedger.CrOrDr = cmbDrorCr.Text; infoAccountLedger.BankAccountNumber = txtAccountNo.Text.Trim(); infoAccountLedger.BranchName = txtBranchName.Text.Trim(); infoAccountLedger.BranchCode = txtBranchCode.Text.Trim(); infoAccountLedger.Mobile = txtMobile.Text.Trim(); infoAccountLedger.Address = txtAddress.Text.Trim(); if (cmbBillbyBill.Text == "Yes") { infoAccountLedger.BillByBill = true; } else { infoAccountLedger.BillByBill = false; } if (txtCreditLimit.Text.Trim() != string.Empty) { infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.ToString()); } else { infoAccountLedger.CreditLimit = 0; } if (txtCreditPeriod.Text.Trim() != string.Empty) { infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.ToString()); } else { infoAccountLedger.CreditPeriod = 0; } infoAccountLedger.Cst = txtCST.Text.Trim(); if (Convert.ToDecimal(cmbArea.SelectedValue.ToString()) != 0) { infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); } else { infoAccountLedger.AreaId = 1m; } if (Convert.ToDecimal(cmbRoute.SelectedValue.ToString()) != 0) { infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString()); } else { infoAccountLedger.RouteId = 1m; } infoAccountLedger.MailingName = txtMailingName.Text.Trim(); infoAccountLedger.Phone = txtphone.Text.Trim(); infoAccountLedger.Email = txtEmail.Text.Trim(); infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); infoAccountLedger.Tin = txtTin.Text.Trim(); infoAccountLedger.Pan = txtPan.Text.Trim(); infoAccountLedger.Narration = txtNarration.Text.Trim(); infoAccountLedger.IsDefault = false; infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; if (bllAccountLedger.AccountLedgerCheckExistenceForCustomer(txtCustomerName.Text.Trim(), 0) == false) { decledgerid = bllAccountLedger.AccountLedgerAddForCustomer(infoAccountLedger); if (decOpeningBlnc > 0) { ledgerPosting(); if (cmbBillbyBill.Text == "Yes") { partyBalance(); } } Messages.SavedMessage(); Clear(); } else { Messages.InformationMessage("Ledger name already exist"); txtCustomerName.Focus(); } } catch (Exception ex) { MessageBox.Show("Cus6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Account ledger combobox while return from Account ledger creation when creating new ledger /// </summary> /// <param name="decLedgerId"></param> public void ReturnFromAccountLedgerForm(decimal decLedgerId) { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll(); DataTable dtbl = new DataTable(); try { this.Enabled = true; this.Activate(); CashOrPartyComboFill(); PurchaseAccountComboFill(); cmbPurchaseAccount.SelectedValue = decLedgerId; cmbCashOrParty.SelectedValue = decLedgerId; if (cmbCashOrParty.Text == string.Empty) { cmbCashOrParty.SelectedValue = strCashOrParty; } if (cmbPurchaseAccount.Text == string.Empty) { cmbPurchaseAccount.SelectedValue = strPurchaseAccount; } } catch (Exception ex) { MessageBox.Show("PI6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void SaveOrEdit() { try { if (cboLevel.SelectedIndex == -1) { MessageBox.Show("Select a class"); cboLevel.Focus(); } else if (txtFirstName.Text.Trim() == string.Empty) { MessageBox.Show("Enter FirstName"); txtFirstName.Focus(); } else if (txtLastName.Text.Trim() == string.Empty) { MessageBox.Show("Enter OtherName"); txtLastName.Focus(); } else if (txtAdmision.Text.Trim() == string.Empty) { MessageBox.Show("Enter Admission Number"); txtAdmision.Focus(); } else if (cboGender.SelectedIndex == -1) { MessageBox.Show("Select a Gender"); cboGender.Focus(); } else { AccountLedgerInfo student = new AccountLedgerInfo(); StudentSP studentSP = new StudentSP(); if (cbxActive.Checked) { student.Active = true; } else { student.Active = false; } student.AccountGroupId = 15; student.CrOrDr = cmbDrorCr.Text.Trim(); student.LedgerName = txtFirstName.Text.Trim(); student.OtherName = txtLastName.Text.Trim(); student.DateOfBirth = Convert.ToDateTime(txtDateOfBirth.Text.Trim()); student.OpeningBalance = txtOpeningBalance.Text.Trim() == string.Empty? balance : Convert.ToDecimal(txtOpeningBalance.Text.Trim()); student.HomePhone = txtPhone.Text.Trim(); student.Email = txtEmail.Text.Trim(); student.Gender = cboGender.SelectedItem.ToString(); student.AdminNumber = txtAdmision.Text.Trim(); student.ClassNo = Convert.ToInt32(cboLevel.SelectedValue.ToString()); student.DateJoined = Convert.ToDateTime(txtDateJoined.Text.Trim()); student.Photo = photoPath; student.GuardianName = txtGuardianName.Text.Trim(); student.GuardianEmail = txtGuardianEmail.Text.Trim(); student.GuardianRelationship = txtRelatioship.Text.Trim(); student.GuardianPhone = txtGuardianPhone.Text.Trim(); if (btnSave.Text == "Save") { if (Messages.SaveMessage()) { studentSP.StudentAdd(student); Messages.SavedMessage(); ClearFunction(); txtFirstName.Focus(); } } else { if (Messages.UpdateMessage()) { studentSP.StudentEdit(student, studentId); Messages.UpdatedMessage(); ClearFunction(); txtFirstName.Focus(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Save data to the database /// </summary> public void SaveFunction() { try { int inRowcount = dgvMultipleAccountLedger.RowCount;//edited by Runali int inRowcountDec = (dgvMultipleAccountLedger.RowCount) - 1; decimal decOpeningBalance = 0; decimal decLedgerId = 0; bool isSave = false; AccountLedgerInfo infoAccountledger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); FinancialYearBll BllFinancialYear = new FinancialYearBll(); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); for (int i = 0; i < inRowcount - 1; i++) { infoAccountledger.AccountGroupId = Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString()); infoAccountledger.LedgerName = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtLedgerName"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null) { infoAccountledger.OpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); } else { infoAccountledger.OpeningBalance = 0; } infoAccountledger.CrOrDr = dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value != null) { infoAccountledger.Narration = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value.ToString(); } else { infoAccountledger.Narration = string.Empty; } infoAccountledger.MailingName = string.Empty; infoAccountledger.Address = string.Empty; infoAccountledger.State = string.Empty; infoAccountledger.Phone = string.Empty; infoAccountledger.Mobile = string.Empty; infoAccountledger.Email = string.Empty; infoAccountledger.CreditPeriod = 0; infoAccountledger.CreditLimit = 0; infoAccountledger.PricinglevelId = 0; infoAccountledger.BillByBill = false; infoAccountledger.Tin = string.Empty; infoAccountledger.Cst = string.Empty; infoAccountledger.Pan = string.Empty; infoAccountledger.RouteId = 0; infoAccountledger.BankAccountNumber = string.Empty; infoAccountledger.BranchName = string.Empty; infoAccountledger.BranchCode = string.Empty; infoAccountledger.Extra1 = string.Empty; infoAccountledger.Extra2 = string.Empty; infoAccountledger.AreaId = 0; infoAccountledger.IsDefault = false; infoAccountledger.ExtraDate = PublicVariables._dtCurrentDate; decLedgerId = bllAccountLedger.AccountLedgerAddWithIdentity(infoAccountledger); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null && dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != "0") { if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != string.Empty) { string strfinancialId; decOpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); infoFinancialYear = BllFinancialYear.FinancialYearViewForAccountLedger(1); strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy"); infoLedgerPosting.VoucherTypeId = 1; infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString()); infoLedgerPosting.LedgerId = decLedgerId; infoLedgerPosting.VoucherNo = decLedgerId.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString() == "Dr") { infoLedgerPosting.Debit = decOpeningBalance; } else { infoLedgerPosting.Credit = decOpeningBalance; } infoLedgerPosting.DetailsId = 0; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = decLedgerId.ToString(); infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } isSave = true; } if (isSave) { Messages.SavedMessage(); cmbAccountGroup.Focus(); cmbAccountGroup.SelectedIndex = -1; dgvMultipleAccountLedger.Rows.Clear(); } else { } } catch (Exception ex) { MessageBox.Show("MAL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save account ledger /// </summary> public void SaveFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.LedgerName = txtLedgerName.Text.Trim(); infoAccountLedger.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString()); decOpeningBalance = Convert.ToDecimal(((txtOpeningBalance.Text == "") ? "0" : txtOpeningBalance.Text.Trim())); infoAccountLedger.OpeningBalance = decOpeningBalance; infoAccountLedger.CrOrDr = cmbOpeningBalanceCrOrDr.Text.Trim(); infoAccountLedger.Narration = txtNarration.Text.Trim(); infoAccountLedger.IsDefault = false; if (isBankAccount) { infoAccountLedger.BankAccountNumber = txtAcNo.Text.Trim(); infoAccountLedger.BranchName = txtBranchName.Text.Trim(); infoAccountLedger.BranchCode = txtBranchCode.Text.Trim(); } else { if (isSundryDebtorOrCreditor) { infoAccountLedger.BankAccountNumber = txtAccountNo.Text; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } else { infoAccountLedger.BankAccountNumber = string.Empty; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } } if (isSundryDebtorOrCreditor) { infoAccountLedger.MailingName = txtMailingName.Text.Trim(); infoAccountLedger.BankAccountNumber = txtAccountNo.Text.Trim(); infoAccountLedger.Address = txtAddress.Text.Trim(); infoAccountLedger.Phone = txtPhone.Text.Trim(); infoAccountLedger.Mobile = txtMobile.Text.Trim(); infoAccountLedger.Email = txtEmail.Text.Trim(); infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim()); infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.Trim()); if (cmbPricingLevel.SelectedIndex <= 0) { infoAccountLedger.PricinglevelId = 1; } else { infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } if (cmbBillByBill.Text == "Yes") { infoAccountLedger.BillByBill = true; } else { infoAccountLedger.BillByBill = false; } infoAccountLedger.Tin = txtTin.Text.Trim(); infoAccountLedger.Cst = txtCst.Text.Trim(); infoAccountLedger.Pan = txtPan.Text.Trim(); if (cmbArea.SelectedIndex <= 0) { infoAccountLedger.AreaId = 1; } else { infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); } if (cmbRoute.SelectedIndex < 0) { infoAccountLedger.RouteId = 1; } else { infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString()); } infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; } else { infoAccountLedger.MailingName = string.Empty; infoAccountLedger.BankAccountNumber = string.Empty; infoAccountLedger.Address = string.Empty; infoAccountLedger.State = string.Empty; infoAccountLedger.Phone = string.Empty; infoAccountLedger.Mobile = string.Empty; infoAccountLedger.Email = string.Empty; infoAccountLedger.CreditPeriod = 0; infoAccountLedger.CreditLimit = 0; infoAccountLedger.PricinglevelId = 0; infoAccountLedger.BillByBill = false; infoAccountLedger.Tin = string.Empty; infoAccountLedger.Cst = string.Empty; infoAccountLedger.Pan = string.Empty; infoAccountLedger.RouteId = 1; infoAccountLedger.AreaId = 1; infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; } if (bllAccountLedger.AccountLedgerCheckExistence(txtLedgerName.Text.Trim().ToString(), 0) == false) { decLedgerId = bllAccountLedger.AccountLedgerAddWithIdentity(infoAccountLedger); if (decOpeningBalance > 0) { LedgerPostingAdd(); if (cmbBillByBill.Text == "Yes" && isSundryDebtorOrCreditor) { PartyBalanceAdd(); } } Messages.SavedMessage(); Clear(); decIdForOtherForms = decLedgerId; if (frmRejectionInObj != null) { this.Close(); } if (frmMaterialReceptObj != null) { this.Close(); } if (frmPurchaseInvoiceObj != null) { this.Close(); } if (frmContraVoucherObj != null) { this.Close(); } if (frmPaymentVoucherObj != null) { this.Close(); } if (frmReceiptVoucherObj != null) { this.Close(); } if (frmDailysalaryvoucherobj != null) { this.Close(); } /*------------------For ReceiptVoucher--------------------*/ if (frmReceiptVoucherObj != null) { this.Close(); } if (frmPurchaseOrderObj != null) { this.Close(); } /*----------For journal voucher------------*/ if (frmJournalVoucherObj != null) { this.Close(); } /*----------For Debitnote voucher-----------*/ if (frmDebitNoteObj != null) { this.Close(); } /*----------For Creditnote voucher-----------*/ if (frmCreditNoteObj != null) { this.Close(); } if (frmSalesReturnObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmSalesInvoiceObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmSalesQuotationObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmSalesOrderObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } /*---------- For Pdcpayable voucher-----------*/ if (frmPdcpayableObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmPdcpayableObj2 != null) { if (decIdForOtherForms != 0) { this.Close(); } } /*---------- Coded For PdcReceivable voucher-----------*/ if (frmpdcreceivableObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmpdcreceivableObj2 != null) { if (decIdForOtherForms != 0) { this.Close(); } } /*.................end.......................*/ if (frmPOSObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } } else { Messages.InformationMessage("Ledger name already exist"); txtLedgerName.Focus(); } } catch (Exception ex) { MessageBox.Show("AL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print function for Dotmatrix Printer /// </summary> /// <param name="decMasterId"></param> public void PrintForDotMatrix(decimal decMasterId) { try { DataTable dtblOtherDetails = new DataTable(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); dtblOtherDetails = bllCompanyCreation.CompanyViewForDotMatrix(); DataTable dtblGridDetails = new DataTable(); dtblGridDetails.Columns.Add("SlNo"); dtblGridDetails.Columns.Add("BankAccount"); dtblGridDetails.Columns.Add("ChequeNo"); dtblGridDetails.Columns.Add("ChequeDate"); dtblGridDetails.Columns.Add("Amount"); DataRow dr = dtblGridDetails.NewRow(); dr["SlNo"] = 1; dr["ChequeNo"] = txtcheckNo.Text; dr["BankAccount"] = cmbBank.Text; dr["ChequeDate"] = txtCheckDate.Text; dr["Amount"] = txtAmount.Text; dtblGridDetails.Rows.Add(dr); dtblOtherDetails.Columns.Add("voucherNo"); dtblOtherDetails.Columns.Add("date"); dtblOtherDetails.Columns.Add("ledgerName"); dtblOtherDetails.Columns.Add("Narration"); dtblOtherDetails.Columns.Add("TotalAmount"); dtblOtherDetails.Columns.Add("AmountInWords"); dtblOtherDetails.Columns.Add("Declaration"); dtblOtherDetails.Columns.Add("Heading1"); dtblOtherDetails.Columns.Add("Heading2"); dtblOtherDetails.Columns.Add("Heading3"); dtblOtherDetails.Columns.Add("Heading4"); dtblOtherDetails.Columns.Add("CustomerAddress"); DataRow dRowOther = dtblOtherDetails.Rows[0]; dRowOther["voucherNo"] = txtVoucherNo.Text; dRowOther["date"] = txtVoucherDate.Text; dRowOther["ledgerName"] = cmbAccountLedger.Text; dRowOther["Narration"] = txtNarration.Text; dRowOther["TotalAmount"] = txtAmount.Text; dRowOther["address"] = (dtblOtherDetails.Rows[0]["address"].ToString().Replace("\n", ", ")).Replace("\r", ""); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); infoAccountLedger = bllAccountLedger.AccountLedgerView(Convert.ToDecimal(cmbAccountLedger.SelectedValue)); dRowOther["CustomerAddress"] = (infoAccountLedger.Address.ToString().Replace("\n", ", ")).Replace("\r", ""); string s = new NumToText().AmountWords(Convert.ToDecimal(txtAmount.Text), PublicVariables._decCurrencyId); dRowOther["AmountInWords"] = new NumToText().AmountWords(Convert.ToDecimal(txtAmount.Text), PublicVariables._decCurrencyId); VoucherTypeBll BllVOucherType = new VoucherTypeBll(); DataTable dtblDeclaration = BllVOucherType.DeclarationAndHeadingGetByVoucherTypeId(decPDCReceivableVoucherTypeId); dRowOther["Declaration"] = dtblDeclaration.Rows[0]["Declaration"].ToString(); dRowOther["Heading1"] = dtblDeclaration.Rows[0]["Heading1"].ToString(); dRowOther["Heading2"] = dtblDeclaration.Rows[0]["Heading2"].ToString(); dRowOther["Heading3"] = dtblDeclaration.Rows[0]["Heading3"].ToString(); dRowOther["Heading4"] = dtblDeclaration.Rows[0]["Heading4"].ToString(); int inFormId = BllVOucherType.FormIdGetForPrinterSettings(Convert.ToInt32(dtblDeclaration.Rows[0]["masterId"].ToString())); PrintWorks.DotMatrixPrint.PrintDesign(inFormId, dtblOtherDetails, dtblGridDetails, dtblOtherDetails); } catch (Exception ex) { MessageBox.Show("PR22:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Save and Edit /// </summary> public void SaveOrEdit() { try { PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll(); PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll(); PurchaseReturnDetailsInfo infoPurchaseReturnDetails = new PurchaseReturnDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); //StockPostingSP spStockPosting = new StockPostingSP(); StockPostingBll BllStockPosting = new StockPostingBll(); UnitConvertionBll BllUnitConvertion = new UnitConvertionBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); PurchaseReturnBilltaxInfo infoPurchaseReturnBillTax = new PurchaseReturnBilltaxInfo(); SettingsBll BllSettings = new SettingsBll(); UnitBll bllUnit = new UnitBll(); List<DataTable> ListObj = new List<DataTable>(); string strAgainstVoucherNo = string.Empty; string strAgainstInvoiceNo = string.Empty; decimal decPurchaseReturnMasterIds = 0; decimal decPurchaseMasterId = 0; decimal decDiscount = 0; decimal decExchangeRate = 0; decimal decDis = 0; if (isAutomatic) { if (strVoucherNo != string.Empty) { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; } if (txtReturnNo.Text != string.Empty) { infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } } else { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } if (decPurchaseReturnVoucherTypeId != 0) { infoPurchaseReturnMaster.VoucherTypeId = decPurchaseReturnVoucherTypeId; } infoPurchaseReturnMaster.SuffixPrefixId = (decPurchaseReturnSuffixPrefixId != 0) ? decPurchaseReturnSuffixPrefixId : 0; infoPurchaseReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPurchaseReturnMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString()); if (cmbInvoiceNo.SelectedValue != null && cmbInvoiceNo.Visible == true) { infoPurchaseReturnMaster.PurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); decPurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); } else { infoPurchaseReturnMaster.PurchaseMasterId = 0; } infoPurchaseReturnMaster.ExchangeRateId = (cmbCurrency.SelectedValue != null) ? Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()) : 0; infoPurchaseReturnMaster.Narration = txtNarration.Text.Trim(); infoPurchaseReturnMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseReturnMaster.LrNo = txtLrlNo.Text.Trim(); infoPurchaseReturnMaster.TransportationCompany = txtTransportationCompany.Text.Trim(); infoPurchaseReturnMaster.Date = Convert.ToDateTime(txtDate.Text); infoPurchaseReturnMaster.TotalAmount = (txtTotalAmount.Text != string.Empty) ? Convert.ToDecimal(txtTotalAmount.Text) : 0; infoPurchaseReturnMaster.TotalTax = (lblTaxAmount.Text != string.Empty) ? Convert.ToDecimal(lblTaxAmount.Text) : 0; infoPurchaseReturnMaster.Discount = (txtBillDiscount.Text != string.Empty) ? Convert.ToDecimal(txtBillDiscount.Text) : 0; infoPurchaseReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseReturnMaster.Extra1 = string.Empty; infoPurchaseReturnMaster.Extra2 = string.Empty; infoPurchaseReturnMaster.ExtraDate = DateTime.Now; infoPurchaseReturnMaster.GrandTotal = (txtGrandTotal.Text != string.Empty) ? Convert.ToDecimal(txtGrandTotal.Text) : 0; if (btnSave.Text == "Save") { decPurchaseReturnMasterIds = BllPurchaseReturn.PurchaseReturnMasterAddWithReturnIdentity(infoPurchaseReturnMaster); } else { infoPurchaseReturnMaster.PurchaseReturnMasterId = decPurchaseReturnMasterId; decExchangeRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(infoPurchaseReturnMaster.ExchangeRateId); BllPurchaseReturn.PurchaseReturnMasterEdit(infoPurchaseReturnMaster); infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); BllLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseReturnVoucherTypeId); bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseReturnVoucherTypeId); } infoLedgerPosting.Date = infoPurchaseReturnMaster.Date; infoLedgerPosting.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoLedgerPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.PurchaseAccount; infoLedgerPosting.Debit = 0; if (btnSave.Text == "Save") { infoLedgerPosting.Credit = TotalNetAmountCalculation() * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Credit = TotalNetAmountCalculation(); } BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.LedgerId; if (btnSave.Text == "Save") { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text) * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text); } infoLedgerPosting.Credit = 0; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvPurchaseReturnTax.Rows) { if (dgvrow.Cells["dgvtxtTaxId"].Value != null && dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty) { infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtledgerId"].Value.ToString()); infoLedgerPosting.Credit = (dgvrow.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(dgvrow.Cells["dgvtxtAmounts"].Value.ToString()); infoLedgerPosting.Debit = 0; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } if (txtBillDiscount.Text.Trim() != string.Empty) { decDis = Convert.ToDecimal(txtBillDiscount.Text); } if (decDis >= 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decDis; infoLedgerPosting.LedgerId = 9; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } if (btnSave.Text == "Update") { infoPurchaseReturnMaster = BllPurchaseReturn.PurchaseReturnMasterView(decPurchaseReturnMasterId); if (infoPurchaseReturnMaster.PurchaseMasterId == 0) { BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", infoPurchaseReturnMaster.VoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } if (infoPurchaseReturnMaster.PurchaseMasterId != 0) { infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(infoPurchaseMaster.VoucherTypeId, strInvoiceNo, strVoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } } foreach (DataGridViewRow dgvrow in dgvPurchaseReturn.Rows) { if (dgvrow.Cells["dgvtxtProductId"].Value != null && dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { infoPurchaseReturnDetails.ExtraDate = DateTime.Now; infoPurchaseReturnDetails.Extra1 = string.Empty; infoPurchaseReturnDetails.Extra2 = string.Empty; infoPurchaseReturnDetails.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterId; infoPurchaseReturnDetails.ProductId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtproductId"].Value)); infoPurchaseReturnDetails.Qty = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtqty"].Value)); infoPurchaseReturnDetails.Rate = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtrate"].Value)); if (btnSave.Text == "Save") { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); infoPurchaseReturnDetails.UnitConversionId = BllUnitConvertion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { if (Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value) == 0) { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = bllUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } infoPurchaseReturnDetails.UnitConversionId = BllUnitConvertion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = bllUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } } infoPurchaseReturnDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value); } infoPurchaseReturnDetails.Discount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtdiscount"].Value)); if (dgvrow.Cells["dgvcmbTax"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value) != string.Empty && dgvrow.Cells["dgvcmbTax"].Value as string != "NA") { infoPurchaseReturnDetails.TaxId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value)); if (strTaxComboFill != string.Empty) { infoPurchaseReturnDetails.TaxAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtTaxAmount"].Value)); } } else { infoPurchaseReturnDetails.TaxId = 0; } if (dgvrow.Cells["dgvcmbBatch"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbBatch"].Value) != string.Empty) { infoPurchaseReturnDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value); } else { infoPurchaseReturnDetails.GodownId = 0; } if (dgvrow.Cells["dgvcmbGodown"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbGodown"].Value) != string.Empty) { infoPurchaseReturnDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value); } else { infoPurchaseReturnDetails.RackId = 0; } if (dgvrow.Cells["dgvcmbRack"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbRack"].Value) != string.Empty) { infoPurchaseReturnDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value); } infoPurchaseReturnDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtgrossValue"].Value.ToString()); infoPurchaseReturnDetails.NetAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtNetAmount"].Value)); infoPurchaseReturnDetails.Amount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtAmount"].Value)); infoPurchaseReturnDetails.SlNo = Convert.ToInt32(Convert.ToString(dgvrow.Cells["dgvtxtSlNo"].Value)); infoPurchaseReturnDetails.PurchaseDetailsId = (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) ? Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value)) : 0; if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == "0" || dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == string.Empty) { BllPurchaseReturn.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } else { infoPurchaseReturnDetails.PurchaseReturnDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString()); BllPurchaseReturn.PurchaseReturnDetailsEdit(infoPurchaseReturnDetails); } } else { BllPurchaseReturn.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } if (btnSave.Text == "Save") { infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); } infoStockPosting.Date = infoPurchaseReturnMaster.Date; infoStockPosting.ProductId = infoPurchaseReturnDetails.ProductId; infoStockPosting.BatchId = infoPurchaseReturnDetails.BatchId; infoStockPosting.UnitId = infoPurchaseReturnDetails.UnitId; infoStockPosting.GodownId = infoPurchaseReturnDetails.GodownId; infoStockPosting.RackId = infoPurchaseReturnDetails.RackId; decimal decConversionId = BllUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseReturnDetails.UnitConversionId); //infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty / (decConversionId == 0 ? 1 : decConversionId); infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty; infoStockPosting.InwardQty = 0; infoStockPosting.Rate = infoPurchaseReturnDetails.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (infoPurchaseReturnDetails.PurchaseDetailsId != 0) { infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = txtReturnNo.Text.Trim(); infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId; } else { infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoStockPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = 0; } BllStockPosting.StockPostingAdd(infoStockPosting); } } if (btnSave.Text == "Update") { removePurchaseReturnDetails(); } infoAccountLedger = bllAccountLedger.AccountLedgerView(infoPurchaseReturnMaster.LedgerId); if (infoAccountLedger.BillByBill == true) { infoPartyBalance.Date = infoPurchaseReturnMaster.Date; infoPartyBalance.LedgerId = infoPurchaseReturnMaster.LedgerId; if (decAgainstVoucherTypeId != 0) { infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.AgainstVoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.AgainstInvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.ReferenceType = "Against"; } else { infoPartyBalance.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.ReferenceType = "New"; } infoPartyBalance.Debit = infoPurchaseReturnMaster.TotalAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = 0; infoPartyBalance.ExchangeRateId = infoPurchaseReturnMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceAdd(infoPartyBalance); } foreach (DataGridViewRow item in dgvPurchaseReturnTax.Rows) { if (item.Cells["dgvtxtTaxId"].Value != null) { if (Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString()) > 0) { infoPurchaseReturnBillTax.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterIds; infoPurchaseReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvtxtTaxId"].Value.ToString()); infoPurchaseReturnBillTax.TaxAmount = (item.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString()); infoPurchaseReturnBillTax.Extra1 = string.Empty; infoPurchaseReturnBillTax.Extra2 = string.Empty; BllPurchaseReturn.PurchaseReturnBilltaxAdd(infoPurchaseReturnBillTax); } } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterIds); } else { Print(decPurchaseReturnMasterIds); } } Clear(); } else { decDiscount = Convert.ToDecimal(txtBillDiscount.Text); Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterId); } else { Print(decPurchaseReturnMasterId); } } if (frmPurchaseReturnRegisterObj != null) { frmPurchaseReturnRegisterObj.GridFill(); frmPurchaseReturnRegisterObj.Enabled = true; } if (ObjPurchaseReturnReport != null) { ObjPurchaseReturnReport.PurchaseReturnReportGridFill(); ObjPurchaseReturnReport.Enabled = true; } if (frmLedgerDetailsObj != null) { frmLedgerDetailsObj.LedgerDetailsView(); frmLedgerDetailsObj.Enabled = true; } this.Close(); } } catch (Exception ex) { MessageBox.Show("PR:49" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void cmbCashParty_SelectedIndexChanged(object sender, EventArgs e) { try { AccountLedgerInfo InfoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (cmbCashParty.SelectedValue.ToString() != "System.Data.DataRowView" && cmbCashParty.Text != "System.Data.DataRowView") { InfoAccountLedger = bllAccountLedger.accountLedgerviewbyId(Convert.ToDecimal(cmbCashParty.SelectedValue.ToString())); txtCustomer.Text = InfoAccountLedger.LedgerName; txtCreditPeriod.Text = InfoAccountLedger.CreditPeriod.ToString(); } } catch (Exception ex) { MessageBox.Show("SV 63 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Account ledger combobox while return from ledger creation when creating new ledger /// </summary> /// <param name="decId"></param> public void ReturnFromAccountLedgerForm(decimal decLedgerId) { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); // RejectionInMasterSP spRejectionOutMaster = new RejectionInMasterSP(); DataTable dtbl = new DataTable(); try { CashOrPartyComboFill(); if (decLedgerId.ToString() != "0") { cmbCashOrParty.SelectedValue = decLedgerId; cmbCashOrParty.Focus(); } else if (strCashOrParty != string.Empty) { cmbCashOrParty.SelectedItem = strCashOrParty; cmbCashOrParty.Focus(); } else { cmbCashOrParty.SelectedIndex = -1; } } catch (Exception ex) { MessageBox.Show("RO42:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }