Beispiel #1
0
        public void Delete(St_BranchAccountH ObjDelete)
        {
            var ObjToDelete = _context.St_BranchAccountHs.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.BranchCode == ObjDelete.BranchCode);

            if (ObjToDelete != null)
            {
                _context.St_BranchAccountHs.Remove(ObjToDelete);
            }
        }
Beispiel #2
0
        public JsonResult Delete(St_BranchHVM ObjDelete)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);

                ObjDelete.CompanyID = UserInfo.fCompanyId;
                var ObjDeleteSt_Branch = new St_BranchH();
                ObjDeleteSt_Branch.CompanyID  = UserInfo.fCompanyId;
                ObjDeleteSt_Branch.BranchCode = ObjDelete.BranchCode;
                var ObjDeleteSt_BranchAccount = new St_BranchAccountH();
                ObjDeleteSt_BranchAccount.CompanyID  = UserInfo.fCompanyId;
                ObjDeleteSt_BranchAccount.BranchCode = ObjDelete.BranchCode;
                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }

                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                _unitOfWork.NativeSql.DeleteSt_BranchExpenseAccountH(ObjDeleteSt_Branch.CompanyID, ObjDeleteSt_Branch.BranchCode);
                _unitOfWork.NativeSql.DeleteSt_BranchOtherExpenseAccountH(ObjDeleteSt_Branch.CompanyID, ObjDeleteSt_Branch.BranchCode);
                _unitOfWork.St_BranchAccountH.Delete(ObjDeleteSt_BranchAccount);
                _unitOfWork.St_BranchH.Delete(ObjDeleteSt_Branch);
                _unitOfWork.Complete();

                Msg.Code = 1;
                Msg.Msg  = Resources.Resource.DeletedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #3
0
 public void Add(St_BranchAccountH ObjSave)
 {
     _context.St_BranchAccountHs.Add(ObjSave);
 }
Beispiel #4
0
        public JsonResult SaveSt_BranchAccountH(St_BranchAccountHVM ObjToSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);
                ObjToSave.InsDateTime = DateTime.Now;
                ObjToSave.InsUserID   = userId;
                ObjToSave.CompanyID   = UserInfo.fCompanyId;
                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }

                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                var St_BranchAccountHObj = new St_BranchAccountH();
                St_BranchAccountHObj.CompanyID                                = UserInfo.fCompanyId;
                St_BranchAccountHObj.BranchCode                               = ObjToSave.BranchCode;
                St_BranchAccountHObj.FundAccountNumber                        = ObjToSave.FundAccountNumber;
                St_BranchAccountHObj.SalesAccountNumber                       = ObjToSave.SalesAccountNumber;
                St_BranchAccountHObj.MaintenanceCardAccountNumber             = ObjToSave.MaintenanceCardAccountNumber;
                St_BranchAccountHObj.ReturnCardAccountNumber                  = ObjToSave.ReturnCardAccountNumber;
                St_BranchAccountHObj.TransferFeesAndInstallationAccountNumber = ObjToSave.TransferFeesAndInstallationAccountNumber;
                St_BranchAccountHObj.ChequeFundAccountNumber                  = ObjToSave.ChequeFundAccountNumber;
                St_BranchAccountHObj.RelocationAccountNumber                  = ObjToSave.RelocationAccountNumber;
                St_BranchAccountHObj.VisaAccountNumber                        = ObjToSave.VisaAccountNumber;
                St_BranchAccountHObj.MasterAccountNumber                      = ObjToSave.MasterAccountNumber;
                St_BranchAccountHObj.AmericanAccountNumber                    = ObjToSave.AmericanAccountNumber;
                St_BranchAccountHObj.ArabiCashAccountNumber                   = ObjToSave.ArabiCashAccountNumber;
                St_BranchAccountHObj.ReceiptVoucherNo                         = ObjToSave.ReceiptVoucherNo;
                St_BranchAccountHObj.PaymentVoucherNo                         = ObjToSave.PaymentVoucherNo;
                St_BranchAccountHObj.ReceiptChequeVoucherNo                   = ObjToSave.ReceiptChequeVoucherNo;
                St_BranchAccountHObj.TransferFeesAndInstallationVoucherNo     = ObjToSave.TransferFeesAndInstallationVoucherNo;
                St_BranchAccountHObj.InstallmentSchedulingVoucherNo           = ObjToSave.InstallmentSchedulingVoucherNo;
                St_BranchAccountHObj.MaintenanceCardVoucherNo                 = ObjToSave.MaintenanceCardVoucherNo;
                St_BranchAccountHObj.TransferVoucherNo                        = ObjToSave.TransferVoucherNo;
                St_BranchAccountHObj.ReturningSoldItemVoucherNo               = ObjToSave.ReturningSoldItemVoucherNo;
                St_BranchAccountHObj.ClosingAFundVoucherNo                    = ObjToSave.ClosingAFundVoucherNo;
                St_BranchAccountHObj.ChequeFundClosingVoucherNo               = ObjToSave.ChequeFundClosingVoucherNo;
                St_BranchAccountHObj.ClosingAFinancingFundVoucherNo           = ObjToSave.ClosingAFinancingFundVoucherNo;
                St_BranchAccountHObj.FinancingVoucherNo                       = ObjToSave.FinancingVoucherNo;
                St_BranchAccountHObj.InstallationVoucherNo                    = ObjToSave.InstallationVoucherNo;
                St_BranchAccountHObj.InsDateTime                              = DateTime.Now;
                St_BranchAccountHObj.InsUserID                                = userId;
                _unitOfWork.NativeSql.DeleteSt_BranchExpenseAccountH(UserInfo.fCompanyId, ObjToSave.BranchCode);
                _unitOfWork.NativeSql.DeleteSt_BranchOtherExpenseAccountH(UserInfo.fCompanyId, ObjToSave.BranchCode);
                _unitOfWork.St_BranchAccountH.Delete(St_BranchAccountHObj);
                _unitOfWork.Complete();
                if (ObjToSave.St_BranchExpenseAccountH != null)
                {
                    foreach (var SaveSt_BranchExpenseAccountH in ObjToSave.St_BranchExpenseAccountH)
                    {
                        SaveSt_BranchExpenseAccountH.CompanyID            = UserInfo.fCompanyId;
                        SaveSt_BranchExpenseAccountH.BranchCode           = ObjToSave.BranchCode;
                        SaveSt_BranchExpenseAccountH.ExpenseAccountNumber = SaveSt_BranchExpenseAccountH.ExpenseAccountNumber;
                        SaveSt_BranchExpenseAccountH.RowNumber            = SaveSt_BranchExpenseAccountH.RowNumber;
                        _unitOfWork.St_BranchAccountH.AddBranchExpenseAccountH(SaveSt_BranchExpenseAccountH);
                    }
                }
                if (ObjToSave.St_BranchOtherExpenseAccountH != null)
                {
                    foreach (var SaveSt_BranchOtherExpenseAccountH in ObjToSave.St_BranchOtherExpenseAccountH)
                    {
                        SaveSt_BranchOtherExpenseAccountH.CompanyID  = UserInfo.fCompanyId;
                        SaveSt_BranchOtherExpenseAccountH.BranchCode = ObjToSave.BranchCode;
                        SaveSt_BranchOtherExpenseAccountH.OtherExpenseAccountNumber = SaveSt_BranchOtherExpenseAccountH.OtherExpenseAccountNumber;
                        SaveSt_BranchOtherExpenseAccountH.RowNumber = SaveSt_BranchOtherExpenseAccountH.RowNumber;
                        _unitOfWork.St_BranchAccountH.AddBranchOtherExpenseAccountH(SaveSt_BranchOtherExpenseAccountH);
                    }
                }
                _unitOfWork.St_BranchAccountH.Add(St_BranchAccountHObj);
                _unitOfWork.Complete();
                Msg.Code = 1;
                Msg.Msg  = Resources.Resource.AddedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }