private void deleteItem(int id) { using (SqlConnection conn = new SqlConnection(DBHelper.connString)) { conn.Open(); using (SqlTransaction tran = conn.BeginTransaction()) { try { ChangeLogs cl = new ChangeLogs("smscontent", "ltrim(rtrim(str(ProductID)))"); cl.AddRecordtran(tran, id.ToString()); SMScontentBLL.deleteSMScontent(tran, id); cl.AddRecordtran(tran, id.ToString()); cl.DeletedIntoLogs(ChangeCategory.company23, Session["Company"].ToString(), ENUM_USERTYPE.objecttype10); tran.Commit(); } catch { tran.Rollback(); lblMessage.Text = GetTran("007147", "短信删除失败,请联系管理员!"); return; } } } lblMessage.Text = GetTran("007146", "短信删除成功"); }
/// <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", "产品类删除成功!"); }
/// <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", "产品删除成功"); }