コード例 #1
0
        public ActionMessage deleteBranch(int branchId)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    BranchInfo branchInfo = BranchDataLayer.GetInstance().GetBranchById(connection, branchId);
                    if (branchInfo == null)
                    {
                        ret.isSuccess   = false;
                        ret.err.msgCode = "Chi nhánh này không tồn tại";
                        return(ret);
                    }
                    BranchDataLayer.GetInstance().DeleteBranch(connection, branchId);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }
コード例 #2
0
        public int GetTotalRecordBranch()
        {
            int total = 0;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                total = BranchDataLayer.GetInstance().GetTatalRecordBranch(connection);
            }
            return(total);
        }
コード例 #3
0
        public BranchInfo getBranchById(int branchId)
        {
            BranchInfo           result        = new BranchInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                result = BranchDataLayer.GetInstance().GetBranchById(connection, branchId);
            }
            return(result);
        }
コード例 #4
0
        public List <BranchInfo> getAllBranch(int page, int size)
        {
            List <BranchInfo>    result        = new List <BranchInfo>();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
            int position = (page - 1) * size;

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                result = BranchDataLayer.GetInstance().GetAllBranch(connection, position, size);
            }
            return(result);
        }
コード例 #5
0
        public int totalRecordSearch(string query)
        {
            List <BranchInfo> result = new List <BranchInfo>();
            int total = 0;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                total = BranchDataLayer.GetInstance().totalRecordSearch(connection, query);
            }
            return(total);
        }
コード例 #6
0
        public ActionMessage editBranch(BranchInfo branch)
        {
            ActionMessage ret = new ActionMessage();

            if (string.IsNullOrEmpty(branch.BranchName.Trim()))
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error";
                ret.err.msgString = "Chưa nhập Tên chi nhánh";
            }
            else if (string.IsNullOrEmpty(branch.BranchAddress.Trim()))
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error";
                ret.err.msgString = "Chưa nhập Địa chỉ";
            }
            else
            {
                SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        BranchInfo branchInfo = BranchDataLayer.GetInstance().GetBranchById(connection, branch.BranchID);
                        if (branchInfo == null)
                        {
                            ret.isSuccess   = false;
                            ret.err.msgCode = "Chi nhánh này không tồn tại";
                            return(ret);
                        }
                        BranchDataLayer.GetInstance().UpdateBranch(connection, branch);
                        ret.isSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        ret.isSuccess     = false;
                        ret.err.msgCode   = "Internal Error";
                        ret.err.msgString = ex.ToString();
                    }
                }
            }
            return(ret);
        }
コード例 #7
0
        public ActionMessage deleteManyBranch(string ids)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    BranchDataLayer.GetInstance().DeleteManyBranch(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }