Beispiel #1
0
    /// <summary>
    /// 删除产品类
    /// </summary>
    /// <param name="id">产品ID</param>
    private void deleteFold(int id)
    {
        string productList = string.Empty;
        //检查某产品类是否发生了业务
        bool delFlag = AddNewProductBLL.CheckProductKindWheatherHasOperation(id, out productList);

        if (delFlag)
        {
            this.lblMessage.Text = GetTran("003256", "该产品类已有业务发生,因此不能删除!");
            return;
        }

        using (SqlConnection conn = new SqlConnection(DBHelper.connString))
        {
            conn.Open();
            using (SqlTransaction tran = conn.BeginTransaction())
            {
                try
                {
                    // before delete
                    ChangeLogs cl = new ChangeLogs("Product", "ltrim(rtrim(ProductID))");
                    cl.AddRecordtran(tran, id.ToString());

                    ///删除产品类以及该产品类所属的产品
                    AddNewProductBLL.DelProductKindByID(tran, productList);

                    cl.DeletedIntoLogstran(tran, ChangeCategory.company7, Session["Company"].ToString(), ENUM_USERTYPE.objecttype1);

                    ///提交事务
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    lblMessage.Text = GetTran("003258", "产品类删除失败,请联系管理员!");
                    return;
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        this.lblMessage.Text = GetTran("003260", "产品类删除成功!");
    }
Beispiel #2
0
    /// <summary>
    /// 删除指定产品
    /// </summary>
    /// <param name="id">产品ID</param>
    private void deleteItem(int id)
    {
        ///检查某产品是否放生了业务
        if (AddNewProductBLL.CheckProductWheatherHasOperation(id))
        {
            lblMessage.Text = GetTran("003252", "对不起,该产品已有业务发生,因此不能删除!");
            return;
        }

        using (SqlConnection conn = new SqlConnection(DBHelper.connString))
        {
            conn.Open();
            using (SqlTransaction tran = conn.BeginTransaction())
            {
                try
                {
                    // before delete
                    ChangeLogs cl = new ChangeLogs("Product", "ltrim(rtrim(ProductID))");
                    cl.AddRecordtran(tran, Convert.ToString(id));
                    //删除指定产品
                    AddNewProductBLL.DelProductByID(tran, id);

                    cl.DeletedIntoLogstran(tran, ChangeCategory.company7, Session["Company"].ToString(), ENUM_USERTYPE.objecttype1);
                    //提交事务
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    lblMessage.Text = GetTran("003254", "产品删除失败,请联系管理员!");
                    return;
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        lblMessage.Text = GetTran("003255", "产品删除成功");
    }