/// <summary> /// Get Material Type By Id /// </summary> /// <param name="materialTypeId">Int32:materialTypeId</param> /// <returns></returns> public MaterialTypeDTO GetMaterialTypeById(int materialTypeId) { MaterialTypeDTO materialTypeDetails = new MaterialTypeDTO(); AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<materialtype>>() .GetSingle(item => item.MaterialType_Id == materialTypeId), materialTypeDetails); return materialTypeDetails; }
/// <summary> /// Save Material Type /// </summary> /// <param name="materialTypeDetails"></param> /// <returns></returns> public int SaveMaterialType(MaterialTypeDTO materialTypeDetails) { materialtype materialtypeEntity = new materialtype(); AutoMapper.Mapper.Map(materialTypeDetails, materialtypeEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<materialtype>>().Save(materialtypeEntity); IList<AgentDTO> listAgentDTO = ESalesUnityContainer.Container.Resolve<IAgentService>().GetAgentList(); AgentMaterialPercentageDTO objAgentMaterialPercentageDTO = new AgentMaterialPercentageDTO(); foreach (AgentDTO agent in listAgentDTO) { objAgentMaterialPercentageDTO.AMP_Agent_Id = agent.Agent_Id; objAgentMaterialPercentageDTO.AMP_MaterialType_Id = materialtypeEntity.MaterialType_Id; objAgentMaterialPercentageDTO.AMP_IsActive = true; objAgentMaterialPercentageDTO.AMP_CreatedBy = materialtypeEntity.MaterialType_CreatedBy; ESalesUnityContainer.Container.Resolve<IAgentMaterialPercentageService>() .SaveAgentMaterialPercentage(objAgentMaterialPercentageDTO); } return materialtypeEntity.MaterialType_Id; }
protected void grdMaterialType_RowUpdating(object sender, GridViewUpdateEventArgs e) { //To update material type MaterialTypeDTO materialTypeDetails = new MaterialTypeDTO(); materialTypeDetails = ESalesUnityContainer.Container.Resolve<IMaterialTypeService>() .GetMaterialTypeById(Convert.ToInt32(grdMaterialType.DataKeys[e.RowIndex].Value)); materialTypeDetails.MaterialType_Name = ((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtProductName")).Text; materialTypeDetails.MaterialType_Code = ((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtProductCode")).Text; materialTypeDetails.MaterialType_CSTRate = Convert.ToDecimal(((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtCSTRate")).Text); materialTypeDetails.MaterialType_EducationCess = Convert.ToDecimal(((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtEducationCess")).Text); materialTypeDetails.MaterialType_HigherEducationCess = Convert.ToDecimal(((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtHigherEducationCess")).Text); materialTypeDetails.MaterialType_HandlingRate = Convert.ToDecimal(((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtHandlingRate")).Text); materialTypeDetails.MaterialType_CFormRate = Convert.ToDecimal(((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtCFormRate")).Text); materialTypeDetails.MaterialType_TiscoRate = Convert.ToDecimal(((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtTiscoRate")).Text); materialTypeDetails.MaterialType_ServiceTax = Convert.ToDecimal(((TextBox)grdMaterialType.Rows[e.RowIndex].FindControl("txtServiceTax")).Text); materialTypeDetails.MaterialType_IsActive = ((CheckBox)grdMaterialType.Rows[e.RowIndex].FindControl("chkActive")).Checked; materialTypeDetails.MaterialType_LastUpdatedDate = DateTime.Now; int materialTypeId= ESalesUnityContainer.Container.Resolve<IMaterialTypeService>().UpdateMaterialType(materialTypeDetails); ucMessageBoxForGrid.ShowMessage(Messages.MaterialTypeUpdatedSuccessfully); }
private decimal GetAmount(decimal qty) { MaterialTypeDTO materialTypeDetails = new MaterialTypeDTO(); materialTypeDetails = ESalesUnityContainer.Container.Resolve<IMaterialTypeService>() .GetMaterialTypeById(Convert.ToInt32(ESalesUnityContainer.Container.Resolve<IMaterialTypeService>().GetMaterialTypeList(true)[0].MaterialType_Id)); decimal handlingRate = Convert.ToDecimal(qty) * Convert.ToDecimal(materialTypeDetails.MaterialType_HandlingRate); decimal tiscoRate = Convert.ToDecimal(qty) * Convert.ToDecimal(materialTypeDetails.MaterialType_TiscoRate); decimal grossAmount = handlingRate + tiscoRate; decimal serviceTax = handlingRate * (Convert.ToDecimal(materialTypeDetails.MaterialType_ServiceTax) / 100); decimal educationCess = serviceTax * (Convert.ToDecimal(materialTypeDetails.MaterialType_EducationCess) / 100); decimal higherEducationCess = serviceTax * (Convert.ToDecimal(materialTypeDetails.MaterialType_HigherEducationCess) / 100); decimal netAmount = grossAmount + serviceTax + educationCess + higherEducationCess; return netAmount; }
protected void grdMaterialType_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == Globals.GridCommandEvents.ADDNEW) { GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer); MaterialTypeDTO materialTypeDetails = new MaterialTypeDTO(); materialTypeDetails.MaterialType_Name = ((TextBox)row.FindControl("txtNewProductName")).Text; materialTypeDetails.MaterialType_Code = ((TextBox)row.FindControl("txtNewProductCode")).Text; materialTypeDetails.MaterialType_CSTRate = Convert.ToDecimal(((TextBox)row.FindControl("txtNewCSTRate")).Text); materialTypeDetails.MaterialType_EducationCess = Convert.ToDecimal(((TextBox)row.FindControl("txtNewEducationCess")).Text); materialTypeDetails.MaterialType_HigherEducationCess = Convert.ToDecimal(((TextBox)row.FindControl("txtNewHigherEducationCess")).Text); materialTypeDetails.MaterialType_HandlingRate = Convert.ToDecimal(((TextBox)row.FindControl("txtNewHandlingRate")).Text); materialTypeDetails.MaterialType_CFormRate = Convert.ToDecimal(((TextBox)row.FindControl("txtNewCFormRate")).Text); materialTypeDetails.MaterialType_TiscoRate = Convert.ToDecimal(((TextBox)row.FindControl("txtNewTiscoRate")).Text); materialTypeDetails.MaterialType_ServiceTax = Convert.ToDecimal(((TextBox)row.FindControl("txtNewServiceTax")).Text); materialTypeDetails.MaterialType_IsActive = ((CheckBox)row.FindControl("chkNewActive")).Checked; materialTypeDetails.MaterialType_CreatedBy = base.GetCurrentUserId(); materialTypeDetails.MaterialType_CreatedDate = DateTime.Now; int materialTypeId = ESalesUnityContainer.Container.Resolve<IMaterialTypeService>().SaveMaterialType(materialTypeDetails); ucMessageBoxForGrid.ShowMessage(Messages.MaterialTypeSavedSuccessfully); } }
/// <summary> /// Update Material Type /// </summary> /// <param name="materialTypeDetails"></param> /// <returns></returns> public int UpdateMaterialType(MaterialTypeDTO materialTypeDetails) { materialtype materialtypeEntity = new materialtype(); materialtype_history materialtypehistoryEntity = new materialtype_history(); int materialid; using (TransactionScope transactionScope = new TransactionScope()) { AutoMapper.Mapper.Map(materialTypeDetails, materialtypeEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<materialtype>>().Update(materialtypeEntity); materialid = materialTypeDetails.MaterialType_Id; materialTypeDetails.MaterialType_Id = 0; AutoMapper.Mapper.Map(materialTypeDetails, materialtypehistoryEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<materialtype_history>>().Save(materialtypehistoryEntity); transactionScope.Complete(); } return materialid; }
/// <summary> /// Delete Material Type by materialTypeId /// </summary> /// <param name="materialTypeId">Int32:materialTypeId</param> public void DeleteMaterialType(int materialTypeId) { using (TransactionScope transactionScope = new TransactionScope()) { MaterialTypeDTO materialTypeDetails = new MaterialTypeDTO(); materialTypeDetails = ESalesUnityContainer.Container.Resolve<IMaterialTypeService>() .GetMaterialTypeById(materialTypeId); materialTypeDetails.MaterialType_IsDeleted = true; UpdateMaterialType(materialTypeDetails); AgentMaterialPercentageService agentMatPercentageService = new AgentMaterialPercentageService(); IList<AgentMaterialPercentageDTO> lstAgentMaterialPercentage = agentMatPercentageService .GetAgentMaterialPercentByMaterialTypeId(materialTypeId); foreach (var percent in lstAgentMaterialPercentage) { AgentMaterialPercentageDTO agentMaterialPercentage = agentMatPercentageService .GetAgentMaterialPercentageByAMPId(percent.AMP_Id); agentMaterialPercentage.AMP_IsDeleted = true; ESalesUnityContainer.Container.Resolve<IAgentMaterialPercentageService>() .UpdateAgentPercentage(agentMaterialPercentage); } transactionScope.Complete(); } }