/// <summary>
 /// 插入
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Insert(CompanyProductCategoryInfo model) {
     string strSQL = "INSERT INTO CompanyProductCategories(Name,IsSystem,CompanyId,ProductCount,IsDeleted) VALUES(@Name,@IsSystem,@CompanyId,0,0);SELECT @@IDENTITY;";
     SqlParameter[] parms = { 
                             new SqlParameter("Name",SqlDbType.NVarChar),
                             new SqlParameter("IsSystem",SqlDbType.Int),
                             new SqlParameter("CompanyId",SqlDbType.Int),
                            };
     parms[0].Value = model.Name;
     parms[1].Value = model.IsSystem;
     parms[2].Value = model.CompanyId;
     return Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text,strSQL,parms));
 }
 /// <summary>
 /// 添加或编辑
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static CompanyProductCategoryInfo Update(CompanyProductCategoryInfo model)
 {
     if (model.Id == 0)
     {
         //插入
         int id = CompanyProductCategoryManage.Insert(model);
         model.Id = id;
     }
     else {
         CompanyProductCategoryManage.Update(model);
     }
     return model;
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Update(CompanyProductCategoryInfo model) {
     string strSQL = "UPDATE CompanyProductCategories SET Name = @Name WHERE CompanyId = @CompanyId AND Id = @Id";
     SqlParameter[] parms = { 
                             new SqlParameter("Name",SqlDbType.NVarChar),
                             new SqlParameter("IsSystem",SqlDbType.Int),
                             new SqlParameter("CompanyId",SqlDbType.Int),
                             new SqlParameter("Id",SqlDbType.Int),
                            };
     parms[0].Value = model.Name;
     parms[1].Value = model.IsSystem;
     parms[2].Value = model.CompanyId;
     parms[3].Value = model.Id;
     return SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms);
 }
Exemplo n.º 4
0
        public ActionResult ProductCategoryList(CompanyProductCategoryInfo oldModel) {
            var companyInfo = MemberService.GetCompanyInfoByUserId(PlantEngContext.Current.UserId);
            //保存
            bool errors = false;
            if (string.IsNullOrEmpty(oldModel.Name))
            {
                errors = true;
                ModelState.AddModelError("NAMEEMPTY", "名称不能为空");
            }
            if (!errors && ModelState.IsValid)
            {
                //OK
                oldModel.CompanyId = companyInfo.CompanyId;
                CompanyProductCategoryService.Update(oldModel);
                ViewBag.Msg = "保存成功!";
            }
            

            //产品分类
            ViewBag.CategoryList = CompanyProductCategoryService.GetCategoryList(companyInfo.CompanyId);
            return View(oldModel);
        }