Esempio n. 1
0
        /// <summary>
        /// Update Branch details
        /// </summary>
        /// <param name="branchInfoBO"></param>
        /// <param name="msg"></param>
        /// <returns></returns>

        public bool UpdateBranchInfo(BranchInfoBO branchInfoBO, out string msg)
        {
            msg = "";
            var UpdateBranchInfo = db.Branch_Details.SingleOrDefault(br => br.BranchID.Equals(branchInfoBO.BranchID));

            var isExistBranchCode = (from b in db.Branch_Details
                                     where b.BranchCode.Equals(branchInfoBO.BranchCode) && b.BranchID != branchInfoBO.BranchID
                                     select b).SingleOrDefault();

            var isExistBranchName = (from b in db.Branch_Details where b.BranchName.Equals(branchInfoBO.BranchName) && b.BranchID != branchInfoBO.BranchID select b).SingleOrDefault();

            try
            {
                if (UpdateBranchInfo != null)
                {
                    if (isExistBranchCode != null)
                    {
                        msg = "Branch  Code is  already exist!!";
                        return(false);
                    }
                    if (isExistBranchName != null)
                    {
                        msg = "Branch Name is  already exist!!";
                        return(false);
                    }
                    if (branchInfoBO.Address.CountryID != 1)
                    {
                        msg = "PAF Is Only Used For UK, So please Select a Country As a UK..!! ";
                        return(false);
                    }
                    UpdateBranchInfo.BranchName = branchInfoBO.BranchName;
                    //UpdateBranchInfo.AddressID = (int)branchInfoBO.AddressID;
                    UpdateBranchInfo.BranchStatusID = (int)branchInfoBO.BranchStatusID;
                    UpdateBranchInfo.BranchTypeID   = (int)branchInfoBO.BranchTypeID;
                    UpdateBranchInfo.Fax            = branchInfoBO.FaxNumber;
                    UpdateBranchInfo.Telephone      = branchInfoBO.TelephoneNumber;
                    UpdateBranchInfo.VATNumber      = branchInfoBO.VATnumber;
                    UpdateBranchInfo.BranchCode     = branchInfoBO.BranchCode;
                    UpdateBranchInfo.Status         = branchInfoBO.status;

                    UpdateBranchInfo.AddressID = (int)addressBL.CheckAddress(branchInfoBO.Address);
                    if (branchInfoBO.Address.AddressID == 0)
                    {
                        msg = "AddressId is Not Saved ";
                        return(false);
                    }
                    db.SaveChanges();
                    msg = "Successfully Updated!!";
                    return(true);
                }
                msg = "Unable to update! No records found with this Branch ID";

                return(false);
            }
            catch (Exception exc)
            {
                msg = exc.Message;
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///  for Get the List using Ajax (Inner Update List)
        /// </summary>
        /// <returns></returns>
        public ActionResult ListBranch()
        {
            BranchInfoBO        branchInfoBo   = new BranchInfoBO();
            BranchInfoViewModel branchInfoView = new BranchInfoViewModel();

            branchInfoView.branchInfoViewModel = branchInfoBL.GetBranchList();
            return(PartialView("_BranchListView", branchInfoView.branchInfoViewModel));
        }
Esempio n. 3
0
        /// <summary>
        ///  Save Branch Details to DB
        /// </summary>
        /// <param name="branchInfoBO"></param>
        /// <param name="eMessage"></param>
        /// <returns></returns>

        public bool SaveBranchDetails(BranchInfoBO branchInfoBO, out string eMessage)
        {
            eMessage = "";
            var existingTypeBranchCode = db.Branch_Details.Where(t => t.BranchCode == branchInfoBO.BranchCode).SingleOrDefault();
            var existingTypeBranchName = db.Branch_Details.Where(t => t.BranchName == branchInfoBO.BranchName).SingleOrDefault();

            try
            {
                if (existingTypeBranchCode != null)
                {
                    eMessage = "Branch Code Is Already Exist...!!";
                    return(false);
                }

                if (existingTypeBranchName != null)
                {
                    eMessage = "Branch Name Is Already Exist..!!";
                    return(false);
                }

                if (branchInfoBO.Address.CountryID != 1)
                {
                    eMessage = "PAF Is Only Used For UK, So please Select a Country As a UK..!! ";
                    return(false);
                }
                var branchdetails = new Branch_Details();

                //branchdetails.AddressID = (int)branchInfoBO.AddressID;
                branchdetails.BranchCode     = branchInfoBO.BranchCode;
                branchdetails.BranchName     = branchInfoBO.BranchName;
                branchdetails.BranchTypeID   = (int)branchInfoBO.BranchTypeID;
                branchdetails.BranchStatusID = (int)branchInfoBO.BranchStatusID;
                branchdetails.Fax            = branchInfoBO.FaxNumber;
                branchdetails.Telephone      = branchInfoBO.TelephoneNumber;
                branchdetails.VATNumber      = branchInfoBO.VATnumber;
                branchdetails.Status         = false;
                db.Branch_Details.Add(branchdetails);
                if (branchInfoBO.Address.Postcode != null)
                {
                    branchdetails.AddressID = (int)addressBL.CheckAddress(branchInfoBO.Address);
                    branchInfoBO.AddressID  = branchInfoBO.Address.AddressID = branchdetails.AddressID;
                    if (branchInfoBO.Address.AddressID == 0)
                    {
                        eMessage = "AddressId Is Not Saved ";
                        return(false);
                    }
                }

                db.SaveChanges();
                eMessage = "Successfully Saved ";
                return(true);
            }
            catch (Exception e)
            {
                eMessage = e.Message;
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        ///View the Total Branch Details
        /// </summary>
        /// <returns>
        /// Branch List
        /// </returns>
        ///
        public ActionResult Index()

        {
            BranchInfoBO        branchInfoBo   = new BranchInfoBO();
            BranchInfoViewModel branchInfoView = new BranchInfoViewModel();

            branchInfoView.branchInfoViewModel = branchInfoBL.GetBranchList();
            branchInfoView.branchInfoBO        = new BranchInfoBO();

            return(View(branchInfoView));
        }
Esempio n. 5
0
        public ActionResult CreateBranch(BranchInfoBO branchInfoBO)
        {
            string eMessage;

            if (ModelState.IsValid)
            {
                if (branchInfoBO.BranchID == 0)
                {
                    if (branchInfoBL.SaveBranchDetails(branchInfoBO, out eMessage) == true)
                    {
                        return(Json(new
                        {
                            success = true,

                            errorMsg = eMessage
                        }));
                    }
                    else
                    {
                        return(Json(new
                        {
                            success = false,
                            errorMsg = eMessage,
                            //AjaxReturn = PartialView("_CreateEditBranch", branchInfoBO).RenderTostring()
                        }));
                        //ModelState.AddModelError("BranchCode", eMessage);
                    }
                }


                else
                {
                    if (branchInfoBL.UpdateBranchInfo(branchInfoBO, out eMessage) == true)
                    {
                        return(Json(new { success = true, errorMsg = eMessage }));
                    }
                    else
                    {
                        return(Json(new
                        {
                            success = false,

                            errorMsg = eMessage,
                        }));
                    }
                }
            }
            ViewBagList();
            return(PartialView("_CreateEditBranch", branchInfoBO));
        }
Esempio n. 6
0
        /// <summary>
        ///  Edit Branch details & view to  _CreateEditBranch partial view
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult EditBranch(int Id)
        {
            if (branchInfoBL.ChkEditBranch(Id) == true)
            {
                BranchInfoBO branchInfoBO = new BranchInfoBO();
                branchInfoBO = branchInfoBL.GetEditBranch(Id);
                ViewBagList();
                return(Json(new { success = true, partialview = RenderViewToString("_CreateEditBranch", branchInfoBO), message = "" }));
                // return PartialView("_CreateEditBranch", branchInfoBO);
            }

            else
            {
                return(Json(new
                {
                    success = false,

                    errorMsg = "This Branch Details Is Already Deleted....!! ",
                }, JsonRequestBehavior.AllowGet));
            }
        }