/// <summary>
        /// Edit group info
        /// </summary>
        /// <param name="data">Group info</param>
        /// <param name="groupID">Group ID output</param>
        /// <returns>Action result</returns>
        public bool EditGroupInfo(GroupPlus data, out int groupID)
        {
            var res = false;

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

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

            return(res);
        }
        /// <summary>
        /// Edit group info
        /// </summary>
        /// <param name="data">Group info</param>
        /// <param name="groupID">Group ID output</param>
        /// <returns>Action result</returns>
        public bool EditGroupInfo(GroupPlus data, out int groupID)
        {
            int result = 0;

            groupID = data.group_id;

            if (data.group_id == 0)
            {
                var sqlInsert = new Sql(@"
                    INSERT INTO
                        m_group
                        (company_code,
                        group_name,
                        display_name,
                        budget_setting_flg,
                        check_actual_work_flg,
                        remarks,
                        ins_date,
                        ins_id,
                        upd_date,
                        upd_id,
                        del_flg)
                    VALUES
                        (@company_code, @group_name, @display_name, @budget_setting_flg, @check_actual_work_flg, @remarks,
                         @ins_date, @ins_id, @upd_date, @upd_id, @del_flg);
                    SELECT
                        SCOPE_IDENTITY();",
                                        new
                {
                    company_code          = data.company_code,
                    group_name            = data.group_name.Trim(),
                    display_name          = data.display_name.Trim(),
                    budget_setting_flg    = data.budget_setting_flg,
                    check_actual_work_flg = data.check_actual_work_flg,
                    remarks  = data.remarks,
                    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
                });

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

                if (groupID > 0)
                {
                    result = groupID;
                }
            }
            else
            {
                var sqlUpdate = new Sql(@"
                    UPDATE
                        m_group
                    SET
                        group_name = @group_name,
                        display_name = @display_name,
                        budget_setting_flg = @budget_setting_flg,
                        check_actual_work_flg = @check_actual_work_flg,
                        remarks = @remarks,
                        upd_date = @upd_date,
                        upd_id = @upd_id,
                        del_flg = @del_flg
                    WHERE
                        group_id = @group_id
                        AND company_code = @company_code;",
                                        new
                {
                    group_name            = data.group_name.Trim(),
                    display_name          = data.display_name.Trim(),
                    budget_setting_flg    = data.budget_setting_flg,
                    check_actual_work_flg = data.check_actual_work_flg,
                    remarks      = data.remarks,
                    upd_date     = data.upd_date,
                    upd_id       = data.upd_id,
                    del_flg      = data.del_flg,
                    group_id     = data.group_id,
                    company_code = data.company_code
                });
                result = this._database.Execute(sqlUpdate);
            }

            return(result > 0);
        }
Exemple #3
0
 public PMS05001EditViewModel()
 {
     GroupInfo = new GroupPlus();
 }