Permalink
Browse files

修改好

  • Loading branch information...
1 parent 6b2e5c7 commit c28fa90798e9ea9ad32766767968311bbefaa8c3 qicb committed Oct 24, 2012
Showing with 30 additions and 43 deletions.
  1. +16 −29 Application/Code/SqlHelper.cs
  2. +8 −8 Application/frmAddRoutName.cs
  3. +6 −6 Application/frmAddRoute.cs
@@ -175,7 +175,7 @@ private static void PrepareCommand(SqlCommand command, SqlConnection connection,
/// <returns></returns>
public static int ExecuteNonQuery(string commandText)
{
- return ExecuteNonQuery(sqlConnectionStr,CommandType.Text,commandText);
+ return ExecuteNonQuery(sqlConnectionStr,CommandType.Text,commandText,(SqlParameter[])null);
}
/// <summary>
/// 执行但参数的sql数据
@@ -187,21 +187,19 @@ public static int ExecuteNonQuery(string commandText, params SqlParameter[] comm
{
return ExecuteNonQuery(sqlConnectionStr, CommandType.Text, commandText,commandParameters);
}
+
/// <summary>
- /// 执行指定连接字符串,类型的SqlCommand.
+ /// 执行存储过程
/// </summary>
- /// <remarks>
- /// 示例:
- /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders");
- /// </remarks>
- /// <param name="connectionString">一个有效的数据库连接字符串</param>
- /// <param name="commandType">命令类型 (存储过程,命令文本, 其它.)</param>
- /// <param name="commandText">存储过程名称或SQL语句</param>
- /// <returns>返回命令影响的行数</returns>
- public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText)
+ /// <param name="spName"></param>
+ /// <param name="commandType"></param>
+ /// <param name="parameterValues"></param>
+ /// <returns></returns>
+ public static int ExecuteNonQuery(string spName, CommandType commandType, params SqlParameter[] parameterValues)
{
- return ExecuteNonQuery(connectionString, commandType, commandText, (SqlParameter[])null);
- }
+ return ExecuteNonQuery(sqlConnectionStr, CommandType.StoredProcedure, spName, parameterValues);
+ }
+
/// <summary>
/// 执行指定连接字符串,类型的SqlCommand.如果没有提供参数,不返回结果.
@@ -225,20 +223,13 @@ public static int ExecuteNonQuery(string connectionString, CommandType commandTy
}
}
- public static int RunPredure(string spName, params object[] parameterValues)
- {
- return ExecuteNonQuery(sqlConnectionStr,spName,parameterValues);
- }
+
+
/// <summary>
- /// 执行指定连接字符串的存储过程,将对象数组的值赋给存储过程参数,
+ ///执行指定连接字符串的存储过程,将对象数组的值赋给存储过程参数,
/// 此方法需要在参数缓存方法中探索参数并生成参数.
/// </summary>
- /// <remarks>
- /// 这个方法没有提供访问输出参数和返回值.
- /// 示例:
- /// int result = ExecuteNonQuery(connString, "PublishOrders", 24, 36);
- /// </remarks>
- /// <param name="connectionString">一个有效的数据库连接字符串/param>
+ /// <param name="connectionString">一个有效的数据库连接字符串</param>
/// <param name="spName">存储过程名称</param>
/// <param name="parameterValues">分配到存储过程输入参数的对象数组</param>
/// <returns>返回受影响的行数</returns>
@@ -342,14 +333,10 @@ public static int ExecuteNonQuery(SqlConnection connection, string spName, param
/// <summary>
/// 执行带事务的SqlCommand.
/// </summary>
- /// <remarks>
- /// 示例.:
- /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders");
- /// </remarks>
/// <param name="transaction">一个有效的数据库连接对象</param>
/// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param>
/// <param name="commandText">存储过程名称或T-SQL语句</param>
- /// <returns>返回影响的行数/returns>
+ /// <returns>返回影响的行数</returns>
public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText)
{
return ExecuteNonQuery(transaction, commandType, commandText, (SqlParameter[])null);
@@ -27,14 +27,14 @@ private void frmAddRoutName_Load(object sender, EventArgs e)
{
this.btnTrue.Text = "修改";
this.Text = "修改巡检路线";
- SqlDataReader dr = SqlHelper.ExecuteReader("Select Site_ID,Name,Alias,Code From CheckRoute Where ID="+routeID.ToString());
+ SqlDataReader dr = SqlHelper.ExecuteReader("Select Site_ID,Name,Alias,Sequence From CheckRoute Where ID="+routeID.ToString());
if (dr == null) return;
while (dr.Read())
{
this.cboSiteArea.SelectedValue = dr["Site_ID"];
this.tbRouteName.Text = dr["Name"].ToString();
this.tbRouteAlias.Text = dr["Alias"].ToString();
- this.cboInOrder.SelectedValue = dr["Code"].ToString();
+ this.cboInOrder.SelectedValue = dr["Sequence"].ToString();
}
dr.Dispose();
}
@@ -44,7 +44,7 @@ private void frmAddRoutName_Load(object sender, EventArgs e)
private void btnTrue_Click(object sender, EventArgs e)
{
int _ret=(int)SqlHelper.ExecuteScalar("Select Count(1) From CheckRoute Where Name='" + this.tbRouteName.Text.Trim() + "' and Site_ID=" + cboSiteArea.SelectedValue.ToString());
- if ( _ret!= 0)
+ if ( isEdit==false&&_ret!= 0)
{
MessageBox.Show("请确保路线名称的唯一性");
return;
@@ -55,15 +55,15 @@ private void btnTrue_Click(object sender, EventArgs e)
new SqlParameter("@name",this.tbRouteName.Text.Trim().ToString()),
new SqlParameter("@alias",this.tbRouteAlias.Text.Trim().ToString()),
new SqlParameter("@routeid",SqlDbType.BigInt),
- new SqlParameter("@code",SqlDbType.Int)
+ new SqlParameter("@sequence",SqlDbType.Int)
};
if (isEdit)
{
- strsql = "Update CheckRoute Set Site_ID=@id,[Name]=@name,Alias=@alias,Code=@code Where ID=@routeid";
+ strsql = "Update CheckRoute Set Site_ID=@id,[Name]=@name,Alias=@alias,Sequence=@sequence Where ID=@routeid";
}
else
- {
- strsql = "Insert Into CheckRoute(Site_ID,[Name],Alias,Code) Values(@id,@name,@alias,@code)";
+ {
+ strsql = "Insert Into CheckRoute(Site_ID,[Name],Alias,Sequence) Values(@id,@name,@alias,@sequence)";
}
pars[0].Value = cboSiteArea.SelectedValue.ToString();
@@ -81,7 +81,7 @@ private void btnClose_Click(object sender, EventArgs e)
private void cbo_init()
{
- DataSet ds = SqlHelper.ExecuteDataset("Select Code,Meaning From CheckInOrder");
+ DataSet ds = SqlHelper.ExecuteDataset("Select Code,Meaning From Codes where purpose='CheckSequence' ");
this.cboInOrder.DataSource = ds.Tables[0];
this.cboInOrder.DisplayMember = "Meaning";
this.cboInOrder.ValueMember = "Code";
View
@@ -233,7 +233,7 @@ private void btnSave_Click(object sender, EventArgs e)
pars[5].Value = parIndex;
pars[6].Value = tvLogicalPoint.Nodes[i].Index;
- int _ret = SqlHelper.RunPredure("LogicalPointItemControl", pars);
+ int _ret = SqlHelper.ExecuteNonQuery("LogicalPointItemControl",CommandType.StoredProcedure,pars);
}
}
@@ -259,7 +259,7 @@ private void getTvLogicalPoint(string route_id)
TreeNode tnode = new TreeNode();
tnode.Text = dr["Name"].ToString();
tnode.Tag = dr["PhysicalPoint_ID"].ToString();
- tnode = tvNodeAdd(tnode, "select l.ID as LIID,c.[Name],c.ID ,'' as Code from LogicalPoint_Item l ,CheckItem c where l.Item_ID=c.ID and l.ID=" + dr["ID"].ToString().Trim() + " order by l.inorder");
+ tnode = tvNodeAdd(tnode, "select l.ID as LIID,c.[Name],c.ID ,'' as Sequence from LogicalPoint_Item l ,CheckItem c where l.Item_ID=c.ID and l.ID=" + dr["ID"].ToString().Trim() + " order by l.inorder");
tvLogicalPoint.Nodes.Add(tnode);
}
if (chkLogicalPoint.Checked)
@@ -275,7 +275,7 @@ private void getTvPhysicalPoint()
TreeNode tnode = new TreeNode();
tnode.Text = dr["Name"].ToString();
tnode.Tag = dr["ID"].ToString();
- tnode = tvNodeAdd(tnode, "Select ID,Name,'' AS Code From CheckItem Where Phy_ID=" + dr["ID"].ToString().Trim());
+ tnode = tvNodeAdd(tnode, "Select ID,Name,'' AS Sequence From CheckItem Where Phy_ID=" + dr["ID"].ToString().Trim());
tvPhysicalPoint.Nodes.Add(tnode);
}
dr.Close();
@@ -290,10 +290,10 @@ public static void tvRouteInit(TreeView tvRoute)
TreeNode tnode = new TreeNode();
tnode.Text = dr["Name"].ToString();
tnode.Tag = dr["ID"].ToString();
- tnode = tvNodeAdd(tnode, "select ID,Name,''AS Code from Site where Company_ID='" + dr["ID"].ToString() + "'");
+ tnode = tvNodeAdd(tnode, "select ID,Name,''AS Sequence from Site where Company_ID='" + dr["ID"].ToString() + "'");
for (int i = 0; i < tnode.Nodes.Count; i++)
{
- (tnode.Nodes)[i] = tvNodeAdd((tnode.Nodes)[i], "Select ID,Name,Code from CheckRoute Where site_id=" + (tnode.Nodes)[i].Tag);
+ (tnode.Nodes)[i] = tvNodeAdd((tnode.Nodes)[i], "Select ID,Name,Sequence as Sequence from CheckRoute Where site_id=" + (tnode.Nodes)[i].Tag);
}
tvRoute.Nodes.Add(tnode);
}
@@ -315,7 +315,7 @@ private static TreeNode tvNodeAdd(TreeNode node, string comstr)
TreeNode tn = new TreeNode();
tn.Text = dr["Name"].ToString();
tn.Tag = dr["ID"];
- if (dr["Code"].ToString() == "1")
+ if (dr["Sequence"].ToString() == "1")
{
tn.ForeColor = Color.Red;
}

0 comments on commit c28fa90

Please sign in to comment.