Example #1
0
        private bool AddBeneficiaryType()
        {
            try
            {
                var newBeneficiaryType = new BeneficiaryType
                {
                    Name   = txtName.Text.Trim(),
                    Status = chkBeneficiaryType.Checked ? 1 : 0
                };

                var k = ServiceProvider.Instance().GetBeneficiaryTypeServices().AddBeneficiaryTypeCheckDuplicate(newBeneficiaryType);

                if (k < 1)
                {
                    if (k == -3)
                    {
                        ConfirmAlertBox1.ShowMessage("Beneficiary Type Information already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                    ConfirmAlertBox1.ShowMessage("Beneficiary Type Information could not be added.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                ConfirmAlertBox1.ShowSuccessAlert("Beneficiary Type Information was added to successfully.");
                return(true);
            }
            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
        public static TR Map <T, TR>(T sourceObject) where T : class where TR : class
        {
            if (sourceObject == null)
            {
                return(null);
            }
            Type myType = typeof(T);

            if (myType == typeof(BeneficiaryType))
            {
                var objItem = new ExpenseManager.EF.BeneficiaryType();
                var myItem  = sourceObject as BeneficiaryType;
                if (myItem == null)
                {
                    return(null);
                }
                ;
                try
                {
                    objItem.BeneficiaryTypeId = myItem.BeneficiaryTypeId;

                    objItem.Name = myItem.Name;

                    objItem.Status = myItem.Status;
                }
                catch (Exception ex)
                {
                    return(new BeneficiaryType() as TR);
                }
                return(objItem as TR);
            }
            if (myType == typeof(ExpenseManager.EF.BeneficiaryType))
            {
                var objItem = new BeneficiaryType();
                var myItem  = sourceObject as ExpenseManager.EF.BeneficiaryType;
                if (myItem == null)
                {
                    return(null);
                }
                ;
                try
                {
                    objItem.BeneficiaryTypeId = myItem.BeneficiaryTypeId;

                    objItem.Name = myItem.Name;

                    objItem.Status = myItem.Status;

                    #region Included Tables
                    #endregion
                }
                catch (Exception ex)
                {
                    return(new BeneficiaryType() as TR);
                }
                return(objItem as TR);
            }
            return(null);
        }
Example #3
0
 public int AddBeneficiaryTypeCheckDuplicate(BeneficiaryType beneficiaryType)
 {
     try
     {
         return(_beneficiaryTypeManager.AddBeneficiaryTypeCheckDuplicate(beneficiaryType));
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public bool UpdateBeneficiaryType(BeneficiaryType beneficiaryType)
 {
     try
     {
         return(_beneficiaryTypeManager.UpdateBeneficiaryType(beneficiaryType));
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return(false);
     }
 }