public bool SaveTax(TaxModel taxModel, TaxSiteMappingModel taxSiteMapModel, TaxSiteDocMapModel taxSiteDocMapModel) { taxModel.ToAddOrModifyEntity(true); taxSiteMapModel.ToAddOrModifyEntity(true); taxSiteDocMapModel.ToAddOrModifyEntity(true); var tax = Mapper.Map(taxModel, new MstTax()); var taxSiteMap = Mapper.Map(taxSiteMapModel, new TaxSiteMapping()); var taxSiteDocMap = Mapper.Map(taxSiteDocMapModel, new TaxSiteDocMap()); return(this.taxRepository.SaveTax(tax, taxSiteMap, taxSiteDocMap)); }
private void btnSave_Click(object sender, System.EventArgs e) { try { if (ValidateTax()) { TaxModel taxdata = new TaxModel(); TaxSiteMappingModel taxSiteMap = new TaxSiteMappingModel(); TaxSiteDocMapModel taxsitedoc = new TaxSiteDocMapModel(); taxdata.TaxName = txtTaxName.Text; if (rdoTaxInclusive.Checked == true) { taxdata.Inclusive = true; taxsitedoc.Inclusive = true; } else { taxdata.Inclusive = false; taxsitedoc.Inclusive = false; } if (rdoTVTPercent.Checked == true) { taxdata.Type = "Per"; taxsitedoc.IsPercentageValue = true; } else { taxdata.Type = "Val"; taxsitedoc.IsPercentageValue = false; } if (chkInterStateTax.Checked == true) { taxdata.InterStateTax = true; } else { taxdata.InterStateTax = false; } taxdata.TaxSeqProfile = "A"; taxdata.Value = Convert.ToDecimal(txtTaxValue.Text); taxsitedoc.TaxValue = Convert.ToDecimal(txtTaxValue.Text); taxdata.UpdatedAt = CommonModel.SiteCode; taxdata.UpdatedBy = CommonModel.UserID; bool Status = false; if (flag == true && taxCode != "") { Dupdoc = cmbDocumentType.SelectedValue.ToString(); // taxName = txtTaxName.Text; bool Duplicate = false; taxdata.TaxCode = taxCode; taxsitedoc.TaxCode = taxCode; taxsitedoc.DocumentType = cmbDocumentType.SelectedValue.ToString(); taxsitedoc.UpdatedAt = CommonModel.SiteCode; taxsitedoc.UpdatedBy = CommonModel.UserID; taxsitedoc.TaxName = txtTaxName.Text; taxsitedoc.SiteCode = CommonModel.SiteCode; taxsitedoc.IsDocumentLevelTax = false; taxsitedoc.Appliedon = cmbAppliedon.SelectedValue.ToString(); Duplicate = this.taxManager.DuplicateRecords(taxName, Dupdoc, taxCode); //if (taxsitedoc.DocumentType != doc) //{ // Status = this.taxManager.UpdateTax(taxdata, taxsitedoc); // if (Status == true) // CommonFunc.ShowMessage("Tax " + taxCode + " Updated Successfully.", MessageType.Information); // else // CommonFunc.ShowMessage("Error!!!", MessageType.Information); //} if (Duplicate == false) { Status = this.taxManager.UpdateTax(taxdata, taxsitedoc); CommonFunc.ShowMessage("Tax " + taxCode + " Updated Successfully.", MessageType.Information); } else { Status = this.taxManager.UpdateTaxDoc(taxdata, taxsitedoc); CommonFunc.ShowMessage("Tax " + taxCode + " Updated Successfully.", MessageType.Information); } } else { string newtaxcode = GetTaxCode("C"); taxdata.TaxCode = newtaxcode; taxSiteMap.Taxcode = newtaxcode; taxSiteMap.Sitecode = CommonModel.SiteCode; taxSiteMap.Defaultsite = false; taxsitedoc.TaxCode = newtaxcode; taxsitedoc.SiteCode = CommonModel.SiteCode; taxsitedoc.DocumentType = cmbDocumentType.SelectedValue.ToString(); taxsitedoc.Appliedon = cmbAppliedon.SelectedValue.ToString(); taxsitedoc.TaxName = txtTaxName.Text; taxsitedoc.IsDocumentLevelTax = false; Status = this.taxManager.SaveTax(taxdata, taxSiteMap, taxsitedoc); if (Status == true) { this.commonManager.UpdateNextID(CommonModel.SiteCode, "TX"); CommonFunc.ShowMessage("Tax " + newtaxcode + " Added Successfully.", MessageType.Information); } else { CommonFunc.ShowMessage("Error!!!", MessageType.Information); } } Fillgrid(); clearForm(); } } catch (System.Exception ex) { CommonFunc.ShowMessage(ex.Message, MessageType.Information); Logger.Log(ex.Message, Logger.LogingLevel.Error); } finally { } }