//取类别ID protected int GetCategoryTypeId(string name, DataTable dt) { foreach (DataRow dr in dt.Rows) { if (name == dr["CategoryTypeName"].ToString()) { return(Int32.Parse(dr["CategoryTypeID"].ToString())); } } UserCategoryEntity userCat = new UserCategoryEntity(); userCat.CategoryTypeName = name; userCat.UserID = userId; userCat.CategoryTypeLive = 1; userCat.Synchronize = 1; int catTypeId = 0; bool success = UserCategoryAccess.InsertCategoryType(userCat, out catTypeId); if (!success) { throw new Exception(); } return(catTypeId); }
//添加类别操作 protected void Button1_Click(object sender, EventArgs e) { string catTypeName = this.CatTypeNameEmpIns.Text.Trim(); if (catTypeName == "") { Utility.Alert(this, "类别名称未填写!"); return; } string catTypePrice = this.CatTypePriceEmpIns.Text.Trim(); if (catTypePrice != "") { if (!ValidHelper.CheckDouble(catTypePrice)) { Utility.Alert(this, "类别预算填写错误!"); return; } } else { catTypePrice = "0"; } UserCategoryEntity userCat = new UserCategoryEntity(); userCat.CategoryTypeName = catTypeName; userCat.CategoryTypePrice = Double.Parse(catTypePrice); userCat.UserID = userId; userCat.CategoryTypeLive = 1; userCat.Synchronize = 1; int catTypeId = 0; bool success = UserCategoryAccess.InsertCategoryType(userCat, out catTypeId); if (success) { Utility.Alert(this, "添加成功。", "UserCategoryAdmin.aspx"); } else { Utility.Alert(this, "添加失败!"); } }