Example #1
0
    //取类别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);
    }
    //插入用户类别名称//输出类别ID用于数据导入时插入类别//
    public static bool InsertCategoryType(UserCategoryEntity userCat, out int catTypeId)
    {
        DbCommand comm = GenericDataAccess.CreateCommand();

        comm.CommandText = "InsertCategoryType_v4";
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@CategoryTypeName";
        param.Value         = userCat.CategoryTypeName;
        param.DbType        = DbType.String;
        param.Size          = 20;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypePrice";
        param.Value         = userCat.CategoryTypePrice;
        param.DbType        = DbType.Double;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@UserID";
        param.Value         = userCat.UserID;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeLive";
        param.Value         = userCat.CategoryTypeLive;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@Synchronize";
        param.Value         = userCat.Synchronize;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeID";
        param.Direction     = ParameterDirection.Output;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        catTypeId = 0;
        int result = -1;

        try
        {
            result    = GenericDataAccess.ExecuteNonQuery(comm);
            catTypeId = Int32.Parse(comm.Parameters["@CategoryTypeID"].Value.ToString());
        }
        catch
        {
        }

        return(catTypeId != 0);
    }
Example #3
0
    //更新同步类别//
    public static bool SyncCategoryUpdate(UserCategoryEntity userCat)
    {
        DbCommand comm = GenericDataAccess.CreateCommand();

        comm.CommandText = "SyncCategoryUpdate_v4";
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@CategoryTypeID";
        param.Value         = userCat.CategoryTypeID;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeName";
        param.Value         = userCat.CategoryTypeName;
        param.DbType        = DbType.String;
        param.Size          = 20;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypePrice";
        param.Value         = userCat.CategoryTypePrice;
        param.DbType        = DbType.Double;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@UserID";
        param.Value         = userCat.UserID;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeLive";
        param.Value         = userCat.CategoryTypeLive;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@Synchronize";
        param.Value         = userCat.Synchronize;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        int result = -1;

        try
        {
            result = GenericDataAccess.ExecuteNonQuery(comm);
        }
        catch
        {
        }

        return(result != -1);
    }
Example #4
0
    //删除用户类别名称//
    public static bool DeleteCategoryType(UserCategoryEntity userCat)
    {
        DbCommand comm = GenericDataAccess.CreateCommand();
        comm.CommandText = "DeleteCategoryType_v4";
        DbParameter param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeName";
        param.Value = userCat.CategoryTypeName;
        param.DbType = DbType.String;
        param.Size = 20;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypePrice";
        param.Value = userCat.CategoryTypePrice;
        param.DbType = DbType.Double;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@UserID";
        param.Value = userCat.UserID;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeID";
        param.Value = userCat.CategoryTypeID;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeLive";
        param.Value = userCat.CategoryTypeLive;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@Synchronize";
        param.Value = userCat.Synchronize;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        int result = -1;
        try
        {
            result = GenericDataAccess.ExecuteNonQuery(comm);
        }
        catch
        {
        }

        return (result != -1);
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int    catId    = Int32.Parse(Request.Form["catid"].ToString());
        string catName  = Request.Form["catname"].ToString();
        string catPrice = Request.Form["catprice"] ?? "";
        int    catLive  = Int32.Parse(Request.Form["catlive"].ToString());
        int    userId   = Int32.Parse(Request.Form["userid"].ToString());

        UserCategoryEntity userCat = new UserCategoryEntity();

        userCat.CategoryTypeID   = catId;
        userCat.CategoryTypeName = catName;
        if (catPrice != "")
        {
            userCat.CategoryTypePrice = Double.Parse(catPrice);
        }
        userCat.UserID           = userId;
        userCat.CategoryTypeLive = catLive;
        userCat.Synchronize      = 0;

        bool success = SyncHelper.SyncCheckCategoryIsExists(catId, userId);

        if (success)
        {
            success = SyncHelper.SyncCategoryUpdate(userCat);
        }
        else
        {
            success = SyncHelper.SyncCategoryInsert(userCat);
        }

        string result = "{";

        if (success)
        {
            result += "\"result\":\"ok\"";
        }
        else
        {
            result += "\"result\":\"error\"";
        }
        result += "}";

        Response.Write(result);
        Response.End();
    }
    //添加类别操作
    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, "添加失败!");
        }
    }
    //类别更新操作
    protected void CatTypeList_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int     catTypeId      = Int32.Parse(CatTypeList.DataKeys[e.RowIndex].Value.ToString());
        TextBox catTypeNameBox = (TextBox)CatTypeList.Rows[e.RowIndex].FindControl("CatTypeNameBox");
        string  catTypeName    = catTypeNameBox.Text.Trim();

        if (catTypeName == "")
        {
            Utility.Alert(this, "类别名称未填写!");
            return;
        }
        TextBox catTypePriceBox = (TextBox)CatTypeList.Rows[e.RowIndex].FindControl("CatTypePriceBox");
        string  catTypePrice    = catTypePriceBox.Text.Trim();

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

        UserCategoryEntity userCat = new UserCategoryEntity();

        userCat.CategoryTypeID    = catTypeId;
        userCat.CategoryTypeName  = catTypeName;
        userCat.CategoryTypePrice = Double.Parse(catTypePrice);
        userCat.UserID            = userId;
        userCat.CategoryTypeLive  = 1;
        userCat.Synchronize       = 1;

        bool success = UserCategoryAccess.UpdateCategoryType(userCat);

        if (success)
        {
            Utility.Alert(this, "更新成功。");

            CatTypeList.EditIndex = -1;
            BindGrid();
        }
        else
        {
            Utility.Alert(this, "更新失败!");
        }
    }
Example #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int catId = Int32.Parse(Request.Form["catid"].ToString());
        string catName = Request.Form["catname"].ToString();
        string catPrice = Request.Form["catprice"] ?? "";
        int catLive = Int32.Parse(Request.Form["catlive"].ToString());
        int userId = Int32.Parse(Request.Form["userid"].ToString());

        UserCategoryEntity userCat = new UserCategoryEntity();
        userCat.CategoryTypeID = catId;
        userCat.CategoryTypeName = catName;
        if (catPrice != "") userCat.CategoryTypePrice = Double.Parse(catPrice);
        userCat.UserID = userId;
        userCat.CategoryTypeLive = catLive;
        userCat.Synchronize = 0;

        bool success = SyncHelper.SyncCheckCategoryIsExists(catId, userId);
        if (success)
        {
            success = SyncHelper.SyncCategoryUpdate(userCat);
        }
        else
        {
            success = SyncHelper.SyncCategoryInsert(userCat);
        }

        string result = "{";
        if (success)
        {
            result += "\"result\":\"ok\"";
        }
        else
        {
            result += "\"result\":\"error\"";
        }
        result += "}";

        Response.Write(result);
        Response.End();
    }
Example #9
0
    //添加类别操作
    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, "添加失败!");
        }
    }
    //类别删除操作
    protected void CatTypeList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int    catTypeId    = Int32.Parse(CatTypeList.DataKeys[e.RowIndex].Value.ToString());
        string catTypeName  = ((Label)CatTypeList.Rows[e.RowIndex].FindControl("CatTypeNameLab")).Text;
        string catTypePrice = ((Label)CatTypeList.Rows[e.RowIndex].FindControl("CatTypePriceLab")).Text;

        UserCategoryEntity userCat = new UserCategoryEntity();

        userCat.CategoryTypeID    = catTypeId;
        userCat.CategoryTypeName  = catTypeName;
        userCat.CategoryTypePrice = Double.Parse(catTypePrice);
        userCat.UserID            = userId;
        userCat.CategoryTypeLive  = 0;
        userCat.Synchronize       = 1;

        bool success = UserCategoryAccess.CheckItemListByCatId(userId, catTypeId);

        if (!success)
        {
            success = UserCategoryAccess.DeleteCategoryType(userCat);
            if (success)
            {
                Utility.Alert(this, "删除成功。");

                CatTypeList.EditIndex = -1;
                BindGrid();
            }
            else
            {
                Utility.Alert(this, "删除失败!");
            }
        }
        else
        {
            Utility.Alert(this, "不能删除已使用的类别!");
        }
    }
Example #11
0
    //类别删除操作
    protected void CatTypeList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int catTypeId = Int32.Parse(CatTypeList.DataKeys[e.RowIndex].Value.ToString());
        string catTypeName = ((Label)CatTypeList.Rows[e.RowIndex].FindControl("CatTypeNameLab")).Text;
        string catTypePrice = ((Label)CatTypeList.Rows[e.RowIndex].FindControl("CatTypePriceLab")).Text;

        UserCategoryEntity userCat = new UserCategoryEntity();
        userCat.CategoryTypeID = catTypeId;
        userCat.CategoryTypeName = catTypeName;
        userCat.CategoryTypePrice = Double.Parse(catTypePrice);
        userCat.UserID = userId;
        userCat.CategoryTypeLive = 0;
        userCat.Synchronize = 1;

        bool success = UserCategoryAccess.CheckItemListByCatId(userId, catTypeId);
        if (!success)
        {
            success = UserCategoryAccess.DeleteCategoryType(userCat);
            if (success)
            {
                Utility.Alert(this, "删除成功。");

                CatTypeList.EditIndex = -1;
                BindGrid();
            }
            else
            {
                Utility.Alert(this, "删除失败!");
            }
        }
        else
        {
            Utility.Alert(this, "不能删除已使用的类别!");
        }
    }
Example #12
0
    //类别更新操作
    protected void CatTypeList_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int catTypeId = Int32.Parse(CatTypeList.DataKeys[e.RowIndex].Value.ToString());
        TextBox catTypeNameBox = (TextBox)CatTypeList.Rows[e.RowIndex].FindControl("CatTypeNameBox");
        string catTypeName = catTypeNameBox.Text.Trim();
        if (catTypeName == "")
        {
            Utility.Alert(this, "类别名称未填写!");
            return;
        }
        TextBox catTypePriceBox = (TextBox)CatTypeList.Rows[e.RowIndex].FindControl("CatTypePriceBox");
        string catTypePrice = catTypePriceBox.Text.Trim();
        if (!ValidHelper.CheckDouble(catTypePrice))
        {
            Utility.Alert(this, "类别预算填写错误!");
            return;
        }

        UserCategoryEntity userCat = new UserCategoryEntity();
        userCat.CategoryTypeID = catTypeId;
        userCat.CategoryTypeName = catTypeName;
        userCat.CategoryTypePrice = Double.Parse(catTypePrice);
        userCat.UserID = userId;
        userCat.CategoryTypeLive = 1;
        userCat.Synchronize = 1;

        bool success = UserCategoryAccess.UpdateCategoryType(userCat);
        if (success)
        {
            Utility.Alert(this, "更新成功。");

            CatTypeList.EditIndex = -1;
            BindGrid();
        }
        else
        {
            Utility.Alert(this, "更新失败!");
        }
    }
Example #13
0
    //取类别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;
    }
Example #14
0
    //插入用户类别名称//输出类别ID用于数据导入时插入类别//
    public static bool InsertCategoryType(UserCategoryEntity userCat, out int catTypeId)
    {
        DbCommand comm = GenericDataAccess.CreateCommand();
        comm.CommandText = "InsertCategoryType_v4";
        DbParameter param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeName";
        param.Value = userCat.CategoryTypeName;
        param.DbType = DbType.String;
        param.Size = 20;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypePrice";
        param.Value = userCat.CategoryTypePrice;
        param.DbType = DbType.Double;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@UserID";
        param.Value = userCat.UserID;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeLive";
        param.Value = userCat.CategoryTypeLive;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@Synchronize";
        param.Value = userCat.Synchronize;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        param = comm.CreateParameter();
        param.ParameterName = "@CategoryTypeID";
        param.Direction = ParameterDirection.Output;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);

        catTypeId = 0;
        int result = -1;
        try
        {
            result = GenericDataAccess.ExecuteNonQuery(comm);
            catTypeId = Int32.Parse(comm.Parameters["@CategoryTypeID"].Value.ToString());
        }
        catch
        {
        }

        return (catTypeId != 0);
    }