Example #1
0
        /// <summary>
        /// Edit category data
        /// </summary>
        /// <param name="?"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        public int EditCategoryData(CategoryPlus category, IList <SubCategoryPlus> subCategoryList)
        {
            int res;

            using (var transaction = new TransactionScope())
            {
                res = this._repository.EditCategory(category, subCategoryList);

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

            return(res);
        }
Example #2
0
        /// <summary>
        /// Edit Category
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public int EditCategory(CategoryPlus category, IList <SubCategoryPlus> subCategoryList)
        {
            int res = 0;
            Sql sql;

            if (category.category_id > 0)
            {
                IDictionary <string, object> columns = new Dictionary <string, object>()
                {
                    { "category", category.category.Trim() }
                    , { "remarks", category.remarks }
                    , { "display_order", category.display_order }
                    , { "upd_date", category.upd_date }
                    , { "upd_id", category.upd_id }
                    , { "del_flg", category.del_flg }
                };

                IDictionary <string, object> condition = new Dictionary <string, object>()
                {
                    { "category_id", category.category_id },
                    { "company_code", category.company_code }
                };


                if (Update <Category>(columns, condition) > 0)
                {
                    res = category.category_id;
                }
            }
            else
            {
                category.ins_date = category.upd_date;
                category.ins_id   = category.upd_id;

                sql = new Sql(@"
                INSERT INTO m_category
                       (company_code
                       ,category
                       ,remarks
                       ,display_order
                       ,ins_date
                       ,ins_id
                       ,upd_date
                       ,upd_id
                       ,del_flg)
                 VALUES
                       (
                       @company_code,
                       @category,
                       @remarks,
                       @display_order,
                       @ins_date,
                       @ins_id,
                       @upd_date,
                       @upd_id,
                       @del_flg)"
                              , new { company_code = category.company_code }
                              , new { category = category.category.Trim() }
                              , new { remarks = category.remarks }
                              , new { display_order = category.display_order }
                              , new { ins_date = category.ins_date }
                              , new { ins_id = category.ins_id }
                              , new { upd_date = category.upd_date }
                              , new { upd_id = category.upd_id }
                              , new { del_flg = Constant.DeleteFlag.NON_DELETE }
                              );

                if (_database.Execute(sql) > 0)
                {
                    var query = "select ident_current('m_category')";
                    res = _database.ExecuteScalar <int>(query);
                }
            }

            if (res > 0)
            {
                if (!EditListSubCategory(category.company_code, res, category.upd_date, category.upd_id, subCategoryList))
                {
                    res = 0;
                }
            }

            return(res);
        }
Example #3
0
 public PMS10004EditViewModel()
 {
     CATEGORY         = new CategoryPlus();
     LIST_SUBCATEGORY = new List <SubCategoryPlus>();
 }