public void TaxDetailsEdit(TaxDetailsInfo taxdetailsinfo) { try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("TaxDetailsEdit", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam7 = new SqlParameter(); sprmparam7 = sccmd.Parameters.Add("@taxdetailsId", SqlDbType.Decimal); sprmparam7.Value = taxdetailsinfo.TaxdetailsId; sprmparam7 = sccmd.Parameters.Add("@taxId", SqlDbType.Decimal); sprmparam7.Value = taxdetailsinfo.TaxId; sprmparam7 = sccmd.Parameters.Add("@selectedtaxId", SqlDbType.Decimal); sprmparam7.Value = taxdetailsinfo.SelectedtaxId; sprmparam7 = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam7.Value = taxdetailsinfo.ExtraDate; sprmparam7 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam7.Value = taxdetailsinfo.Extra1; sprmparam7 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam7.Value = taxdetailsinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } }
/// <summary> /// Function to Update values in TaxDetails Table /// </summary> /// <param name="taxdetailsinfo"></param> public void TaxDetailsEdit(TaxDetailsInfo infoTaxDetails) { try { spTaxDetails.TaxDetailsEdit(infoTaxDetails); } catch (Exception ex) { MessageBox.Show("TBLL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from TaxDetails Table based on the parameter /// </summary> /// <param name="taxdetailsId"></param> /// <returns></returns> public TaxDetailsInfo TaxDetailsView(decimal decTaxDetailsId) { TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); try { infoTaxDetails = spTaxDetails.TaxDetailsView(decTaxDetailsId); } catch (Exception ex) { MessageBox.Show("TBLL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(infoTaxDetails); }
public TaxDetailsInfo TaxDetailsView(decimal taxdetailsId) { TaxDetailsInfo taxdetailsinfo = new TaxDetailsInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("TaxDetailsView", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam2 = new SqlParameter(); sprmparam2 = sccmd.Parameters.Add("@taxdetailsId", SqlDbType.Decimal); sprmparam2.Value = taxdetailsId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { taxdetailsinfo.TaxdetailsId = decimal.Parse(((DbDataReader)sdrreader)[0].ToString()); taxdetailsinfo.TaxId = decimal.Parse(((DbDataReader)sdrreader)[1].ToString()); taxdetailsinfo.SelectedtaxId = decimal.Parse(((DbDataReader)sdrreader)[2].ToString()); taxdetailsinfo.ExtraDate = DateTime.Parse(((DbDataReader)sdrreader)[3].ToString()); taxdetailsinfo.Extra1 = ((DbDataReader)sdrreader)[4].ToString(); taxdetailsinfo.Extra2 = ((DbDataReader)sdrreader)[5].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(taxdetailsinfo); }
/// <summary> /// fill the curresponding details for update /// </summary> public void TaxSelectionFillForUpdate() { try { int inRowCount = dgvTaxSelection.RowCount; for (int i = 0; i < inRowCount; i++) { dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = false; } decTaxId = Convert.ToDecimal(dgvTaxSearch.CurrentRow.Cells["dgvtxtTaxIdSearch"].Value.ToString()); TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); infoTax = bllTax.TaxView(decTaxId); txtTaxName.Text = infoTax.TaxName; txtRate.Text = infoTax.Rate.ToString(); cmbApplicableFor.Text = infoTax.ApplicableOn; cmbCalculationMode.Text = infoTax.CalculatingMode; txtNarration.Text = infoTax.Narration; if (infoTax.IsActive.ToString() == "True") { cbxActive.Checked = true; } else { cbxActive.Checked = false; } strTaxName = infoTax.TaxName; decTaxIdForEdit = infoTax.TaxId; btnSave.Text = "Update"; btnDelete.Enabled = true; List<DataTable> ListObj = new List<DataTable>(); ListObj = bllTax.TaxIdForTaxSelectionUpdate(decTaxId); foreach (DataRow dr in ListObj[0].Rows) { string strTaxId = dr["selectedtaxId"].ToString(); for (int i = 0; i < inRowCount; i++) { if (dgvTaxSelection.Rows[i].Cells["dgvtxtTaxId"].Value.ToString() == strTaxId) { dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = true; } } } AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decLedgerId = bllAccountLedger.AccountLedgerIdGetByName(txtTaxName.Text); } catch (Exception ex) { MessageBox.Show("TC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// save function /// </summary> public void SaveFunction() { try { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); infoTax.TaxName = txtTaxName.Text.Trim(); infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString()); infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString(); if (cmbCalculationMode.Enabled != true) { infoTax.CalculatingMode = string.Empty; } else { infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString(); } infoTax.Narration = txtNarration.Text.Trim(); if (cbxActive.Checked) { infoTax.IsActive = true; } else { infoTax.IsActive = false; } infoTax.Extra1 = string.Empty; infoTax.Extra2 = string.Empty; if (bllTax.TaxCheckExistence(0, txtTaxName.Text.Trim()) == false) { decTaxId = bllTax.TaxAddWithIdentity(infoTax); decIdForOtherForms = decTaxId; if (dgvTaxSelection.RowCount > 0) { bool isOk = false; foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows) { isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value); if (isOk) { infoTaxDetails.TaxId = decTaxId; infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString(); infoTaxDetails.ExtraDate = DateTime.Now; infoTaxDetails.Extra1 = string.Empty; infoTaxDetails.Extra2 = string.Empty; bllTax.TaxDetailsAddWithoutId(infoTaxDetails); } } } CreateLedger(); Messages.SavedMessage(); Clear(); SearchClear(); } else { Messages.InformationMessage(" Tax or ledger already exist"); txtTaxName.Focus(); } if (frmProductCreationObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("TC4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// update function /// </summary> public void EditFunction() { try { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); infoTax.TaxName = txtTaxName.Text.Trim(); infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString()); infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString(); if (cmbCalculationMode.Enabled != true) { infoTax.CalculatingMode = string.Empty; } else { infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString(); } infoTax.Narration = txtNarration.Text.Trim(); if (cbxActive.Checked) { infoTax.IsActive = true; } else { infoTax.IsActive = false; } infoTax.Extra1 = string.Empty; infoTax.Extra2 = string.Empty; if (txtTaxName.Text.ToString() != strTaxName) { if (bllTax.TaxCheckExistence(decTaxIdForEdit, txtTaxName.Text.Trim()) == false) { infoTax.TaxId = decTaxId; bllTax.TaxEdit(infoTax); //-- Delete And Add Tax details --// bllTax.TaxDetailsDeleteWithTaxId(decTaxId); if (dgvTaxSelection.RowCount > 0) { bool isOk = false; foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows) { isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value); if (isOk) { infoTaxDetails.TaxId = decTaxId; infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString(); infoTaxDetails.ExtraDate = DateTime.Now; infoTaxDetails.Extra1 = string.Empty; infoTaxDetails.Extra2 = string.Empty; bllTax.TaxDetailsAddWithoutId(infoTaxDetails); } } } LedgerEdit(); Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage(" Tax or ledger already exist"); txtTaxName.Focus(); } } else { infoTax.TaxId = decTaxId; bllTax.TaxEdit(infoTax); bllTax.TaxDetailsDeleteWithTaxId(decTaxId); if (dgvTaxSelection.RowCount > 0) { bool isOk = false; foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows) { isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value); if (isOk) { infoTaxDetails.TaxId = decTaxId; infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString(); infoTaxDetails.ExtraDate = DateTime.Now; infoTaxDetails.Extra1 = string.Empty; infoTaxDetails.Extra2 = string.Empty; bllTax.TaxDetailsAddWithoutId(infoTaxDetails); } } } LedgerEdit(); Messages.UpdatedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("TC5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// delete function /// </summary> public void Delete() { try { if (PublicVariables.isMessageDelete) { if (Messages.DeleteMessage()) { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); bool isExist = bllTax.TaxReferenceCheck(decTaxId); if (!isExist) { if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1) { Messages.ReferenceExistsMessage(); } else { bllTax.TaxDetailsDeleteWithTaxId(decTaxId); bllAccountLedger.AccountLedgerDelete(decLedgerId); Messages.DeletedMessage(); TaxSearchGridFill(); TaxSelectionGridFill(); Clear(); SearchClear(); } } else { Messages.ReferenceExistsMessage(); } } } else { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); bool isExist = bllTax.TaxReferenceCheck(decTaxId); if (!isExist) { if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1) { Messages.ReferenceExistsMessage(); } else { bllTax.TaxDetailsDeleteWithTaxId(decTaxId); Messages.DeletedMessage(); TaxSearchGridFill(); TaxSelectionGridFill(); Clear(); SearchClear(); } } else { Messages.ReferenceExistsMessage(); } } } catch (Exception ex) { MessageBox.Show("TC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }