Exemplo n.º 1
0
        public ActionResult SaveAccntType(AccountTypeModel model)
        {
            var isExist = "";

            if (ModelState.IsValid)
            {
                var accntType = model.AccntTypeList.AccntType;

                Tbl_FMBank_AccountType checkAccntType = (from a in BOSSDB.Tbl_FMBank_AccountType where (a.AccntType == accntType) select a).FirstOrDefault();

                if (model.ActionID == 1)
                {
                    if (checkAccntType == null)
                    {
                        Tbl_FMBank_AccountType AT = new Tbl_FMBank_AccountType();
                        AT.AccntType = accntType;
                        BOSSDB.Tbl_FMBank_AccountType.Add(AT);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                    }
                    else if (checkAccntType != null)
                    {
                        isExist = "true";
                    }
                }
                else if (model.ActionID == 2)
                {
                    Tbl_FMBank_AccountType        AType        = (from a in BOSSDB.Tbl_FMBank_AccountType where a.AccntTypeID == model.AccntTypeList.AccntTypeID select a).FirstOrDefault();
                    List <Tbl_FMBank_AccountType> acctypeCount = (from e in BOSSDB.Tbl_FMBank_AccountType where e.AccntType == accntType select e).ToList();
                    if (checkAccntType != null)
                    {
                        if (AType.AccntType != accntType && acctypeCount.Count >= 1)
                        {
                            isExist = "true";
                        }
                        else
                        {
                            isExist = "justUpdate";
                        }
                    }
                    else if (checkAccntType == null)
                    {
                        isExist = "justUpdate";
                    }

                    if (isExist == "justUpdate")
                    {
                        AType.AccntType = accntType;
                        BOSSDB.Entry(AType);
                        BOSSDB.SaveChanges();
                    }
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }
Exemplo n.º 2
0
        public ActionResult ConfirmDeleteAccntType(int PrimaryID)
        {
            Tbl_FMBank_AccountType acctype = (from a in BOSSDB.Tbl_FMBank_AccountType where a.AccntTypeID == PrimaryID select a).FirstOrDefault();

            BOSSDB.Tbl_FMBank_AccountType.Remove(acctype);
            BOSSDB.SaveChanges();

            var result = "";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult DeleteAccntType(int PrimaryID)
        {
            Tbl_FMBank_AccountType  AccntType = (from a in BOSSDB.Tbl_FMBank_AccountType where a.AccntTypeID == PrimaryID select a).FirstOrDefault();
            Tbl_FMBank_BankAccounts bankaccnt = (from a in BOSSDB.Tbl_FMBank_BankAccounts where a.AccntTypeID == PrimaryID select a).FirstOrDefault();

            var confirmDelete = "";

            if (AccntType != null)
            {
                if (bankaccnt != null)
                {
                    confirmDelete = "true";
                }
                else
                {
                    confirmDelete = "false";
                }
            }
            var result = new { confirmDelete = confirmDelete };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }