Пример #1
0
        /// <summary>
        /// Edit Branch info
        /// </summary>
        /// <param name="data">Branch info</param>
        /// <param name="BranchID">Branch ID output</param>
        /// <returns>Action result</returns>
        public bool EditBranchInfo(BranchPlus data, out int BranchID)
        {
            var res = false;

            using (var transaction = new TransactionScope())
            {
                res = this._repository.EditBranchInfo(data, out BranchID);

                if (res)
                {
                    transaction.Complete();
                }
            }

            return(res);
        }
Пример #2
0
        /// <summary>
        /// Edit group info
        /// </summary>
        /// <param name="data">Branch info</param>
        /// <param name="BranchID">Branch ID output</param>
        /// <returns>Action result</returns>
        public bool EditBranchInfo(BranchPlus data, out int branchID)
        {
            int result = 0;

            branchID = data.location_id;

            if (data.location_id == 0)
            {
                var sqlInsert = new Sql(@"
                    INSERT INTO
                        m_business_location
                        (company_code,
                        location_name,
                        display_name,
                        remarks,
                        display_order,
                        ins_date,
                        ins_id,
                        upd_date,
                        upd_id,
                        del_flg)
                    VALUES
                        (@company_code, @branch_name, @display_name, @remarks,@display_order,
                         @ins_date, @ins_id, @upd_date, @upd_id, @del_flg);
                    SELECT
                        SCOPE_IDENTITY();",
                                        new
                {
                    company_code  = data.company_code,
                    branch_name   = data.location_name.Trim(),
                    display_name  = data.display_name.Trim(),
                    remarks       = data.remarks,
                    display_order = data.display_order,
                    ins_date      = data.upd_date,
                    ins_id        = data.upd_id,
                    upd_date      = data.upd_date,
                    upd_id        = data.upd_id,
                    del_flg       = Constant.DeleteFlag.NON_DELETE
                });

                branchID = this._database.ExecuteScalar <int>(sqlInsert);

                if (branchID > 0)
                {
                    result = branchID;
                }
            }
            else
            {
                var sqlUpdate = new Sql(@"
                    UPDATE
                        m_business_location
                    SET
                        location_name = @branch_name,
                        display_name = @display_name,
                        remarks = @remarks,
                        display_order = @display_order,
                        upd_date = @upd_date,
                        upd_id = @upd_id,
                        del_flg = @del_flg
                    WHERE
                        location_id = @branch_id
                        AND company_code = @company_code;",
                                        new
                {
                    branch_name   = data.location_name.Trim(),
                    display_name  = data.display_name.Trim(),
                    remarks       = data.remarks,
                    display_order = data.display_order,
                    upd_date      = data.upd_date,
                    upd_id        = data.upd_id,
                    del_flg       = data.del_flg,
                    branch_id     = data.location_id,
                    company_code  = data.company_code
                });
                result = this._database.Execute(sqlUpdate);
            }

            return(result > 0);
        }
Пример #3
0
 public PMS11001EditViewModel()
 {
     BranchInfo = new BranchPlus();
 }