private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('&'); int id = int.Parse(str[0].Split('=')[1]); string cdh = str[1].Split('=')[1]; if (string.IsNullOrEmpty(cdh)) { HttpContext.Current.Response.Write("1"); return; } DataTable dt = new DataTable(); dt = SqlHelper.GetTable("select * from xhqzb where cdh='" + cdh + "'"); if (dt.Rows.Count == 0) { HttpContext.Current.Response.Write("2"); return; } string dsj = ""; sys ex = new sys(); if (ex.isDate(str[2].Split('=')[1]) == true) { dsj = str[2].Split('=')[1].Replace("+", " "); } string csbbh = str[3].Split('=')[1]; if (string.IsNullOrEmpty(csbbh)) { HttpContext.Current.Response.Write("3"); return; } string isbid = ""; dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "'"); if (dt.Rows.Count == 0) { HttpContext.Current.Response.Write("4"); return; } else { isbid = dt.Rows[0]["id"].ToString(); } string csbmc = str[4].Split('=')[1]; if (string.IsNullOrEmpty(csbmc)) { HttpContext.Current.Response.Write("5"); return; } string cscx = str[5].Split('=')[1]; string iyz = str[6].Split('=')[1]; string iqzz = str[7].Split('=')[1]; string cyy = str[8].Split('=')[1]; string czt = str[9].Split('=')[1]; string czdr = str[10].Split('=')[1]; if (string.IsNullOrEmpty(czdr) || czdr.Trim() == "") { HttpContext.Current.Response.Write("9"); return; } string cczy = str[11].Split('=')[1]; string cfzry = str[12].Split('=')[1]; string cbz = str[13].Split('=')[1]; string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parms = { new SqlParameter("@dh", cdh), new SqlParameter("@sj", dsj), new SqlParameter("@sbid", isbid), new SqlParameter("@yz", iyz), new SqlParameter("@qzz", iqzz), new SqlParameter("@yy", cyy), new SqlParameter("@zt", czt), new SqlParameter("@zdr", czdr), new SqlParameter("@bz", cbz), new SqlParameter("@fzry", cfzry), new SqlParameter("@czy", cczy), new SqlParameter("@id", id) }; cmd.CommandText = "update_xhqz"; cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms) { cmd.Parameters.Add(p); } cmd.ExecuteNonQuery(); //履历表 SqlParameter[] parm_llb = { new SqlParameter("@xmid", id), new SqlParameter("@sbid", isbid), new SqlParameter("@zysj", dsj), new SqlParameter("@zyxm", "强制"), new SqlParameter("@zyry", czdr), new SqlParameter("@czy", cczy), new SqlParameter("@zynr", cyy) }; SqlCommand com = new SqlCommand(); com.Connection = con; //获取数据连接 com.Transaction = sqltra; //,在执行SQL时 com.CommandText = "update_llb"; com.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm_llb) { com.Parameters.Add(p); } com.ExecuteNonQuery(); sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("修改成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('&'); int id = int.Parse(str[0].Split('=')[1]); string csbbh = str[1].Split('=')[1]; if (string.IsNullOrEmpty(csbbh) || csbbh == "") { HttpContext.Current.Response.Write("1"); return; } DataTable dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "' and id<>" + id); if (dt.Rows.Count == 0) { HttpContext.Current.Response.Write("2"); return; } string rq = ""; sys ex = new sys(); if (ex.isDate(str[5].Split('=')[1]) == true) { rq = str[5].Split('=')[1]; } string csxlx = str[6].Split('=')[1]; string cczy = str[9].Split('=')[1]; string csxnr = str[10].Split('=')[1]; string cclfs = str[11].Split('=')[1]; string cdbr = str[7].Split('=')[1]; string czt = str[8].Split('=')[1]; SqlParameter[] parms = { new SqlParameter("@rq", rq), new SqlParameter("@sbbh", csbbh), new SqlParameter("@sxlx", csxlx), new SqlParameter("@sxnr", csxnr), new SqlParameter("@clfs", cclfs), new SqlParameter("@dbr", cdbr), new SqlParameter("@czy", cczy), new SqlParameter("@zt", czt), new SqlParameter("@id", id) }; bool flag = SqlHelper.ExeNonQuery("update_dbsx", CommandType.StoredProcedure, parms); if (flag) { HttpContext.Current.Response.Write("修改成功!"); } else { HttpContext.Current.Response.Write("修改失败!"); } } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
//添加 private void Add() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('&'); sys ex = new sys(); string drq = ""; //查找id最大值 Int64 id = 0; DataTable dt = new DataTable(); dt = SqlHelper.GetTable("select max(id) as maxid from gcstzb"); if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["maxid"].ToString())) { id = Int64.Parse(dt.Rows[0]["maxid"].ToString()) + 1; } else { id = 1; } } else { id = 1; } dt = null; if (ex.isDate(str[1].Split('=')[1]) == true) { drq = str[1].Split('=')[1]; } string dx = str[2].Split('=')[1]; string cdxmc = ""; if (str[3].Split('=')[1].Trim().Length > 0) { cdxmc = str[3].Split('=')[1]; } if (str[4].Split('=')[1].Trim().Length > 0) { cdxmc = str[4].Split('=')[1]; } string cjl = str[5].Split('=')[1]; string cczy = str[6].Split('=')[1]; string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parm = { new SqlParameter("@id", id), new SqlParameter("@rq", drq), new SqlParameter("@dx", dx), new SqlParameter("@dxmc", cdxmc), new SqlParameter("@jl", cjl), new SqlParameter("@czy", cczy) }; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "insert_gcstz"; foreach (SqlParameter p in parm) { cmd.Parameters.Add(p); } cmd.ExecuteNonQuery(); cmd.Dispose(); //临时表 string[] strr = cdxmc.Split(','); int len = strr.Length; string value = ""; if (len > 0) { //员工分割 for (int i = 0; i < len; i++) { value = strr[i].Split('-')[0]; SqlParameter[] parms = { new SqlParameter("@id", id), new SqlParameter("@rq", drq), new SqlParameter("@dx", dx), new SqlParameter("@dxmc", value), new SqlParameter("@jl", cjl), new SqlParameter("@czy", cczy) }; SqlCommand cmds = new SqlCommand(); cmds.Connection = con; //获取数据连接 cmds.Transaction = sqltra; //,在执行SQL时 cmds.CommandType = CommandType.StoredProcedure; cmds.CommandText = "insert_tmp_gcstz"; foreach (SqlParameter p in parms) { cmds.Parameters.Add(p); } cmds.ExecuteNonQuery(); cmds.Dispose(); } } sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("添加成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('&'); int id = int.Parse(str[0].Split('=')[1]); sys ex = new sys(); string drq = ""; if (ex.isDate(str[1].Split('=')[1]) == true) { drq = str[1].Split('=')[1]; } string dx = str[2].Split('=')[1]; string cdxmc = ""; if (str[3].Split('=')[1].Trim().Length > 0) { cdxmc = str[3].Split('=')[1]; } if (str[4].Split('=')[1].Trim().Length > 0) { cdxmc = str[4].Split('=')[1]; } string cjl = str[5].Split('=')[1]; string cczy = str[6].Split('=')[1]; string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parm = { new SqlParameter("@rq", drq), new SqlParameter("@dx", dx), new SqlParameter("@dxmc", cdxmc), new SqlParameter("@jl", cjl), new SqlParameter("@czy", cczy), new SqlParameter("@id", id) }; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "update_gcstz"; foreach (SqlParameter p in parm) { cmd.Parameters.Add(p); } cmd.ExecuteNonQuery(); cmd.Dispose(); //临时工程师通知 string sql = "delete from tmp_gcstzb where id=" + id; cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); //临时表 string[] strr = cdxmc.Split(','); int len = strr.Length; string value = ""; if (len > 0) { //员工分割 for (int i = 0; i < len; i++) { value = strr[i].Split('-')[0]; SqlParameter[] parms = { new SqlParameter("@id", id), new SqlParameter("@rq", drq), new SqlParameter("@dx", dx), new SqlParameter("@dxmc", value), new SqlParameter("@jl", cjl), new SqlParameter("@czy", cczy) }; SqlCommand cmds = new SqlCommand(); cmds.Connection = con; //获取数据连接 cmds.Transaction = sqltra; //,在执行SQL时 cmds.CommandType = CommandType.StoredProcedure; cmds.CommandText = "insert_tmp_gcstz"; foreach (SqlParameter p in parms) { cmds.Parameters.Add(p); } cmds.ExecuteNonQuery(); cmds.Dispose(); } } sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("修改成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
/// <summary> /// 高级查询 /// </summary> /// <returns></returns> public void Search() { try { //一页显示几行数据 string rows = HttpContext.Current.Request["rows"]; //当前页 string page = HttpContext.Current.Request["page"]; string value = HttpContext.Current.Request["data"]; string[] strr = value.Split('&'); string s_where = "1=1"; string s_csbbh = strr[0].Split('=')[1]; if (s_csbbh.Trim().Length > 0) { s_where = s_where + " and csbbh like '%" + s_csbbh + "%'"; } string s_csbmc = strr[1].Split('=')[1]; if (s_csbmc.Trim().Length > 0) { s_where = s_where + " and csbmc like '%" + s_csbmc + "%'"; } string s_csszy = strr[2].Split('=')[1]; if (s_csszy.Trim().Length > 0) { s_where = s_where + " and izyid='" + s_csszy + "'"; } string s_cscx = strr[3].Split('=')[1]; if (s_cscx.Trim().Length > 0) { s_where = s_where + " and iscxid = '" + s_cscx + "'"; } string s_cjllx = strr[4].Split('=')[1]; if (s_cjllx.Trim().Length > 0) { s_where = s_where + " and typename like '%" + s_cjllx + "%'"; } string s_cdjr = strr[5].Split('=')[1]; if (s_cdjr.Trim().Length > 0) { s_where = s_where + " and cdjr like '%" + s_cdjr + "%'"; } sys ex = new sys(); string s_dtp1 = strr[6].Split('=')[1]; if (ex.isDate(s_dtp1) == true) { s_dtp1 = s_dtp1.Replace("+", " "); //替换+为空,日期提交后格式为:2016-05-30+10:00:00 if (s_dtp1.Trim().Length > 0) { s_where = s_where + " and drq>= '" + s_dtp1 + "'"; } } string s_dtp2 = strr[7].Split('=')[1]; if (ex.isDate(s_dtp2) == true) { s_dtp2 = s_dtp2.Replace("+", " "); if (s_dtp2.Trim().Length > 0) { s_where = s_where + " and drq<= '" + s_dtp2 + "'"; } } DataSet duser = SqlHelper.GetList("v_djjl", "*", "id", int.Parse(rows), int.Parse(page), false, true, s_where); DataTable dt1 = duser.Tables[0]; //获取数据源 DataTable dt = SqlHelper.GetTable("select * from v_djjl where " + s_where + " order by drq desc"); string str = string.Empty; //将数据转换成json格式 str = JSonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count); HttpContext.Current.Response.Write(str); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('@'); int id = int.Parse(str[1]); string csbbh = str[2]; if (csbbh.Trim() == "") { HttpContext.Current.Response.Write("1"); return; } DataTable dt = SqlHelper.GetTable("select * from sbzlb where DeviceId='" + csbbh + "'"); if (dt.Rows.Count == 0) { HttpContext.Current.Response.Write("2"); return; } if (str[3] == "") { HttpContext.Current.Response.Write("3"); return; } sys ex = new sys(); string drq = ""; if (ex.isDate(str[3]) == true) { drq = str[3]; } string cdjr = str[4]; string cbz = str[5]; string cstr1 = str[6]; string cstr2 = str[7]; string cstr3 = str[8]; string cstr4 = str[9]; string cstr5 = str[10]; string cstr6 = str[11]; string cstr7 = str[12]; string cstr8 = str[13]; string cstr9 = str[14]; string cstr10 = str[15]; string bbool1 = str[16]; string bbool2 = str[17]; string bbool3 = str[18]; string bbool4 = str[19]; string bbool5 = str[20]; string bbool6 = str[21]; string bbool7 = str[22]; string bbool8 = str[23]; string bbool9 = str[24]; string bbool10 = str[25]; string inumber1 = str[26]; string inumber2 = str[27]; string inumber3 = str[28]; string inumber4 = str[29]; string inumber5 = str[30]; string inumber6 = str[31]; string inumber7 = str[32]; string inumber8 = str[33]; string inumber9 = str[34]; string inumber10 = str[35]; SqlParameter[] parms = { new SqlParameter("@sbbh", csbbh), new SqlParameter("@rq", drq), new SqlParameter("@djr", cdjr), new SqlParameter("@bz", cbz), new SqlParameter("@cstr1", cstr1), new SqlParameter("@cstr2", cstr2), new SqlParameter("@cstr3", cstr3), new SqlParameter("@cstr4", cstr4), new SqlParameter("@cstr5", cstr5), new SqlParameter("@cstr6", cstr6), new SqlParameter("@cstr7", cstr7), new SqlParameter("@cstr8", cstr8), new SqlParameter("@cstr9", cstr9), new SqlParameter("@cstr10", cstr10), new SqlParameter("@bBool1", bbool1), new SqlParameter("@bBool2", bbool2), new SqlParameter("@bBool3", bbool3), new SqlParameter("@bBool4", bbool4), new SqlParameter("@bBool5", bbool5), new SqlParameter("@bBool6", bbool6), new SqlParameter("@bBool7", bbool7), new SqlParameter("@bBool8", bbool8), new SqlParameter("@bBool9", bbool9), new SqlParameter("@bBool10", bbool10), new SqlParameter("@iNumber1", inumber1), new SqlParameter("@iNumber2", inumber2), new SqlParameter("@iNumber3", inumber3), new SqlParameter("@iNumber4", inumber4), new SqlParameter("@iNumber5", inumber5), new SqlParameter("@iNumber6", inumber6), new SqlParameter("@iNumber7", inumber7), new SqlParameter("@iNumber8", inumber8), new SqlParameter("@iNumber9", inumber9), new SqlParameter("@iNumber10", inumber10), new SqlParameter("@id", id) }; bool flag = SqlHelper.ExeNonQuery("update_djjl", CommandType.StoredProcedure, parms); if (flag) { HttpContext.Current.Response.Write("修改成功!"); } else { HttpContext.Current.Response.Write("修改失败!"); } } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('&'); int id = int.Parse(str[0].Split('=')[1]); string cygbh = str[1].Split('=')[1]; if (string.IsNullOrEmpty(cygbh)) { HttpContext.Current.Response.Write("1"); return; } DataTable dt = new DataTable(); dt = SqlHelper.GetTable("select * from ygzlb where cygbh='" + cygbh + "' and id<>" + id); if (dt.Rows.Count > 0) { HttpContext.Current.Response.Write("2"); return; } string cygxm = str[2].Split('=')[1]; if (string.IsNullOrEmpty(cygxm)) { HttpContext.Current.Response.Write("3"); return; } string cdlmm = str[3].Split('=')[1]; int ibmid = int.Parse(str[4].Split('=')[1]); int izwid = int.Parse(str[5].Split('=')[1]); string cnl = str[6].Split('=')[1]; string cxb = str[7].Split('=')[1] == "1" ? "男" : "女"; string drzsj = ""; sys ex = new sys(); if (ex.isDate(str[8].Split('=')[1]) == true) { drzsj = str[8].Split('=')[1]; } string cbyyx = str[9].Split('=')[1]; string czy = str[10].Split('=')[1]; string csfzh = str[11].Split('=')[1]; string clxdh = str[12].Split('=')[1]; string cjjlxr = str[13].Split('=')[1]; string cjjlxrdh = str[14].Split('=')[1]; string cczyf = str[15].Split('=')[1] == "1" ? "是" : "否"; string cwxh = str[16].Split('=')[1]; if (cwxh.Trim().Length > 0) { //微信号不允许重复 dt = SqlHelper.GetTable("select * from ygzlb where cwxh='" + cwxh + "' and id<>" + id); if (dt.Rows.Count > 0) { HttpContext.Current.Response.Write("4"); return; } } string czt = str[17].Split('=')[1]; string cbz = str[18].Split('=')[1]; SqlParameter[] parms = { new SqlParameter("@ygbh", cygbh), new SqlParameter("@ygxm", cygxm), new SqlParameter("@dlmm", cdlmm), new SqlParameter("@bmid", ibmid), new SqlParameter("@zwid", izwid), new SqlParameter("@xb", cxb), new SqlParameter("@nl", cnl), new SqlParameter("@rzsj", drzsj), new SqlParameter("@byyx", cbyyx), new SqlParameter("@zy", czy), new SqlParameter("@sfzh", csfzh), new SqlParameter("@lxdh", clxdh), new SqlParameter("@jjlxr", cjjlxr), new SqlParameter("@jjlxrdh", cjjlxrdh), new SqlParameter("@czyf", cczyf), new SqlParameter("@wxh", cwxh), new SqlParameter("@bz", cbz), new SqlParameter("@zt", czt), new SqlParameter("@id", id) }; bool flag = SqlHelper.ExeNonQuery("update_ygzl", CommandType.StoredProcedure, parms); if (flag) { HttpContext.Current.Response.Write("修改成功!"); } else { HttpContext.Current.Response.Write("修改失败!"); } } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('~'); string[] strSb = str[0].Split('&'); //设备资料 int id = int.Parse(strSb[0].Split('=')[1]); string cgdh = strSb[1].Split('=')[1]; //工单号 DataTable dt = new DataTable(); dt = SqlHelper.GetTable("select * from zybyb where cgdh='" + cgdh + "' and id<>" + id); if (dt.Rows.Count > 0) { dt = null; HttpContext.Current.Response.Write("1"); return; } dt = null; sys ex = new sys(); string drq = ""; if (ex.isDate((strSb[2].Split('=')[1])) == true) { drq = strSb[2].Split('=')[1]; } string csbbh = strSb[3].Split('=')[1]; //设备编号 if (string.IsNullOrEmpty(csbbh)) { HttpContext.Current.Response.Write("2"); return; } string isbid = ""; dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "'"); if (dt.Rows.Count == 0) { HttpContext.Current.Response.Write("3"); return; } else { isbid = dt.Rows[0]["id"].ToString(); } string cscx = strSb[5].Split('=')[1]; //生产线 string czy = strSb[6].Split('=')[1]; //专业 string dbysj = ""; if (ex.isDate((strSb[7].Split('=')[1])) == true) { dbysj = strSb[7].Split('=')[1].Replace("+", " "); //保养时间 } string cbylx = strSb[8].Split('=')[1]; //保养类型 string cnrjl = strSb[9].Split('=')[1]; //内容记录 string dxcbysj = ""; //下次保养时间 if (ex.isDate((strSb[10].Split('=')[1])) == true) { dxcbysj = strSb[10].Split('=')[1].Replace("+", " "); } string cbyr = strSb[11].Split('=')[1]; //保养 if (string.IsNullOrEmpty(cbyr) || cbyr.Trim() == "") { HttpContext.Current.Response.Write("9"); return; } string cczy = strSb[12].Split('=')[1]; string cfzry = strSb[13].Split('=')[1]; string cbz = strSb[14].Split('=')[1]; //备注 string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parms = { new SqlParameter("@id", id), new SqlParameter("@gdh", cgdh), new SqlParameter("@sbid", isbid), new SqlParameter("@rq", drq), new SqlParameter("@bysj", dbysj), new SqlParameter("@bylx", cbylx), new SqlParameter("@nrjl", cnrjl), new SqlParameter("@xcbysj", dxcbysj), new SqlParameter("@byr", cbyr), new SqlParameter("@czy", cczy), new SqlParameter("@fzry", cfzry), new SqlParameter("@bz", cbz) }; cmd.CommandText = "update_zyby"; cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms) { cmd.Parameters.Add(p); } cmd.ExecuteNonQuery(); SqlParameter[] parm = { new SqlParameter("@byid", id) }; SqlCommand cmds = new SqlCommand(); cmds.Connection = con; //获取数据连接 cmds.Transaction = sqltra; //,在执行SQL时 cmds.CommandText = "update_zyby_mx"; cmds.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm) { cmds.Parameters.Add(p); } cmds.ExecuteNonQuery(); //履历表 SqlParameter[] parm_llb = { new SqlParameter("@xmid", id), new SqlParameter("@sbid", isbid), new SqlParameter("@zysj", drq), new SqlParameter("@zyxm", "保养"), new SqlParameter("@zyry", cbyr), new SqlParameter("@czy", cczy), new SqlParameter("@zynr", cnrjl) }; SqlCommand com = new SqlCommand(); com.Connection = con; //获取数据连接 com.Transaction = sqltra; //,在执行SQL时 com.CommandText = "update_llb"; com.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm_llb) { com.Parameters.Add(p); } com.ExecuteNonQuery(); //插入新的维修明细 int rCount = int.Parse(str[1].Split('*')[2]); if (rCount > 0) { string[] strBj = str[1].Split('*')[1].Split('@'); string[] value; string bjbh = ""; double sl = 0; string strSql = ""; //备件资料 for (int i = 0; i < rCount; i++) { value = strBj[i].Split('&'); bjbh = value[1]; if (bjbh.Trim() == "") { con.Close(); HttpContext.Current.Response.Write("4&" + (i + 1)); return; } ////判断部件编号是否存在 //strSql = "select * from sbbjb where cbjbh='" + bjbh + "'"; //int row = SqlHelper.ExecuteSql(strSql); //if (row == 0) //{ // con.Close(); // HttpContext.Current.Response.Write("5&" + (i + 1)); // return; //} if (value[2].Trim() == "") { con.Close(); HttpContext.Current.Response.Write("6&" + (i + 1)); return; } if (ex.isNumber(value[2]) == true) { sl = double.Parse(value[2]); } SqlParameter[] parms_mx = { new SqlParameter("@byid", id), new SqlParameter("@bjbh", bjbh), new SqlParameter("@sl", sl) }; SqlCommand cmd_mx = new SqlCommand(); cmd_mx.Connection = con; //获取数据连接 cmd_mx.Transaction = sqltra; //,在执行SQL时 cmd_mx.CommandText = "insert_zyby_mx"; cmd_mx.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms_mx) { cmd_mx.Parameters.Add(p); } cmd_mx.ExecuteNonQuery(); } } sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("修改成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('~'); string[] strT = str[0].Split('&'); //设备资料 int id = int.Parse(strT[0].Split('=')[1]); string clxmc = strT[1].Split('=')[1]; if (string.IsNullOrEmpty(clxmc)) { HttpContext.Current.Response.Write("1"); return; } DataTable dt = new DataTable(); dt = SqlHelper.GetTable("select * from djlxb where cdjlx='" + clxmc + "' and id<>" + id); if (dt.Rows.Count > 0) { HttpContext.Current.Response.Write("2"); return; } sys ex = new sys(); string drq = ""; if (ex.isDate((strT[2].Split('=')[1])) == true) { drq = strT[2].Split('=')[1]; } string csjz = strT[3].Split('=')[1]; //设计者 string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parms = { new SqlParameter("@id", id), new SqlParameter("@djlx", clxmc), new SqlParameter("@rq", drq), new SqlParameter("@sjz", csjz) }; SqlCommand com = new SqlCommand(); com.Connection = con; //获取数据连接 com.Transaction = sqltra; //,在执行SQL时 com.CommandText = "update_djlx"; com.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms) { com.Parameters.Add(p); } com.ExecuteNonQuery(); SqlParameter[] parm = { new SqlParameter("@lxid", id) }; SqlCommand comd = new SqlCommand(); comd.Connection = con; //获取数据连接 comd.Transaction = sqltra; //,在执行SQL时 comd.CommandText = "update_djlx_mx"; comd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm) { comd.Parameters.Add(p); } comd.ExecuteNonQuery(); //插入明细 int total = int.Parse(str[1].Split('*')[2]); string[] strSb = str[1].Split('*')[1].Split('@'); string[] strr; string csbbh = ""; Int64 ixh = 0; Int64 isbid = 0; string sql = ""; for (int i = 0; i < total; i++) { strr = strSb[i].Split('&'); if (ex.isNumber(strr[1]) == true) { ixh = Int64.Parse(strr[1]); } isbid = Int64.Parse(strr[2]); csbbh = strr[3]; //不合适的序号 if (ixh != i + 1) { con.Close(); HttpContext.Current.Response.Write("3&" + (i + 1)); return; } if (string.IsNullOrEmpty(csbbh)) { con.Close(); HttpContext.Current.Response.Write("4&" + (i + 1)); return; } ////判断部件编号是否存在 //sql = "select * from sbzlb where DeviceId='" + csbbh + "'"; //dt = SqlHelper.GetTable(sql); //if (dt.Rows.Count == 0) //{ // dt = null; //出错后释放 // con.Close(); // HttpContext.Current.Response.Write("5&" + (i + 1)); // return; //} //dt = null; SqlParameter[] parms_mx = { new SqlParameter("@lxid", id), new SqlParameter("@sbbh", csbbh), new SqlParameter("@xh", ixh) }; SqlCommand coms = new SqlCommand(); coms.Connection = con; //获取数据连接 coms.Transaction = sqltra; //,在执行SQL时 coms.CommandText = "insert_djlx_mx"; coms.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms_mx) { coms.Parameters.Add(p); } coms.ExecuteNonQuery(); } sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("修改成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
//添加 private void Add() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('&'); DataTable dt = new DataTable(); //查找id最大值 Int64 id = 0; dt = SqlHelper.GetTable("select max(id) as maxid from tjjlb"); if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["maxid"].ToString())) { id = Int64.Parse(dt.Rows[0]["maxid"].ToString()) + 1; } else { id = 1; } } else { id = 1; } dt = null; string cdh = str[1].Split('=')[1]; if (string.IsNullOrEmpty(cdh) || cdh == "") { HttpContext.Current.Response.Write("1"); return; } dt = SqlHelper.GetTable("select * from tjjlb where cdh='" + cdh + "'"); if (dt.Rows.Count > 0) { HttpContext.Current.Response.Write("2"); return; } sys ex = new sys(); string drq = ""; if (ex.isDate(str[2].Split('=')[1]) == true) { drq = str[2].Split('=')[1]; } string csbbh = str[3].Split('=')[1]; if (string.IsNullOrEmpty(csbbh) || csbbh == "") { HttpContext.Current.Response.Write("3"); return; } string isbid = ""; dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "'"); if (dt.Rows.Count == 0) { //设备编号不存在 HttpContext.Current.Response.Write("4"); return; } else { isbid = dt.Rows[0]["id"].ToString(); } string dkjrq = ""; if (ex.isDate(str[7].Split('=')[1]) == true) { dkjrq = str[7].Split('=')[1].Replace("+", " "); } string dtjrq = ""; if (ex.isDate(str[8].Split('=')[1]) == true) { dtjrq = str[8].Split('=')[1].Replace("+", " "); } string ctjzl = str[9].Split('=')[1]; string cxxms = str[10].Split('=')[1]; string cjjfa = str[11].Split('=')[1]; string cyyfx = str[12].Split('=')[1]; string cgsdc = str[13].Split('=')[1]; string ctjr = str[14].Split('=')[1]; //if (string.IsNullOrEmpty(ctjr) || ctjr.Trim() == "") //{ // HttpContext.Current.Response.Write("9"); // return; //} string cfzry = str[15].Split('=')[1]; string cczy = str[16].Split('=')[1]; string cbz = str[17].Split('=')[1]; string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parms = { new SqlParameter("@id", id), new SqlParameter("@dh", cdh), new SqlParameter("@rq", drq), new SqlParameter("@sbid", isbid), new SqlParameter("@tjzl", ctjzl), new SqlParameter("@kjrq", dkjrq), new SqlParameter("@tjrq", dtjrq), new SqlParameter("@xxms", cxxms), new SqlParameter("@jjfa", cjjfa), new SqlParameter("@yyfx", cyyfx), new SqlParameter("@gsdc", cgsdc), new SqlParameter("@tjr", ctjr), new SqlParameter("@fzry", cfzry), new SqlParameter("@czy", cczy), new SqlParameter("@bz", cbz) }; cmd.CommandText = "insert_tjjl"; cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms) { cmd.Parameters.Add(p); } cmd.ExecuteNonQuery(); //履历表 SqlParameter[] parm_llb = { new SqlParameter("@xmid", id), new SqlParameter("@sbid", isbid), new SqlParameter("@zysj", drq), new SqlParameter("@zyxm", "停机"), new SqlParameter("@zyry", ctjr), new SqlParameter("@czy", cczy), new SqlParameter("@zynr", cxxms) }; SqlCommand com = new SqlCommand(); com.Connection = con; //获取数据连接 com.Transaction = sqltra; //,在执行SQL时 com.CommandText = "insert_llb"; com.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm_llb) { com.Parameters.Add(p); } com.ExecuteNonQuery(); sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("添加成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('&'); int id = int.Parse(str[0].Split('=')[1]); string TypeName = str[1].Split('=')[1]; if (TypeName.Trim().Length == 0) { HttpContext.Current.Response.Write("1"); return; } //判断记录类型是否存在 DataTable dt = SqlHelper.GetTable("select * from CabinetRecordType where TypeName='" + TypeName + "' and id<>" + id); if (dt.Rows.Count > 0) { HttpContext.Current.Response.Write("3"); return; } string jlzy = str[2].Split('=')[1]; string TypeDesigner = str[3].Split('=')[1]; if (TypeDesigner.Trim().Length == 0) { HttpContext.Current.Response.Write("2"); return; } string DesignDate = ""; sys ex = new sys(); if (ex.isDate(str[4].Split('=')[1]) == true) { DesignDate = str[4].Split('=')[1]; } string ColumnInformation = str[5].Split('=')[1]; if (ColumnInformation.Trim().Length == 0) { HttpContext.Current.Response.Write("4"); return; } string[] strChar = ColumnInformation.Split('#')[0].Split('*'); int cnt = int.Parse(ColumnInformation.Split('#')[1]); string value = "<RecordColInfo Count=\"" + cnt + "\">"; string cstr1 = strChar[0].Split('@')[1]; if (cstr1 != "") { //输入双引号必须用在前面加字符\ value = value + "<cStr1 Type=\"System.String\">" + cstr1 + "</cStr1>"; } string cstr2 = strChar[1].Split('@')[1]; if (cstr2 != "") { value = value + "<cStr2 Type=\"System.String\">" + cstr2 + "</cStr2>"; } string cstr3 = strChar[2].Split('@')[1]; if (cstr3 != "") { value = value + "<cStr3 Type=\"System.String\">" + cstr3 + "</cStr3>"; } string cstr4 = strChar[3].Split('@')[1]; if (cstr4 != "") { value = value + "<cStr4 Type=\"System.String\">" + cstr4 + "</cStr4>"; } string cstr5 = strChar[4].Split('@')[1]; if (cstr5 != "") { value = value + "<cStr5 Type=\"System.String\">" + cstr5 + "</cStr5>"; } string cstr6 = strChar[5].Split('@')[1]; if (cstr6 != "") { value = value + "<cStr6 Type=\"System.String\">" + cstr6 + "</cStr6>"; } string cstr7 = strChar[6].Split('@')[1]; if (cstr7 != "") { value = value + "<cStr7 Type=\"System.String\">" + cstr7 + "</cStr7>"; } string cstr8 = strChar[7].Split('@')[1]; if (cstr8 != "") { value = value + "<cStr8 Type=\"System.String\">" + cstr8 + "</cStr8>"; } string cstr9 = strChar[8].Split('@')[1]; if (cstr9 != "") { value = value + "<cStr9 Type=\"System.String\">" + cstr9 + "</cStr9>"; } string cstr10 = strChar[9].Split('@')[1]; if (cstr10 != "") { value = value + "<cStr10 Type=\"System.String\">" + cstr10 + "</cStr10>"; } string bBool1 = strChar[10].Split('@')[1]; if (bBool1 != "") { value = value + "<bBool1 Type=\"System.Boolean\">" + bBool1 + "</bBool1>"; } string bBool2 = strChar[11].Split('@')[1]; if (bBool2 != "") { value = value + "<bBool2 Type=\"System.Boolean\">" + bBool2 + "</bBool2>"; } string bBool3 = strChar[12].Split('@')[1]; if (bBool3 != "") { value = value + "<bBool3 Type=\"System.Boolean\">" + bBool3 + "</bBool3>"; } string bBool4 = strChar[13].Split('@')[1]; if (bBool4 != "") { value = value + "<bBool4 Type=\"System.Boolean\">" + bBool4 + "</bBool4>"; } string bBool5 = strChar[14].Split('@')[1]; if (bBool5 != "") { value = value + "<bBool5 Type=\"System.Boolean\">" + bBool5 + "</bBool5>"; } string bBool6 = strChar[15].Split('@')[1]; if (bBool6 != "") { value = value + "<bBool6 Type=\"System.Boolean\">" + bBool6 + "</bBool6>"; } string bBool7 = strChar[16].Split('@')[1]; if (bBool7 != "") { value = value + "<bBool7 Type=\"System.Boolean\">" + bBool7 + "</bBool7>"; } string bBool8 = strChar[17].Split('@')[1]; if (bBool8 != "") { value = value + "<bBool8 Type=\"System.Boolean\">" + bBool8 + "</bBool8>"; } string bBool9 = strChar[18].Split('@')[1]; if (bBool9 != "") { value = value + "<bBool9 Type=\"System.Boolean\">" + bBool9 + "</bBool9>"; } string bBool10 = strChar[19].Split('@')[1]; if (bBool10 != "") { value = value + "<bBool10 Type=\"System.Boolean\">" + bBool10 + "</bBool10>"; } string iNumber1 = strChar[20].Split('@')[1]; if (iNumber1 != "") { value = value + "<iNumber1 Type=\"System.Decimal\">" + iNumber1 + "</iNumber1>"; } string iNumber2 = strChar[21].Split('@')[1]; if (iNumber2 != "") { value = value + "<iNumber2 Type=\"System.Decimal\">" + iNumber2 + "</iNumber2>"; } string iNumber3 = strChar[22].Split('@')[1]; if (iNumber3 != "") { value = value + "<iNumber3 Type=\"System.Decimal\">" + iNumber3 + "</iNumber3>"; } string iNumber4 = strChar[23].Split('@')[1]; if (iNumber4 != "") { value = value + "<iNumber4 Type=\"System.Decimal\">" + iNumber4 + "</iNumber4>"; } string iNumber5 = strChar[24].Split('@')[1]; if (iNumber5 != "") { value = value + "<iNumber5 Type=\"System.Decimal\">" + iNumber5 + "</iNumber5>"; } string iNumber6 = strChar[25].Split('@')[1]; if (iNumber6 != "") { value = value + "<iNumber6 Type=\"System.Decimal\">" + iNumber6 + "</iNumber6>"; } string iNumber7 = strChar[26].Split('@')[1]; if (iNumber7 != "") { value = value + "<iNumber7 Type=\"System.Decimal\">" + iNumber7 + "</iNumber7>"; } string iNumber8 = strChar[27].Split('@')[1]; if (iNumber8 != "") { value = value + "<iNumber8 Type=\"System.Decimal\">" + iNumber8 + "</iNumber8>"; } string iNumber9 = strChar[28].Split('@')[1]; if (iNumber9 != "") { value = value + "<iNumber9 Type=\"System.Decimal\">" + iNumber9 + "</iNumber9>"; } string iNumber10 = strChar[29].Split('@')[1]; if (iNumber10 != "") { value = value + "<iNumber10 Type=\"System.Decimal\">" + iNumber10 + "</iNumber10>"; } value = value + "</RecordColInfo>"; SqlParameter[] parms = { new SqlParameter("@TypeName", TypeName), new SqlParameter("@jlzy", jlzy), new SqlParameter("@TypeDesigner", TypeDesigner), new SqlParameter("@DesignDate", DesignDate), new SqlParameter("@ColumnInformation", value), new SqlParameter("@ColumnInformation2", ColumnInformation), new SqlParameter("@cstr1", cstr1), new SqlParameter("@cstr2", cstr2), new SqlParameter("@cstr3", cstr3), new SqlParameter("@cstr4", cstr4), new SqlParameter("@cstr5", cstr5), new SqlParameter("@cstr6", cstr6), new SqlParameter("@cstr7", cstr7), new SqlParameter("@cstr8", cstr8), new SqlParameter("@cstr9", cstr9), new SqlParameter("@cstr10", cstr10), new SqlParameter("@bBool1", bBool1), new SqlParameter("@bBool2", bBool2), new SqlParameter("@bBool3", bBool3), new SqlParameter("@bBool4", bBool4), new SqlParameter("@bBool5", bBool5), new SqlParameter("@bBool6", bBool6), new SqlParameter("@bBool7", bBool7), new SqlParameter("@bBool8", bBool8), new SqlParameter("@bBool9", bBool9), new SqlParameter("@bBool10", bBool10), new SqlParameter("@iNumber1", iNumber1), new SqlParameter("@iNumber2", iNumber2), new SqlParameter("@iNumber3", iNumber3), new SqlParameter("@iNumber4", iNumber4), new SqlParameter("@iNumber5", iNumber5), new SqlParameter("@iNumber6", iNumber6), new SqlParameter("@iNumber7", iNumber7), new SqlParameter("@iNumber8", iNumber8), new SqlParameter("@iNumber9", iNumber9), new SqlParameter("@iNumber10", iNumber10), new SqlParameter("@id", id) }; bool flag = SqlHelper.ExeNonQuery("update_CabinetRecordType", CommandType.StoredProcedure, parms); if (flag) { HttpContext.Current.Response.Write("修改成功!"); } else { HttpContext.Current.Response.Write("修改失败!"); } } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
////转单保存 //private void Add2() //{ // try // { // StringBuilder sb = new StringBuilder(); // //遍历获取传递过来的字符串 // foreach (string s in HttpContext.Current.Request.Form.AllKeys) // { // sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); // } // string ss = sb.ToString(); // string[] str = ss.Split('~'); // string[] strSb = str[0].Split('&'); //设备资料 // DataTable dt = new DataTable(); // //查找id最大值 // Int64 id = 0; // dt = SqlHelper.GetTable("select max(id) as maxid from ycjlb"); // if (dt.Rows.Count > 0) // { // if (!string.IsNullOrEmpty(dt.Rows[0]["maxid"].ToString())) // { // id = Int64.Parse(dt.Rows[0]["maxid"].ToString()) + 1; // } // else // { // id = 1; // } // } // else // { // id = 1; // } // dt = null; // string cgdh = strSb[1].Split('=')[1]; //工单号 // dt = SqlHelper.GetTable("select * from ycjlb where cgdh='" + cgdh + "'"); // if (dt.Rows.Count > 0) // { // dt = null; // HttpContext.Current.Response.Write("1"); // return; // } // dt = null; // sys ex = new sys(); // string drq = ""; // if (ex.isDate((strSb[2].Split('=')[1])) == true) // { // drq = strSb[2].Split('=')[1]; // } // string csbbh = strSb[3].Split('=')[1]; //设备编号 // if (string.IsNullOrEmpty(csbbh)) // { // HttpContext.Current.Response.Write("2"); // return; // } // string isbid = ""; // dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "'"); // if (dt.Rows.Count == 0) // { // HttpContext.Current.Response.Write("3"); // return; // } // else // { // isbid = dt.Rows[0]["id"].ToString(); // } // string cscx = strSb[5].Split('=')[1]; //生产线 // string czy = strSb[6].Split('=')[1]; //专业 // string cycms = strSb[7].Split('=')[1]; //异常描述 // string dycsj = ""; // if (ex.isDate((strSb[8].Split('=')[1])) == true) // { // dycsj = strSb[8].Split('=')[1].Replace("+", " "); // } // string ccljl = strSb[9].Split('=')[1]; //处理记录 // string czyr = strSb[10].Split('=')[1]; //作业人 // if (string.IsNullOrEmpty(czyr) || czyr.Trim() == "") // { // HttpContext.Current.Response.Write("9"); // return; // } // string djssj = ""; //结束时间 // if (ex.isDate((strSb[11].Split('=')[1])) == true) // { // djssj = strSb[11].Split('=')[1].Replace("+", " "); // } // string cbz = strSb[12].Split('=')[1]; //备注 // string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; // SqlConnection con = new SqlConnection(strConn); // con.Open(); // SqlTransaction sqltra = con.BeginTransaction();//开始事务 // SqlCommand cmd = new SqlCommand(); // cmd.Connection = con;//获取数据连接 // cmd.Transaction = sqltra;//,在执行SQL时 // SqlParameter[] parms = { // new SqlParameter("@id",id), // new SqlParameter("@gdh",cgdh), // new SqlParameter("@sbid",isbid), // new SqlParameter("@rq",drq), // new SqlParameter("@ycms",cycms), // new SqlParameter("@ycsj",dycsj), // new SqlParameter("@cljl",ccljl), // new SqlParameter("@jssj",djssj), // new SqlParameter("@zyr",czyr), // new SqlParameter("@bz",cbz) // }; // cmd.CommandText = "insert_ycjl"; // cmd.CommandType = CommandType.StoredProcedure; // foreach (SqlParameter p in parms) // { // cmd.Parameters.Add(p); // } // cmd.ExecuteNonQuery(); // //履历表 // SqlParameter[] parm_llb = { // new SqlParameter("@xmid",id), // new SqlParameter("@sbid",isbid), // new SqlParameter("@zysj",drq), // new SqlParameter("@zyxm","异常"), // new SqlParameter("@zyry",czyr), // new SqlParameter("@zynr",cycms) // }; // SqlCommand com = new SqlCommand(); // com.Connection = con;//获取数据连接 // com.Transaction = sqltra;//,在执行SQL时 // com.CommandText = "insert_llb"; // com.CommandType = CommandType.StoredProcedure; // foreach (SqlParameter p in parm_llb) // { // com.Parameters.Add(p); // } // com.ExecuteNonQuery(); // //待办事项 // SqlParameter[] parms_dbsx = { // new SqlParameter("@wxid",id), // new SqlParameter ("@rq",drq), // new SqlParameter("@sbbh",csbbh), // new SqlParameter("@sxlx","异常"), // new SqlParameter("@sxnr",dycsj +"," + cycms ), // new SqlParameter("@clfs",""), // new SqlParameter("@dbr",""), // new SqlParameter("@zt","持续中") // }; // SqlCommand comd = new SqlCommand(); // comd.Connection = con;//获取数据连接 // comd.Transaction = sqltra;//,在执行SQL时 // comd.CommandText = "insert_dbsx"; // comd.CommandType = CommandType.StoredProcedure; // foreach (SqlParameter p in parms_dbsx) // { // comd.Parameters.Add(p); // } // comd.ExecuteNonQuery(); // //维修明细 // int rCount = int.Parse(str[1].Split('*')[2]); // if (rCount > 0) // { // string[] strBj = str[1].Split('*')[1].Split('@'); // string[] value; // string bjbh = ""; // double sl = 0; // string strSql = ""; // //备件资料 // for (int i = 0; i < rCount; i++) // { // value = strBj[i].Split('&'); // bjbh = value[1]; // if (bjbh.Trim() == "") // { // con.Close(); // HttpContext.Current.Response.Write("4&" + (i + 1)); // return; // } // ////判断部件编号是否存在 // //strSql = "select * from sbbjb where cbjbh='" + bjbh + "'"; // //int row = SqlHelper.ExecuteSql(strSql); // //if (row == 0) // //{ // // con.Close(); // // HttpContext.Current.Response.Write("5&" + (i + 1)); // // return; // //} // if (value[2].Trim() == "") // { // con.Close(); // HttpContext.Current.Response.Write("6&" + (i + 1)); // return; // } // if (ex.isNumber(value[2]) == true) sl = double.Parse(value[2]); // SqlParameter[] parms_mx = { // new SqlParameter("@ycid",id), // new SqlParameter("@bjbh",bjbh), // new SqlParameter("@sl",sl) // }; // SqlCommand cmd_mx = new SqlCommand(); // cmd_mx.Connection = con;//获取数据连接 // cmd_mx.Transaction = sqltra;//,在执行SQL时 // cmd_mx.CommandText = "insert_ycjl_mx"; // cmd_mx.CommandType = CommandType.StoredProcedure; // foreach (SqlParameter p in parms_mx) // { // cmd_mx.Parameters.Add(p); // } // cmd_mx.ExecuteNonQuery(); // } // } // sqltra.Commit(); //提交事务 // if (con.State == ConnectionState.Open) con.Close(); // con.Dispose(); // HttpContext.Current.Response.Write("添加成功!"); // } // catch (Exception ex) // { // sys e = new sys(); // e.GetLog(ex); // } //} private void Edit() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('~'); string[] strSb = str[0].Split('&'); //设备资料 int id = int.Parse(strSb[0].Split('=')[1]); string cgdh = strSb[1].Split('=')[1]; //工单号 DataTable dt = new DataTable(); dt = SqlHelper.GetTable("select * from ycjlb where cgdh='" + cgdh + "' and id<>" + id); if (dt.Rows.Count > 0) { dt = null; HttpContext.Current.Response.Write("1"); return; } dt = null; sys ex = new sys(); string drq = ""; if (ex.isDate((strSb[2].Split('=')[1])) == true) { drq = strSb[2].Split('=')[1]; } string cczy = strSb[3].Split('=')[1]; //生产线 string csbmc = strSb[4].Split('=')[1]; //设备名称 if (string.IsNullOrEmpty(csbmc)) { HttpContext.Current.Response.Write("2"); return; } string cscx = strSb[5].Split('=')[1]; //生产线 string czy = strSb[6].Split('=')[1]; //专业 string dycsj = ""; if (ex.isDate((strSb[7].Split('=')[1])) == true) { dycsj = strSb[7].Split('=')[1].Replace("+", " "); } string djssj = ""; //结束时间 if (ex.isDate((strSb[8].Split('=')[1])) == true) { djssj = strSb[8].Split('=')[1].Replace("+", " "); } string czyr = strSb[9].Split('=')[1]; //作业人 if (string.IsNullOrEmpty(czyr) || czyr.Trim() == "") { HttpContext.Current.Response.Write("9"); return; } string cfzry = strSb[10].Split('=')[1]; //辅助人员 string cycms = strSb[11].Split('=')[1]; //异常描述 string ccljl = strSb[12].Split('=')[1]; //处理记录 string cbz = strSb[13].Split('=')[1]; //备注 string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parms = { new SqlParameter("@id", id), new SqlParameter("@gdh", cgdh), new SqlParameter("@sbmc", csbmc), new SqlParameter("@scxid", cscx), new SqlParameter("@zyid", czy), new SqlParameter("@rq", drq), new SqlParameter("@ycms", cycms), new SqlParameter("@ycsj", dycsj), new SqlParameter("@cljl", ccljl), new SqlParameter("@jssj", djssj), new SqlParameter("@zyr", czyr), new SqlParameter("@fzry", cfzry), new SqlParameter("@czy", cczy), new SqlParameter("@bz", cbz) }; cmd.CommandText = "update_ycjl"; cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms) { cmd.Parameters.Add(p); } cmd.ExecuteNonQuery(); //不进履历表,进值班记录(维修记录),根据设备id是否为0区别,为0标示异常记录 SqlParameter[] parm_wx = { new SqlParameter("@id", id), new SqlParameter("@gdh", cgdh), new SqlParameter("@sbid", ""), new SqlParameter("@sbmc", csbmc), new SqlParameter("@scxid", cscx), new SqlParameter("@zyid", czy), new SqlParameter("@rq", drq), new SqlParameter("@gzsj", drq), new SqlParameter("@gzlx", ""), new SqlParameter("@gzxx", cycms), new SqlParameter("@clfs", ccljl), new SqlParameter("@wxr", czyr), new SqlParameter("@wxnr", ccljl), new SqlParameter("@wxkssj", ""), new SqlParameter("@wcsj", ""), new SqlParameter("@czy", cczy), new SqlParameter("@bz", cbz) }; SqlCommand com = new SqlCommand(); com.Connection = con; //获取数据连接 com.Transaction = sqltra; //,在执行SQL时 com.CommandText = "update_zbjl"; com.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm_wx) { com.Parameters.Add(p); } com.ExecuteNonQuery(); //清除原来的异常描述 SqlParameter[] parm = { new SqlParameter("@ycid", id) }; SqlCommand cmds = new SqlCommand(); cmds.Connection = con; //获取数据连接 cmds.Transaction = sqltra; //,在执行SQL时 cmds.CommandText = "update_ycjl_mx"; cmds.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm) { cmds.Parameters.Add(p); } cmds.ExecuteNonQuery(); //插入新的维修明细 int rCount = int.Parse(str[1].Split('*')[2]); if (rCount > 0) { string[] strBj = str[1].Split('*')[1].Split('@'); string[] value; string bjbh = ""; double sl = 0; string strSql = ""; //备件资料 for (int i = 0; i < rCount; i++) { value = strBj[i].Split('&'); bjbh = value[1]; if (bjbh.Trim() == "") { con.Close(); HttpContext.Current.Response.Write("4&" + (i + 1)); return; } ////判断部件编号是否存在 //strSql = "select * from sbbjb where cbjbh='" + bjbh + "'"; //int row = SqlHelper.ExecuteSql(strSql); //if (row == 0) //{ // con.Close(); // HttpContext.Current.Response.Write("5&" + (i + 1)); // return; //} if (value[2].Trim() == "") { con.Close(); HttpContext.Current.Response.Write("6&" + (i + 1)); return; } if (ex.isNumber(value[2]) == true) { sl = double.Parse(value[2]); } SqlParameter[] parms_mx = { new SqlParameter("@ycid", id), new SqlParameter("@bjbh", bjbh), new SqlParameter("@sl", sl) }; SqlCommand cmd_mx = new SqlCommand(); cmd_mx.Connection = con; //获取数据连接 cmd_mx.Transaction = sqltra; //,在执行SQL时 cmd_mx.CommandText = "insert_ycjl_mx"; cmd_mx.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms_mx) { cmd_mx.Parameters.Add(p); } cmd_mx.ExecuteNonQuery(); } } sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("修改成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }
//转单保存 private void Add2() { try { StringBuilder sb = new StringBuilder(); //遍历获取传递过来的字符串 foreach (string s in HttpContext.Current.Request.Form.AllKeys) { sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]); } string ss = sb.ToString(); string[] str = ss.Split('~'); string[] strSb = str[0].Split('&'); //设备资料 DataTable dt = new DataTable(); //查找id最大值 Int64 id = 0; dt = SqlHelper.GetTable("select max(id) as maxid from wxjlb"); if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["maxid"].ToString())) { id = Int64.Parse(dt.Rows[0]["maxid"].ToString()) + 1; } else { id = 1; } } else { id = 1; } dt = null; string cgdh = strSb[1].Split('=')[1]; //工单号 dt = SqlHelper.GetTable("select * from wxjlb where cgdh='" + cgdh + "'"); if (dt.Rows.Count > 0) { dt = null; HttpContext.Current.Response.Write("1"); return; } dt = null; sys ex = new sys(); string drq = ""; if (ex.isDate((strSb[2].Split('=')[1])) == true) { drq = strSb[2].Split('=')[1]; } string csbbh = strSb[3].Split('=')[1]; //设备编号 if (string.IsNullOrEmpty(csbbh)) { HttpContext.Current.Response.Write("2"); return; } string isbid = ""; dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "'"); if (dt.Rows.Count == 0) { HttpContext.Current.Response.Write("3"); return; } else { isbid = dt.Rows[0]["id"].ToString(); } string cscx = strSb[5].Split('=')[1]; //生产线 string czy = strSb[6].Split('=')[1]; //专业 string dgzsj = ""; if (ex.isDate((strSb[7].Split('=')[1])) == true) { dgzsj = strSb[7].Split('=')[1].Replace("+", " ");; } string cgzlx = strSb[8].Split('=')[1]; //故障类型 string cwxr = strSb[9].Split('=')[1]; //维修人 if (string.IsNullOrEmpty(cwxr) || cwxr.Trim() == "") { HttpContext.Current.Response.Write("9"); return; } string dwxkssj = ""; //维修开始时间 if (ex.isDate((strSb[10].Split('=')[1])) == true) { dwxkssj = strSb[10].Split('=')[1].Replace("+", " "); } string dwcsj = ""; //完成时间 if (ex.isDate((strSb[11].Split('=')[1])) == true) { dwcsj = strSb[11].Split('=')[1].Replace("+", " "); } string cczy = strSb[12].Split('=')[1]; //制单人 string cfzry = strSb[13].Split('=')[1]; //辅助人员 string cgzxx = strSb[14].Split('=')[1]; //故障现象 string cclfs = strSb[15].Split('=')[1]; //处理方式 string cwxnr = strSb[16].Split('=')[1]; //维修内容 string cbz = strSb[17].Split('=')[1]; //备注 string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); SqlTransaction sqltra = con.BeginTransaction(); //开始事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //获取数据连接 cmd.Transaction = sqltra; //,在执行SQL时 SqlParameter[] parms = { new SqlParameter("@id", id), new SqlParameter("@gdh", cgdh), new SqlParameter("@sbid", isbid), new SqlParameter("@rq", drq), new SqlParameter("@gzsj", dgzsj), new SqlParameter("@gzlx", cgzlx), new SqlParameter("@gzxx", cgzxx), new SqlParameter("@clfs", cclfs), new SqlParameter("@wxr", cwxr), new SqlParameter("@fzry", cfzry), new SqlParameter("@wxnr", cwxnr), new SqlParameter("@wxkssj", dwxkssj), new SqlParameter("@wcsj", dwcsj), new SqlParameter("@czy", cczy), new SqlParameter("@bz", cbz) }; cmd.CommandText = "insert_wxjl"; cmd.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parms) { cmd.Parameters.Add(p); } cmd.ExecuteNonQuery(); //履历表 SqlParameter[] parm_llb = { new SqlParameter("@xmid", id), new SqlParameter("@sbid", isbid), new SqlParameter("@zysj", drq), new SqlParameter("@zyxm", "维修"), new SqlParameter("@zyry", cwxr), new SqlParameter("@czy", cczy), new SqlParameter("@zynr", cwxnr) }; SqlCommand com = new SqlCommand(); com.Connection = con; //获取数据连接 com.Transaction = sqltra; //,在执行SQL时 com.CommandText = "insert_llb"; com.CommandType = CommandType.StoredProcedure; foreach (SqlParameter p in parm_llb) { com.Parameters.Add(p); } com.ExecuteNonQuery(); //待办事项 //SqlParameter[] parms_dbsx = { // new SqlParameter("@wxid",id), // new SqlParameter ("@rq",drq), // new SqlParameter("@sbbh",csbbh), // new SqlParameter("@sxlx","维修"), // new SqlParameter("@sxnr",dgzsj +"," + cgzlx + "," + cgzxx ), // new SqlParameter("@clfs",""), // new SqlParameter("@dbr",""), // new SqlParameter("@zt","持续中") // }; //SqlCommand comd = new SqlCommand(); //comd.Connection = con;//获取数据连接 //comd.Transaction = sqltra;//,在执行SQL时 //comd.CommandText = "insert_dbsx"; //comd.CommandType = CommandType.StoredProcedure; //foreach (SqlParameter p in parms_dbsx) //{ // comd.Parameters.Add(p); //} //comd.ExecuteNonQuery(); //维修明细 int rCount = int.Parse(str[1].Split('*')[2]); if (rCount > 0) { string[] strBj = str[1].Split('*')[1].Split('@'); string[] value; string bjbh = ""; double sl = 0; string strSql = ""; //备件资料 for (int i = 0; i < rCount; i++) { value = strBj[i].Split('&'); bjbh = value[1]; if (bjbh.Trim() == "") { con.Close(); HttpContext.Current.Response.Write("4&" + (i + 1)); return; } //判断部件编号是否存在 strSql = "select * from sbbjb where cbjbh='" + bjbh + "'"; SqlCommand comm = new SqlCommand(); comm.Connection = con; comm.Transaction = sqltra;//,在执行SQL时 comm.CommandText = strSql; comm.CommandType = CommandType.Text; int row = comm.ExecuteNonQuery(); if (row == 0) { comm.Dispose(); con.Close(); HttpContext.Current.Response.Write("5&" + (i + 1)); return; } if (value[2].Trim() == "") { con.Close(); HttpContext.Current.Response.Write("6&" + (i + 1)); return; } if (ex.isNumber(value[2]) == true) { sl = double.Parse(value[2]); } SqlParameter[] parms_mx = { new SqlParameter("@wxid", id), new SqlParameter("@bjbh", bjbh), new SqlParameter("@sl", sl) }; SqlCommand cmd_mx = new SqlCommand(); cmd_mx.Connection = con; //获取数据连接 cmd_mx.Transaction = sqltra; //,在执行SQL时 cmd_mx.CommandType = CommandType.StoredProcedure; cmd_mx.CommandText = "insert_wxjl_mx"; foreach (SqlParameter p in parms_mx) { cmd_mx.Parameters.Add(p); } cmd_mx.ExecuteNonQuery(); cmd_mx.Dispose(); } } sqltra.Commit(); //提交事务 if (con.State == ConnectionState.Open) { con.Close(); } con.Dispose(); HttpContext.Current.Response.Write("添加成功!"); } catch (Exception ex) { sys e = new sys(); e.GetLog(ex); } }