protected void ToSave(object sender, EventArgs e) { sSQL = "select * from _LookUpType where iID='" + TextBox1.Text + "'"; DataTable dt = clsSQLCommond.ExecQuery(sSQL); if (YxBtn.HidID != "" && dt.Rows.Count > 0) { OpenWindow ow = new OpenWindow(); ow.Alert(Page, "序号重复"); } else { SqlConnection con = new SqlConnection(clsSQLCommond.Online); SqlCommand cmd = new SqlCommand(); SqlTransaction trans; con.Open(); cmd.Connection = con; trans = con.BeginTransaction(); cmd.Transaction = trans; try { #region 主表 Sql sc = new Sql(); if (YxBtn.HidID == "") { sc.Get(tablename, tableid, TextBox1.Text, true); } else { sc.Get(tablename, tableid, TextBox1.Text, false); } sc.ToString("iType", TextBox2.Text); sc.ToString("iType2", TextBox3.Text); sc.ToString("Remark", TextBox7.Text); cmd.CommandText = sc.ReturnSql(); cmd.ExecuteNonQuery(); #endregion trans.Commit(); } catch { trans.Rollback(); Response.Redirect("../ErrorPage.aspx"); } finally { if (con.State == ConnectionState.Open) { con.Close(); } Response.Redirect("LookUpType_Index.aspx"); } } }
protected void ToDel(object sender, EventArgs e) { if (IsUsed(hidiType.Value, YxBtn.HidID) == false || CheckBox5.Checked == true) { OpenWindow ow = new OpenWindow(); ow.Alert(Page, "已使用或系统项,不可删除"); } else { SqlConnection con = new SqlConnection(clsSQLCommond.Online); SqlCommand cmd = new SqlCommand(); SqlTransaction trans; con.Open(); cmd.Connection = con; trans = con.BeginTransaction(); cmd.Transaction = trans; try { sSQL = "delete from " + tablename + " where " + tableid + "='" + YxBtn.HidID + "' and iType='" + hidiType.Value + "'"; cmd.CommandText = sSQL; cmd.ExecuteNonQuery(); trans.Commit(); } catch { trans.Rollback(); Response.Redirect("../ErrorPage.aspx"); } finally { if (con.State == ConnectionState.Open) { con.Close(); } Response.Redirect("LookUpData_Index.aspx"); } } }