Exemplo n.º 1
0
        private GenericValidator ValidateChartOfAccount(ChartOfAccountObject chartOfAccount)
        {
            var gVal = new GenericValidator();

            if (chartOfAccount == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(chartOfAccount.AccountType))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Chart_Of_Account_Type_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(chartOfAccount.AccountCode))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Chart_Of_Account_Code_Error;
                return(gVal);
            }
            if (chartOfAccount.AccountGroupId < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Account_Group_Selection_Error;
                return(gVal);
            }

            gVal.Code = 5;
            return(gVal);
        }
 public int UpdateChartOfAccount(ChartOfAccountObject chartOfAccount)
 {
     try
     {
         if (chartOfAccount == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.AccountType.Trim().ToLower() == chartOfAccount.AccountType.Trim().ToLower() && m.AccountCode.Trim().ToLower() == chartOfAccount.AccountCode.Trim().ToLower() && chartOfAccount.AccountGroupId == m.AccountGroupId && (m.ChartOfAccountId != chartOfAccount.ChartOfAccountId));
         if (duplicates > 0)
         {
             return(-3);
         }
         var chartOfAccountEntity = ModelCrossMapper.Map <ChartOfAccountObject, ChartOfAccount>(chartOfAccount);
         if (chartOfAccountEntity == null || chartOfAccountEntity.ChartOfAccountId < 1)
         {
             return(-2);
         }
         _repository.Update(chartOfAccountEntity);
         _uoWork.SaveChanges();
         return(5);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
 public long AddChartOfAccount(ChartOfAccountObject chartOfAccount)
 {
     try
     {
         if (chartOfAccount == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.AccountType.Trim().ToLower() == chartOfAccount.AccountType.Trim().ToLower() && m.AccountCode.Trim().ToLower() == chartOfAccount.AccountCode.Trim().ToLower() && chartOfAccount.AccountGroupId == m.AccountGroupId);
         if (duplicates > 0)
         {
             return(-3);
         }
         var chartOfAccountEntity = ModelCrossMapper.Map <ChartOfAccountObject, ChartOfAccount>(chartOfAccount);
         if (chartOfAccountEntity == null || string.IsNullOrEmpty(chartOfAccountEntity.AccountType))
         {
             return(-2);
         }
         var returnStatus = _repository.Add(chartOfAccountEntity);
         _uoWork.SaveChanges();
         return(returnStatus.ChartOfAccountId);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Exemplo n.º 4
0
        public ActionResult EditChartOfAccount(ChartOfAccountObject chartOfAccount)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateChartOfAccount(chartOfAccount);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = 0;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_chartOfAccount"] == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldChartOfAccount = Session["_chartOfAccount"] as ChartOfAccountObject;
                    if (oldChartOfAccount == null || oldChartOfAccount.ChartOfAccountId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldChartOfAccount.AccountType    = chartOfAccount.AccountType.Trim();
                    oldChartOfAccount.AccountCode    = chartOfAccount.AccountCode.Trim();
                    oldChartOfAccount.AccountGroupId = chartOfAccount.AccountGroupId;
                    var k = new ChartOfAccountServices().UpdateChartOfAccount(oldChartOfAccount);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate: message_Feedback.Update_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Update_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 5
0
 public int UpdateChartOfAccount(ChartOfAccountObject chartOfAccount)
 {
     try
     {
         return(_chartOfAccountRepository.UpdateChartOfAccount(chartOfAccount));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
Exemplo n.º 6
0
        public ActionResult AddChartOfAccount(ChartOfAccountObject chartOfAccount)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateChartOfAccount(chartOfAccount);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = 0;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var k = new ChartOfAccountServices().AddChartOfAccount(chartOfAccount);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Insertion_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }