internal static List<Branch> GetAll(Branch srchBranch, string executedBy)
        {
            List<Branch> branchList = null;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_Branch_GetAll);

                db.AddInParameter(cmd, "IsActive", DbType.Boolean, srchBranch.IsActive);
                db.AddInParameter(cmd, "BranchName", DbType.String, srchBranch.BranchName);
                db.AddInParameter(cmd, "AddressLine1", DbType.String, srchBranch.AddressLine1);

                DataSet ds = db.ExecuteDataSet(cmd);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    branchList = Utility.DataTableToCollection<Branch>(ds.Tables[0]);
                }
            }
            catch (Exception ex)
            {
                branchList = null;
            }

            return branchList;
        }
        public ActionResult Create()
        {
            TransferModel transfer = new TransferModel();

            List<Branch> fromBranchList = BranchManager.GetAllBranch(new Branch { BranchName = "", AddressLine1 = "", IsActive = true }, "dini");
            ViewBag.FromBranchList = fromBranchList;

            Branch[] tmpArray = new Branch[] { };
            fromBranchList.CopyTo(tmpArray);
            List<Branch> toBranchList = tmpArray.ToList();
            ViewBag.ToBranchList = toBranchList;

            return View(transfer);
        }
        internal static bool Insert(Branch branch, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_Branch_Insert);

                db.AddInParameter(cmd, "BranchName", DbType.String, branch.BranchName);
                db.AddInParameter(cmd, "AddressLine1", DbType.String, branch.AddressLine1);
                db.AddInParameter(cmd, "AddressLine2", DbType.String, branch.AddressLine2);
                db.AddInParameter(cmd, "AddressLine3", DbType.String, branch.AddressLine3);
                db.AddInParameter(cmd, "Telephone", DbType.String, branch.Telephone);
                db.AddInParameter(cmd, "Email", DbType.String, branch.Email);
                //db.AddInParameter(cmd, "MainBranchID", DbType.Int32, branch.MainBranchID);
                db.AddInParameter(cmd, "IsActive", DbType.Boolean, branch.IsActive);
                db.AddInParameter(cmd, "CreatedBy", DbType.Int32, 1);

                db.AddOutParameter(cmd, "NewID", DbType.Int32, 4);

                db.ExecuteNonQuery(cmd);

                int newID = 0;
                int.TryParse(db.GetParameterValue(cmd, "NewID").ToString(), out newID);

                if (newID > 0)
                {
                    branch.BranchID = newID;
                    rslt = true;
                }
            }

            catch (Exception ex)
            {
                rslt = false;
            }

            return rslt;
        }
        internal static bool Update(Branch branch, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_Branch_Update);

                db.AddInParameter(cmd, "BranchID", DbType.Int32, branch.BranchID);
                db.AddInParameter(cmd, "BranchName", DbType.String, branch.BranchName);
                db.AddInParameter(cmd, "AddressLine1", DbType.String, branch.AddressLine1);
                db.AddInParameter(cmd, "AddressLine2", DbType.String, branch.AddressLine2);
                db.AddInParameter(cmd, "AddressLine3", DbType.String, branch.AddressLine3);
                db.AddInParameter(cmd, "Telephone", DbType.String, branch.Telephone);
                db.AddInParameter(cmd, "Email", DbType.String, branch.Email);
                //db.AddInParameter(cmd, "MainBranchID", DbType.Int32, branch.MainBranchID);
                db.AddInParameter(cmd, "IsActive", DbType.Boolean, branch.IsActive);
                db.AddInParameter(cmd, "UpdatedBY", DbType.Int32, 1);

                db.ExecuteNonQuery(cmd);

                rslt = true;
            }

            catch (Exception ex)
            {
                rslt = false;
            }

            return rslt;
        }
 public static bool UpdateBranch(Branch branch, string executedBy)
 {
     return BranchDAO.Update(branch, executedBy);
 }
 public static List<Branch> GetAllBranch(Branch srchBranch, string executedBy)
 {
     return BranchDAO.GetAll(srchBranch, executedBy);
 }
 public static bool AddBranch(Branch branch, string executedBy)
 {
     return BranchDAO.Insert(branch, executedBy);
 }
        public ActionResult Index(FormCollection collection)
        {
            try
            {
                string branchName = collection.GetValue("BranchName").AttemptedValue;
                string addressLine1 = collection.GetValue("AddressLine1").AttemptedValue;
                bool bIsActive = Request.Form.GetValues("active") != null && Request.Form.GetValues("active")[0] != null ? true : false;

                Branch srcBran = new Branch() { BranchName = branchName, AddressLine1 = addressLine1, IsActive = bIsActive };

                List<Branch> branch = new List<Branch>();
                List<BranchModel> branchModels = new List<BranchModel>();
                branch = BranchManager.GetAllBranch(srcBran, "nirshan");

                return View(Utility.ConvetrToList<BranchModel, Branch>(branch));
            }
            catch
            {
                return View();
            }
        }
        //
        // GET: /Branch/
        public ActionResult Index()
        {
            Branch srchBranch = new Branch() { BranchName = "", AddressLine1 = "", IsActive = true };
            List<Branch> branList = BranchManager.GetAllBranch(srchBranch, "nirshan");
            List<BranchModel> branchList = Utility.ConvetrToList<BranchModel, Branch>(branList);

            return View(branchList);
        }