public bool Delete(MST_FEE data) { try { unitOfWork.FeeRepository.Delete(data); unitOfWork.Save(); return(true); } catch (Exception ex) { return(false); } }
protected void lkbFeeSave_Click(object sender, EventArgs e) { try { if (txtFeeText.Text.Trim() == "") { txtFeeText.ForeColor = Color.Red; txtFeeText.BorderColor = Color.Red; txtFeeText.Focus(); return; } if (ddlFeeDuration.SelectedIndex > -1) { MST_FEE obj = new MST_FEE(); obj.FeeName = txtFeeText.Text.Trim(); obj.UserId = cls_Common.UserProfile.Id; obj.Org_ID = cls_Common.UserProfile.ORG_ID; EnumConstants.FeeDuration duration = (EnumConstants.FeeDuration)Enum.Parse(typeof(EnumConstants.FeeDuration), ddlFeeDuration.SelectedValue); List <MST_FEE_TERM> terms = new List <MST_FEE_TERM>(); if (ddlFeeDuration.SelectedItem.Text == EnumConstants.FeeDuration.Monthly.ToString() || ddlFeeDuration.SelectedItem.Text == EnumConstants.FeeDuration.Quartly.ToString() || ddlFeeDuration.SelectedItem.Text == EnumConstants.FeeDuration.HalfYearly.ToString()) { int countIsSelect = 0; if (cbTerm.Items.Count > 0) { foreach (ListItem item in cbTerm.Items) { MST_FEE_TERM term = new MST_FEE_TERM(); if (ddlFeeDuration.SelectedValue == ((byte)EnumConstants.FeeDuration.Monthly).ToString()) { if (item.Selected) { EnumConstants.MonthName fD = (EnumConstants.MonthName)Enum.Parse(typeof(EnumConstants.MonthName), item.Value); term.FeeTerm = (byte)fD; terms.Add(term); countIsSelect++; } } else if (ddlFeeDuration.SelectedValue == ((byte)EnumConstants.FeeDuration.Quartly).ToString()) { if (item.Selected) { EnumConstants.Quaterly fD = (EnumConstants.Quaterly)Enum.Parse(typeof(EnumConstants.Quaterly), item.Value); term.FeeTerm = (byte)fD; terms.Add(term); countIsSelect++; } } else if (ddlFeeDuration.SelectedValue == ((byte)EnumConstants.FeeDuration.HalfYearly).ToString()) { if (item.Selected) { EnumConstants.HalfYearly fD = (EnumConstants.HalfYearly)Enum.Parse(typeof(EnumConstants.HalfYearly), item.Value); term.FeeTerm = (byte)fD; terms.Add(term); countIsSelect++; } } } } if (countIsSelect == 0 || cbTerm.Items.Count < 1) { uc_sucess3.VisibleError = true; uc_sucess3.ErrorMessage = "Kindly Select at least one term.."; return; } } if (ddlFeeDuration.SelectedItem.Text == EnumConstants.FeeDuration.Anually.ToString()) { terms.Add(new MST_FEE_TERM { FeeTerm = 1 }); } else if (ddlFeeDuration.SelectedItem.Text == EnumConstants.FeeDuration.OneTime.ToString()) { terms.Add(new MST_FEE_TERM { FeeTerm = 1 }); } obj.MST_FEE_TERM = terms; obj.FeeDuration = (byte)duration; obj.CreatedBy = cls_Common.UserProfile.Id; obj.CreatedDate = DateTime.Now; feeDTO.Save(obj); uc_sucess3.Visible = true; uc_sucess3.SuccessMessage = "Data Saved Successfully."; txtFeeText.Text = ""; BindFee(); cbTerm.Items.Clear(); ddlFeeDuration.SelectedIndex = -1; txtFeeText.BorderColor = ddlFeeDuration.BorderColor; txtFeeText.ForeColor = ddlFeeDuration.ForeColor; } } catch (Exception ex) { } }