예제 #1
0
    //取类别ID
    private int GetCategoryTypeId(string catName)
    {
        catTypeList = cat_bll.GetUserCategoryList(userId);
        foreach (DataRow dr in catTypeList.Rows)
        {
            if (catName == dr["CategoryTypeName"].ToString())
            {
                return(Convert.ToInt32(dr["CategoryTypeID"]));
            }
        }

        UserCategoryInfo category = new UserCategoryInfo();

        category.CategoryTypeID    = cat_bll.GetMaxCategoryTypeId(userId);
        category.CategoryTypeName  = catName;
        category.CategoryTypePrice = 0m;
        category.UserID            = userId;
        category.CategoryTypeLive  = 1;
        category.Synchronize       = 1;
        category.ModifyDate        = DateTime.Now;

        bool success = cat_bll.InsertUserCategory(category);

        if (success)
        {
            return(category.CategoryTypeID);
        }
        else
        {
            throw new Exception();
        }
    }
예제 #2
0
        //添加类别操作
        protected void Button1_Click(object sender, EventArgs e)
        {
            string catTypeName  = this.CatTypeNameEmpIns.Text.Trim();
            string catTypePrice = this.CatTypePriceEmpIns.Text.Trim();

            if (catTypeName == "")
            {
                Utility.Alert(this, "类别名称未填写!");
                return;
            }

            if (catTypePrice != "")
            {
                if (!ValidHelper.CheckNumber(catTypePrice))
                {
                    Utility.Alert(this, "类别预算填写错误!");
                    return;
                }
            }
            else
            {
                catTypePrice = "0";
            }

            UserCategoryInfo category = bll.GetUserCategoryByName(userId, catTypeName);

            category.CategoryTypeID    = bll.GetMaxCategoryTypeId(userId);
            category.CategoryTypeName  = catTypeName;
            category.CategoryTypePrice = Convert.ToInt32(catTypePrice);
            category.UserID            = userId;
            category.CategoryTypeLive  = 1;
            category.Synchronize       = 1;
            category.ModifyDate        = DateTime.Now;

            if (category.UserCategoryID > 0)
            {
                Utility.Alert(this, "类别已存在,不能重复添加!");
                return;
            }

            bool success = bll.InsertUserCategory(category);

            if (success)
            {
                Utility.Alert(this, "添加成功。", "UserCategoryAdmin.aspx");
            }
            else
            {
                Utility.Alert(this, "添加失败!");
            }
        }