protected void ASPxCbSubmit_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) { int count = 0; string oFlag, pline, station, locationPro, locationId, itemPro; char[] charSeparators = new char[] { ',' }; string[] collection = e.Parameter.Split(charSeparators); int cnt = collection.Length; oFlag = collection[0].ToString(); pline = collection[1].ToString(); station = collection[2].ToString(); locationPro = collection[3].ToString(); itemPro = collection[4].ToString(); if (oFlag == "ADD") { //获取工位 List <string> s = new List <string>(); for (int i = 5; i < cnt; i++) { s.Add(collection[i].ToString()); } string[] s1 = s.ToArray(); if (ASPxGridView1.Selection.Count == 0) { e.Result = "Fail,请选择要增加的工位!"; return; } for (int i = 0; i < s1.Length; i++) { locationId = s1[i].ToString(); string inSqlTemp = "insert into REL_STATION_LOCATION_TEMP(RMES_ID,PLINE_CODE,LOCATION_CODE,STATION_CODE,LOCATION_FLAG,MACHINENAME,LOCATION_FLAG1,INSERT_FLAG) " + "values(SEQ_RMES_ID.NEXTVAL,'" + pline + "','" + locationId + "','" + station + "','" + locationPro + "','" + GV_MachineName + "','" + itemPro + "','3')"; dc.ExeSql(inSqlTemp); } e.Result = "OK,增加成功!"; return; } if (oFlag == "DELETE") { //获取工位 List <string> s = new List <string>(); for (int i = 5; i < cnt; i++) { s.Add(collection[i].ToString()); } string[] s1 = s.ToArray(); if (ASPxGridView2.Selection.Count == 0) { e.Result = "Fail,请选择要删除的工位!"; return; } for (int i = 0; i < s1.Length; i++) { locationId = s1[i].ToString(); string sql = "select insert_flag from REL_STATION_LOCATION_TEMP where PLINE_CODE='" + pline + "' AND LOCATION_CODE='" + locationId + "'" + " AND STATION_CODE='" + station + "' " + " AND LOCATION_FLAG='" + locationPro + "' AND MACHINENAME='" + GV_MachineName + "' "; if (itemPro != "") { sql = sql + "and LOCATION_FLAG1='" + itemPro + "' "; } dataConn dc1 = new dataConn(sql); DataTable dt1 = dc1.GetTable(); if (dt1.Rows[0]["insert_flag"].ToString() == "1") { string upSql = "update REL_STATION_LOCATION_TEMP set insert_flag='2' where PLINE_CODE='" + pline + "' AND LOCATION_CODE='" + locationId + "' " + "AND STATION_CODE='" + station + "' " + " AND LOCATION_FLAG='" + locationPro + "' AND MACHINENAME='" + GV_MachineName + "'";// and LOCATION_FLAG1='" + itemPro + "' "; if (itemPro != "") { upSql = upSql + "and LOCATION_FLAG1='" + itemPro + "' "; } dc.ExeSql(upSql); } if (dt1.Rows[0]["insert_flag"].ToString() == "3") { string deSqlTemp = "DELETE FROM REL_STATION_LOCATION_TEMP WHERE PLINE_CODE='" + pline + "' AND LOCATION_CODE='" + locationId + "'" + " AND STATION_CODE='" + station + "' AND LOCATION_FLAG='" + locationPro + "' AND MACHINENAME='" + GV_MachineName + "'";// and LOCATION_FLAG1='" + itemPro + "' "; if (itemPro != "") { deSqlTemp = deSqlTemp + "and LOCATION_FLAG1='" + itemPro + "' "; } dc.ExeSql(deSqlTemp); } } e.Result = "OK,删除成功!"; return; } if (collection[0] == "SURE") { string tempSql = "select RMES_ID,location_code from REL_STATION_LOCATION_TEMP"; dataConn tempDc = new dataConn(tempSql); DataTable tempDt = tempDc.GetTable(); for (count = 0; count < tempDt.Rows.Count; count++) { string rmesID = tempDt.Rows[count]["RMES_ID"].ToString(); locationId = tempDt.Rows[count]["location_code"].ToString(); string sql = "select insert_flag from REL_STATION_LOCATION_TEMP where rmes_id='" + rmesID + "'"; dataConn dc1 = new dataConn(sql); DataTable dt1 = dc1.GetTable(); if (dt1.Rows[0]["insert_flag"].ToString() == "2") { //插入到日志表 try { string Sql2 = " INSERT INTO REL_STATION_LOCATION_LOG(rmes_id,company_code,pline_code,station_code,location_code,location_flag,location_flag1,user_code,flag,rqsj)" + " VALUES('" + rmesID + "','" + theCompanyCode + "','" + pline + "','" + station + "','" + locationId + "','" + locationPro + "','" + itemPro + "','" + theUserCode + "','DELETE',SYSDATE)"; dc.ExeSql(Sql2); } catch { return; } string dSql = "delete from REL_STATION_LOCATION where rmes_id='" + rmesID + "'"; dc.ExeSql(dSql); } if (dt1.Rows[0]["insert_flag"].ToString() == "3") { string inSql = "insert into REL_STATION_LOCATION(RMES_ID,COMPANY_CODE,PLINE_CODE,LOCATION_CODE,STATION_CODE,LOCATION_FLAG,LOCATION_FLAG1,INPUT_PERSON,INPUT_TIME) " + "select RMES_ID,'" + theCompanyCode + "',PLINE_CODE,LOCATION_CODE,STATION_CODE,LOCATION_FLAG,LOCATION_FLAG1,'" + theUserId + "',sysdate from REL_STATION_LOCATION_TEMP " + "where RMES_ID='" + rmesID + "'";//20161031增加时间列 dc.ExeSql(inSql); //插入到日志表 try { string Sql2 = " INSERT INTO REL_STATION_LOCATION_LOG(rmes_id,company_code,pline_code,station_code,location_code,location_flag,location_flag1,user_code,flag,rqsj)" + " VALUES('" + rmesID + "','" + theCompanyCode + "','" + pline + "','" + station + "','" + locationId + "','" + locationPro + "','" + itemPro + "','" + theUserCode + "','ADD',SYSDATE)"; dc.ExeSql(Sql2); } catch { return; } } } string sqlD = "DELETE from rel_station_location_temp"; dc.ExeSql(sqlD); e.Result = "Sure,确认成功!"; return; //comboPlineCode.Text = ""; //comboStationCode.Text = ""; //locationPro.Text = ""; //ASPxListBoxLocation.Items.Clear(); //comboItemPro.Text = ""; } }
protected void ButRead_Click1(object sender, EventArgs e) { //直接读取出字符串 try { string GV_Depot = ""; string GV_DepotName = ""; if (comboPline.SelectedIndex < 0)//判断生产线是否为空 { return; } //根据选择生产线(仓库代码)获得仓库名称 if (comboPline.Value != null) { GV_Depot = comboPline.Value.ToString(); string chSql = "SELECT depotname FROM DP_dmdepot where depotid='" + GV_Depot + "'"; dataConn chDc = new dataConn(chSql); DataTable chDt = chDc.GetTable(); if (chDt.Rows.Count > 0) { GV_DepotName = chDt.Rows[0]["depotname"].ToString(); } } //删除临时表数据 string m_Sql = "delete from dp_rckwcbtemp where MachineName='" + GV_MachineName + "' and gzdd='" + GV_Depot + "'"; dc.ExeSql(m_Sql); string path = File2.Value;//上传文件路径 if (path == "" && !path.ToUpper().Contains(".TXT")) { ButRead.Enabled = true; return; } string uploadPath = Server.MapPath(Request.ApplicationPath); //上传目录及文件名 string fileName = "RK" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"; //if (!Directory.Exists("C:\\inetpub\\wwwroot\\webapp\\Rmes\\File\\excel")) //{ // Directory.CreateDirectory("C:\\inetpub\\wwwroot\\webapp\\Rmes\\File\\excel"); //} uploadPath = uploadPath + "\\Rmes\\File\\excel\\" + fileName; //得到上传目录及文件名称 File2.PostedFile.SaveAs(uploadPath); //上传文件到服务器 //string text = System.IO.File.ReadAllText(uploadPath);//@"D:\DT900\UP\733.txt" //Console.WriteLine(text); string m_SO = ""; string m_BatchId = ""; string m_Ch = ""; string m_Jhdm = ""; string m_Lxmc = ""; string m_SourcePlace = ""; string m_Destination = ""; ////员工&类型 //if (text.Length < 10) //{ // //员工 // if (text.Substring(0, 2).ToString() == "YG") // { // string m_Ygdm = text.Substring(0, 5).ToString(); // string m_Ygmc = ""; // string m_Sql1 = "select ygmc from dp_ygb where ygdm='" + m_Ygdm + "'"; // DataTable dt1 = dc.GetTable(m_Sql1); // if (dt1.Rows.Count > 0) // { // m_Ygmc = dt1.Rows[0]["ygmc"].ToString(); // } // } // //类型 // if (text.Substring(0, 1).ToString() == "I") // { // string m_lxdm = text.Substring(0, 4).ToString(); // string m_lxmc = ""; // string m_Sql2 = "select lxmc from dp_rklx where lxdm='" + m_lxdm + "'"; // DataTable dt2 = dc.GetTable(m_Sql2); // if (dt2.Rows.Count > 0) // { // m_lxmc = dt2.Rows[0]["lxmc"].ToString(); // } // } //} //流水号 //if (text.Length > 10) //{ //按行读取为字符串数组 string[] lines = System.IO.File.ReadAllLines(uploadPath); //@"D:\DT900\UP\733.txt" string ch = lines[0].Trim(); for (int i = 0; i < lines.Length; i++) { if (lines[i].ToString().Trim() == "") { continue; } if (lines[i].Length < 10) { //员工 if (lines[i].Substring(0, 2).ToString() == "YG") { string m_Ygdm = lines[i].Substring(0, 5).ToString(); string m_Ygmc = ""; string m_Sql1 = "select ygmc from dp_ygb where ygdm='" + m_Ygdm + "'"; DataTable dt1 = dc.GetTable(m_Sql1); if (dt1.Rows.Count > 0) { m_Ygmc = dt1.Rows[0]["ygmc"].ToString(); } } //类型 if (lines[i].Substring(0, 1).ToString() == "I") { string m_lxdm = lines[i].Substring(0, 4).ToString(); string m_lxmc = ""; string m_Sql2 = "select lxmc from dp_rklx where lxdm='" + m_lxdm + "'"; DataTable dt2 = dc.GetTable(m_Sql2); if (dt2.Rows.Count > 0) { m_lxmc = dt2.Rows[0]["lxmc"].ToString(); } } } //流水号 if (lines[i].Length > 10) { string sn = lines[i].Substring(0, 8).ToString(); string onlinesite = ""; try { onlinesite = dc.GetValue("select pline_code from data_product where sn='" + sn + "' and rownum=1"); } catch { } if ((GV_Depot == "E" || GV_Depot == "W" || GV_Depot == "Z") && onlinesite != GV_Depot) { continue; } string m_RkDate = lines[i].Substring(lines[i].Length - 14, 14); DateTime dt = DateTime.ParseExact(m_RkDate, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture); //---------------------由出库至入库情况--------------------------------------- string sql21 = "Select * from dp_rckwcb where Rc='出库' and ghtm='" + sn + "' and destination='" + GV_DepotName + "' order by gzrq desc"; DataTable dt21 = dc.GetTable(sql21); if (dt21.Rows.Count > 0) { m_SO = dt21.Rows[0]["SO"].ToString(); m_BatchId = dt21.Rows[0]["BATCHID"].ToString(); m_Ch = dt21.Rows[0]["CH"].ToString(); m_Jhdm = dt21.Rows[0]["JHDM"].ToString(); m_Lxmc = dt21.Rows[0]["RKLX"].ToString(); m_SourcePlace = dt21.Rows[0]["SOURCEPLACE"].ToString(); //由上一站点出库类型得出此站点入库类型 string sql22 = "select * from dp_rckmap where cklx='" + m_Lxmc + "'"; DataTable dt22 = dc.GetTable(sql22); if (dt22.Rows.Count > 0) { m_Lxmc = dt22.Rows[0]["RKLX"].ToString(); } if (GV_Depot == "E" || GV_Depot == "W") //从atpu中查询入出库类型 { string sql3 = "select c.* from data_product a,data_plan b,dp_atpukcmap c where a.PLAN_CODE=b.PLAN_CODE and a.SN='" + sn + "' and b.PLAN_TYPE=c.atpujhlx and rc='入库'"; DataTable dt3 = dc.GetTable(sql3); if (dt3.Rows.Count > 0) { m_Lxmc = dt3.Rows[0]["RKLX"].ToString(); } } } else { if (GV_Depot == "A") { m_Lxmc = " "; m_SourcePlace = "客户"; } else { m_Lxmc = "正常入库"; m_SourcePlace = "ATPU"; if (GV_Depot == "L") { if (comboJCJ.Text == "是") { m_SourcePlace = "DCEC"; } else { m_SourcePlace = "柳汽U"; } } //从atpu中查询入出库类型 string sql4 = "select c.* from data_product a,data_plan b,dp_atpukcmap c where a.PLAN_CODE=b.PLAN_CODE and a.SN='" + sn + "' and b.PLAN_TYPE=c.atpujhlx and rc='入库'"; DataTable dt4 = dc.GetTable(sql4); if (dt4.Rows.Count > 0) { m_Lxmc = dt4.Rows[0]["RKLX"].ToString(); } } string sql5 = "Select PLAN_SO,PLAN_CODE from DATA_PRODUCT where sn='" + sn + "'"; DataTable dt5 = dc.GetTable(sql5); if (dt5.Rows.Count > 0) { m_SO = dt5.Rows[0]["PLAN_SO"].ToString(); m_Jhdm = dt5.Rows[0]["PLAN_CODE"].ToString(); } ////最后查询一遍计划代码,保证计划代码不为空 //string sql6 = "Select PLAN_SO,PLAN_CODE from DATA_PRODUCT where sn='" + sn + "'"; //dataConn dc6 = new dataConn(sql6); //DataTable dt6 = dc6.GetTable(); //if (dt6.Rows.Count > 0) //{ // m_SO = dt6.Rows[0]["PLAN_SO"].ToString(); // m_Jhdm = dt6.Rows[0]["PLAN_CODE"].ToString(); //} } //写入临时表 if (string.IsNullOrEmpty(m_BatchId)) { m_BatchId = " "; } if (string.IsNullOrEmpty(m_Ch)) { m_Ch = " "; } m_Destination = GV_DepotName; if (GV_Depot == "L") { m_Destination = "柳器总成库"; } //liuqi if (comboJCJ.Text == "是") { m_Lxmc = "柳汽收货入库"; } string inSql = "insert into dp_rckwcbtemp(ghtm,so,jhdm,ygmc,rklx,rkdate,gzrq,gzdd,rc,SourcePlace,destination,BatchId,Ch,MachineName) " + "values('" + sn + "','" + m_SO + "','" + m_Jhdm + "','" + theUserName + "','" + m_Lxmc + "','" + m_RkDate + "',to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')," + "'" + GV_Depot + "','入库','" + m_SourcePlace + "','" + m_Destination + "','" + m_BatchId + "','" + m_Ch + "','" + GV_MachineName + "')"; dc.ExeSql(inSql); } } //} //删除txt文件20160920 //System.IO.File.Delete(uploadPath); setCondition(); } catch { setCondition(); } }
protected void ButInputSure_Click(object sender, EventArgs e) { string m_Ghtm = ""; //先判断是否有重复扫描和重复入库的记录 string m_Sql = "insert into dp_rckwcb(rmes_id,ghtm,so,jhdm,ygmc,rklx,rkdate,gzrq,gzdd,rc,sourceplace,destination,batchId,ch) select SEQ_RMES_ID.NEXTVAL,ghtm,so,jhdm,ygmc,rklx,rkdate,to_char(to_date(gzrq,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss'),gzdd,rc,sourceplace,destination,batchId,ch from dp_rckwcbtemp where BatchId like'" + v_CurrentBatchId + "' and MachineName='" + GV_MachineName + "' and gzdd='" + GV_Depot + "'"; dc.ExeSql(m_Sql); string m_sql1 = "insert into dp_rkwcb(ghtm,so,jhdm,ygmc,gzrq,rklx,rkdate,gzdd) select ghtm,so,jhdm,ygmc,to_date(gzrq,'yyyy-mm-dd hh24:mi:ss'),rklx,rkdate,gzdd from dp_rckwcbtemp where BatchId like'" + v_CurrentBatchId + "' and MachineName='" + GV_MachineName + "' and gzdd='" + GV_Depot + "'"; dc.ExeSql(m_sql1); //'liuqi string inSql = ""; string lq = ""; if (comboJCJ.Value != null) { lq = comboJCJ.Value.ToString(); } if (lq == "是") { inSql = "insert into dp_kcb(rmes_id,ghtm,so,ygmc,rklx,rkdate,gzrq,gzdd,sourceplace,batchId,ch,lq_flag) select SEQ_RMES_ID.NEXTVAL,ghtm,so,ygmc,rklx,rkdate,gzrq,gzdd,sourceplace,batchId,ch,'Y' from dp_rckwcbtemp where BatchId like'" + v_CurrentBatchId + "' and MachineName='" + GV_MachineName + "' and gzdd='" + GV_Depot + "'"; } else { inSql = "insert into dp_kcb(rmes_id,ghtm,so,ygmc,rklx,rkdate,gzrq,gzdd,sourceplace,batchId,ch) select SEQ_RMES_ID.NEXTVAL,ghtm,so,ygmc,rklx,rkdate,gzrq,gzdd,sourceplace,batchId,ch from dp_rckwcbtemp where BatchId like'" + v_CurrentBatchId + "' and MachineName='" + GV_MachineName + "' and gzdd='" + GV_Depot + "'"; } dc.ExeSql(inSql); //so分布 入库时删除储备表信息 string delSql = "delete from data_store where SN in (select ghtm from dp_rckwcbtemp where BatchId like'" + v_CurrentBatchId + "' and MachineName='" + GV_MachineName + "' and gzdd='" + GV_Depot + "')"; dc.ExeSql(delSql); //删除临时表 string delSql1 = "delete from dp_rckwcbtemp where BatchId like '" + v_CurrentBatchId + "' and MachineName='" + GV_MachineName + "' and gzdd='" + GV_Depot + "'"; dc.ExeSql(delSql1); //删除dp_kcb和dp_willrckwcb string sql = "select * from dp_willrckwcb where rc='出库' and gzdd='" + GV_Depot + "' order by ghtm"; dataConn chDc2 = new dataConn(sql); DataTable chDt2 = chDc2.GetTable(); if (chDt2.Rows.Count > 0) { m_Ghtm = chDt2.Rows[0]["Ghtm"].ToString(); } string sql3 = "select * from dp_kcb where ghtm='" + m_Ghtm + "' and gzdd='" + GV_Depot + "'"; dataConn chDc3 = new dataConn(sql3); DataTable chDt3 = chDc3.GetTable(); if (chDt3.Rows.Count > 0) { string dSql = "delete from dp_kcb where ghtm='" + m_Ghtm + "' and gzdd='" + GV_Depot + "'"; dc.ExeSql(dSql); string dSql1 = "delete from dp_willrckwcb where ghtm='" + m_Ghtm + "' and rc='出库' and gzdd='" + GV_Depot + "'"; dc.ExeSql(dSql1); } setCondition(); }
private void delfaulttree() { string nodeid = Request.QueryString["id"] == null ? "" : Request.QueryString["id"].ToString(); if (nodeid == string.Empty) { Response.Write("error:节点ID为空,无法删除。"); Response.End(); } string[] sp = nodeid.Split('_'); int N = sp.Length; switch (N) { case 2: cmbinfo.GroupCode = sp[0]; cmbinfo.PlaceCode = sp[1]; break; case 3: cmbinfo.GroupCode = sp[0]; cmbinfo.PlaceCode = sp[1]; cmbinfo.PartCode = sp[2]; break; case 4: cmbinfo.GroupCode = sp[0]; cmbinfo.PlaceCode = sp[1]; cmbinfo.PartCode = sp[2]; cmbinfo.FaultCode = sp[3]; break; default: Response.Write("error:根节点不能删除。"); Response.End(); break; } dataConn con = new dataConn(); con.OpenConn(); string strSQL = "select * from " + fault_group_table + " where fault_group_code='" + sp[0] + "'"; con.theComd.CommandType = CommandType.Text; con.theComd.CommandText = strSQL; OracleDataReader dr = con.theComd.ExecuteReader(); if (dr.Read()) { cmbinfo.CompanyCode = dr["company_code"].ToString(); cmbinfo.PLineCode = dr["pline_type_code"].ToString(); } dr.Close(); if (cmbinfo.CompanyCode == string.Empty || cmbinfo.PlaceCode == string.Empty || cmbinfo.GroupCode == string.Empty || cmbinfo.PLineCode == string.Empty) { Response.Write("error:缺乏关键信息,无法删除。"); Response.End(); } string[] strSQLs = new string[3]; int M = 0; if (cmbinfo.FaultCode != string.Empty) { strSQL = "delete from RMES_REL_FAULTPART_FAULT where company_code='" + cmbinfo.CompanyCode + "' and pline_type_code='" + cmbinfo.PLineCode + "' and fault_group_code='" + cmbinfo.GroupCode + "' and fault_place_code='" + cmbinfo.PlaceCode + "' and fault_part_code='" + cmbinfo.PartCode + "' and fault_code='" + cmbinfo.FaultCode + "'"; con.theComd.CommandText = strSQL; M += con.theComd.ExecuteNonQuery(); } else { if (cmbinfo.PartCode != string.Empty) { strSQL = "delete from RMES_REL_FAULTPART_FAULT where company_code='" + cmbinfo.CompanyCode + "' and pline_type_code='" + cmbinfo.PLineCode + "' and fault_group_code='" + cmbinfo.GroupCode + "' and fault_place_code='" + cmbinfo.PlaceCode + "' and fault_part_code='" + cmbinfo.PartCode + "'"; con.theComd.CommandText = strSQL; M += con.theComd.ExecuteNonQuery(); strSQL = "delete from RMES_REL_FAULTPLACE_FAULTPART where company_code='" + cmbinfo.CompanyCode + "' and pline_type_code='" + cmbinfo.PLineCode + "' and fault_group_code='" + cmbinfo.GroupCode + "' and fault_place_code='" + cmbinfo.PlaceCode + "' and fault_part_code='" + cmbinfo.PartCode + "'"; con.theComd.CommandText = strSQL; M += con.theComd.ExecuteNonQuery(); } else { strSQL = "delete from RMES_REL_FAULTPART_FAULT where company_code='" + cmbinfo.CompanyCode + "' and pline_type_code='" + cmbinfo.PLineCode + "' and fault_group_code='" + cmbinfo.GroupCode + "' and fault_place_code='" + cmbinfo.PlaceCode + "'"; con.theComd.CommandText = strSQL; M += con.theComd.ExecuteNonQuery(); strSQL = "delete from RMES_REL_FAULTPLACE_FAULTPART where company_code='" + cmbinfo.CompanyCode + "' and pline_type_code='" + cmbinfo.PLineCode + "' and fault_group_code='" + cmbinfo.GroupCode + "' and fault_place_code='" + cmbinfo.PlaceCode + "'"; con.theComd.CommandText = strSQL; M += con.theComd.ExecuteNonQuery(); strSQL = "delete from RMES_REL_GROUP_FAULTPLACE where company_code='" + cmbinfo.CompanyCode + "' and fault_group_code='" + cmbinfo.GroupCode + "' and fault_place_code='" + cmbinfo.PlaceCode + "'"; con.theComd.CommandText = strSQL; M += con.theComd.ExecuteNonQuery(); } } string retinfo = "success:成功删除" + M.ToString() + "条记录。"; //string html = "<div id=\"dialog-confirm\" title=\"确认删除?\"><p><span class=\"ui-icon ui-icon-alert\"></span>"+retinfo+"</p></div>"; //string script = "<script>$(function() { $( \"#dialog:ui-dialog\" ).dialog( \"destroy\" );$( \"#dialog-confirm\" ).dialog({resizable: false,height:210,modal: true,buttons: {\"确定删除\": function() {alert(\"成功删除!\");$( this ).dialog( \"close\" );},\"取消\": function() {$( this ).dialog( \"close\" );}}});});</script>"; Response.Expires = -1; Response.Write(retinfo); Response.End(); }
private void GetFaultsTree() { Response.Charset = "utf-8"; Response.Expires = -1; string ids = Request.QueryString["id"] != null ? Request.QueryString["id"].ToString() : string.Empty; string output = Request.QueryString["out"] != null ? Request.QueryString["out"].ToString() : "xml"; if (ids == "undefined") { Response.End(); } int n = 0; if (ids == string.Empty) ///建立树的根节点。 { this.thesql = "select distinct t.fault_group_code as id,a.fault_group_name as name from rmes_rel_station_faultgroup t left join code_fault_group a on a.fault_group_code = t.fault_group_code where t.company_code='C2' order by a.fault_group_name"; } else { char[] sep1 = { '_' }; string[] arr = ids.Split(sep1); n = arr.Length; switch (n) { case 1: //strSQL = "select "; this.thesql = "select t.fault_place_code as id,a.fault_place_name as name from rmes_rel_group_faultplace t left join code_fault_place a on a.fault_place_code = t.fault_place_code where t.company_code='C2' and t.fault_group_code='" + arr[0] + "' order by a.fault_place_name"; break; case 2: this.thesql = "select t.fault_part_code as id,a.fault_part_name as name from rmes_rel_faultplace_faultpart t left join code_fault_part a on a.fault_part_code = t.fault_part_code where t.company_code='C2' and t.pline_type_code in (select x.pline_type_code from code_fault_group x where x.fault_group_code='" + arr[0] + "') and t.fault_group_code='" + arr[0] + "' and t.fault_place_code='" + arr[1] + "' order by a.fault_part_name"; break; case 3: this.thesql = "select t.fault_code as id,a.fault_name as name from rmes_rel_faultpart_fault t left join code_fault a on a.fault_code = t.fault_code where t.company_code='C2' and t.pline_type_code in (select x.pline_type_code from code_fault_group x where x.fault_group_code='" + arr[0] + "') and t.fault_group_code='" + arr[0] + "' and t.fault_place_code='" + arr[1] + "' and t.fault_part_code = '" + arr[2] + "' order by a.fault_name"; break; default: this.thesql = ""; break; } } string retStr = ""; if (this.thesql != string.Empty) { dataConn dc = new dataConn(); dc.OpenConn(); dc.theComd.CommandType = CommandType.Text; dc.theComd.CommandText = thesql; OracleDataReader dr = dc.theComd.ExecuteReader(); string prefix = (ids == string.Empty) ? "" : (ids + "_"); if (output == "xml") { Response.ContentType = "text/xml"; System.Xml.XmlDocument docXML = new System.Xml.XmlDocument(); System.Xml.XmlElement allnode = docXML.CreateElement("root"); while (dr.Read()) { System.Xml.XmlElement emper = docXML.CreateElement("item"); emper = docXML.CreateElement("item"); emper.SetAttribute("id", prefix + dr["id"].ToString()); emper.InnerXml = "<content><name id=\"" + prefix + dr["id"].ToString() + "\">" + dr["name"].ToString() + "</name></content>"; if (n != 3) { emper.SetAttribute("state", "closed"); } allnode.AppendChild(emper); } if (allnode != null && allnode.ChildNodes.Count > 0) { docXML.AppendChild(allnode); retStr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + docXML.InnerXml; docXML.RemoveAll(); docXML = null; } } if (output == "json") { Response.ContentType = "text/html"; string name = "", id = ""; retStr = ""; while (dr.Read()) { id = dr["id"].ToString(); name = dr["name"].ToString(); retStr += "{ \"attr\":{\"id\":\"" + prefix + id + "\"},\"data\":{\"title\":\"" + name + "\"} },\r\n"; } //if (retStr.EndsWith(",")) retStr = retStr.Substring(0, retStr.Length - 1); retStr = "[ \r\n" + retStr + " ]"; } dc.theConn.Close(); } Response.Write(retStr); Response.End(); }
protected void ASPxCbSubmit_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) { int count = 0; string pline, station, pSeries, detectCode; //e.Result = "fail,"; char[] charSeparators = new char[] { ',' }; string[] collection = e.Parameter.Split(charSeparators); int cnt = collection.Length; pline = collection[0].ToString(); station = collection[1].ToString(); pSeries = collection[cnt - 1].ToString(); for (count = 0; count < listChosedDetect.Items.Count; count++) { detectCode = listChosedDetect.Items[count].ToString(); string[] sArray = detectCode.Split(';'); string detectName = ""; string detectType = ""; string detectStandard = ""; string detectMax = ""; string detectMin = ""; string detectUnit = ""; string chSql = "select detect_name,detect_type,detect_standard,detect_max,detect_min,detect_unit from code_detect where pline_code='" + pline + "' and detect_code='" + sArray[0] + "'"; dataConn chDc = new dataConn(chSql); DataTable chDt = chDc.GetTable(); if (chDt.Rows.Count > 0) { detectName = chDt.Rows[0]["detect_name"].ToString(); detectType = chDt.Rows[0]["detect_type"].ToString(); detectStandard = chDt.Rows[0]["detect_standard"].ToString(); detectMax = chDt.Rows[0]["detect_max"].ToString(); detectMin = chDt.Rows[0]["detect_min"].ToString(); detectUnit = chDt.Rows[0]["detect_unit"].ToString(); } //顺序号start string detectCode1 = ""; dataConn dc8 = new dataConn("select DETECT_SEQ from REL_STATION_DETECT where pline_code ='" + pline + "' and PRODUCT_SERIES ='" + pSeries + "' and STATION_CODE ='" + station + "'"); if (dc8.GetState() == true) { string cSql = "select max(DETECT_SEQ) DETECT_SEQ_MAX from REL_STATION_DETECT where pline_code ='" + pline + "' and PRODUCT_SERIES ='" + pSeries + "' and STATION_CODE ='" + station + "'"; dataConn dc1 = new dataConn(cSql); DataTable dt = dc1.GetTable(); string aa = dt.Rows[0]["DETECT_SEQ_MAX"].ToString(); detectCode1 = Convert.ToString(Convert.ToInt32(aa) + 1); } else { detectCode1 = "1"; } //顺序号end string sql = "insert into REL_STATION_DETECT(rmes_id,company_code,pline_code,station_code,product_series,detect_code,detect_name,detect_type,detect_standard," + "detect_max,detect_min,detect_unit,DETECT_SEQ)" + "values(SEQ_RMES_ID.NEXTVAL,'" + theCompanyCode + "','" + pline + "','" + station + "','" + pSeries + "','" + sArray[0] + "','" + detectName + "'," + "'" + detectType + "','" + detectStandard + "','" + detectMax + "','" + detectMin + "','" + detectUnit + "','" + detectCode1 + "')"; dc.ExeSql(sql); } }
private void GetFaultsChildren() { Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.AppendHeader("Cache-Control", "must-revalidate"); string strlist = Request.QueryString["str"] != null?Request.QueryString["str"].ToString():string.Empty; string ids = string.Empty; string names = string.Empty; if (strlist != string.Empty) { char[] sep = { ',' }; char[] sep1 = { '_' }; string[] arr = strlist.Split(sep); for (int i = 0; i < arr.Length; i++) { if (arr[i] != string.Empty) { if (arr[i].Substring(0, 2) == "A_" || arr[i].Substring(0, 2) == "B_" || arr[i].Substring(0, 2) == "C_" || arr[i].Substring(0, 2) == "D_") { //char[] sep1 ={ '|' }; //string[] brr = arr[i].Substring(2).Split(sep1); { for (int j = 0; j < arr.Length; j++) { if (arr[j].IndexOf(arr[i]) >= 0 && arr[j] != arr[i]) { arr[j] = string.Empty; } } switch (arr[i].Substring(0, 2)) { case "A_": thesql = "select distinct a.fault_code ID,a.fault_name Name from code_fault a where a.fault_code in (select b.fault_code from rmes_rel_faultpart_fault b"; thesql += " where b.fault_part_code in (select c.fault_part_code from rmes_rel_faultplace_faultpart c where c.fault_place_code in (select d.fault_place_code"; thesql += " from rmes_rel_group_faultplace d where d.fault_group_code in (select e.fault_group_code from rmes_rel_station_faultgroup e where e.fault_station_code='" + arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString() + "'))))"; break; case "B_": thesql = "select distinct a.fault_code ID,a.fault_name Name from code_fault a where a.fault_code in (select b.fault_code from rmes_rel_faultpart_fault b"; thesql += " where b.fault_part_code in (select c.fault_part_code from rmes_rel_faultplace_faultpart c where c.fault_place_code in (select d.fault_place_code"; thesql += " from rmes_rel_group_faultplace d where d.fault_group_code ='" + arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString() + "')))"; break; case "C_": thesql = "select distinct a.fault_code ID,a.fault_name Name from code_fault a where a.fault_code in (select b.fault_code from rmes_rel_faultpart_fault b"; thesql += " where b.fault_part_code in (select c.fault_part_code from rmes_rel_faultplace_faultpart c where c.fault_place_code ='" + arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString() + "'))"; break; case "D_": thesql = "select distinct a.fault_code ID,a.fault_name Name from code_fault a where a.fault_code in (select b.fault_code from rmes_rel_faultpart_fault b"; thesql += " where b.fault_part_code ='" + arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString() + "')"; break; } dataConn dc = new dataConn(thesql); DataTable dt = dc.GetTable(); for (int m = 0; m < dt.Rows.Count; m++) { if (ids == string.Empty) { ids = dt.Rows[m]["ID"].ToString(); } else { string tids = "," + ids + ","; if (tids.IndexOf("," + dt.Rows[m]["ID"].ToString() + ",") == -1) { ids += "," + dt.Rows[m]["ID"].ToString(); } } if (names == string.Empty) { names = dt.Rows[m]["Name"].ToString(); } else { string tnames = "," + names + ","; if (tnames.IndexOf("," + dt.Rows[m]["Name"].ToString() + ",") == -1) { names += "," + dt.Rows[m]["Name"].ToString(); } } } } } else if (arr[i].Substring(0, 2) == "E_") { //char[] sep1 ={ '|' }; //string[] brr = arr[i].Substring(2).Split(sep1); thesql = "select distinct a.fault_code ID,a.fault_name Name from code_fault a where a.fault_code='" + arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString() + "'"; dataConn dc = new dataConn(thesql); DataTable dt = dc.GetTable(); for (int m = 0; m < dt.Rows.Count; m++) { if (ids == string.Empty) { //ids = dt.Rows[m]["ID"].ToString(); ids = arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString(); } else { string tids = "," + ids + ","; //if (tids.IndexOf("," + dt.Rows[m]["ID"].ToString() + ",") == -1) if (tids.IndexOf("," + arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString() + ",") == -1) { ids += "," + arr[i].Split(sep1)[arr[i].Split(sep1).Length - 1].ToString(); } } if (names == string.Empty) { names = dt.Rows[m]["Name"].ToString(); } else { string tnames = "," + names + ","; if (tnames.IndexOf("," + dt.Rows[m]["Name"].ToString() + ",") == -1) { names += "," + dt.Rows[m]["Name"].ToString(); } } } } } } } Response.Write(ids + "|" + names); }
//删除 protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { //判断当前记录是否可以删除 string strLSeq = e.Values["LOCATION_SEQ"].ToString(); string strLCode = e.Values["LOCATION_CODE"].ToString(); string strPCode = e.Values["GZDD"].ToString(); string strTableName = "MS_LOCATION_TIME"; dataConn theDataConn = new dataConn("select func_check_delete_data('" + strTableName + "','" + theCompanyCode + "','MES','MES','MES','" + strLCode + "') from dual"); theDataConn.OpenConn(); string theRet = theDataConn.GetValue(); if (theRet != "Y") { ASPxGridView1.JSProperties.Add("cpCallbackName", "Delete"); ASPxGridView1.JSProperties.Add("cpCallbackRet", theRet); theDataConn.CloseConn(); } else { //插入到日志表delete try { string Sql2 = "INSERT INTO MS_LOCATION_TIME_LOG (LOCATION_SEQ,LOCATION_CODE,LOCATION_TIME,GZDD,user_code,flag,rqsj)" + " SELECT LOCATION_SEQ,LOCATION_CODE,LOCATION_TIME,GZDD,'" + theUserCode + "' , 'DEL', SYSDATE FROM MS_LOCATION_TIME WHERE LOCATION_CODE = '" + strLCode + "' AND GZDD='" + strPCode + "' "; dc.ExeSql(Sql2); } catch { return; } //确认删除 string Sql = "delete from MS_LOCATION_TIME WHERE LOCATION_CODE = '" + strLCode + "' AND GZDD='" + strPCode + "' "; dc.ExeSql(Sql); //插入到日志表update try { string Sql2 = "INSERT INTO MS_LOCATION_TIME_LOG (LOCATION_SEQ,LOCATION_CODE,LOCATION_TIME,GZDD,user_code,flag,rqsj)" + " SELECT LOCATION_SEQ,LOCATION_CODE,LOCATION_TIME,GZDD,'" + theUserCode + "' , 'BEFOREEDIT', SYSDATE FROM MS_LOCATION_TIME WHERE LOCATION_SEQ >= '" + strLSeq + "' AND GZDD='" + strPCode + "' "; dc.ExeSql(Sql2); } catch { return; } string UpSql = "UPDATE MS_LOCATION_TIME SET LOCATION_SEQ = LOCATION_SEQ-1 WHERE LOCATION_SEQ >= '" + strLSeq + "' AND GZDD = '" + strPCode + "' "; dc.ExeSql(UpSql); //插入到日志表update try { string Sql2 = "INSERT INTO MS_LOCATION_TIME_LOG (LOCATION_SEQ,LOCATION_CODE,LOCATION_TIME,GZDD,user_code,flag,rqsj)" + " SELECT LOCATION_SEQ,LOCATION_CODE,LOCATION_TIME,GZDD,'" + theUserCode + "' , 'AFTEREDIT', SYSDATE FROM MS_LOCATION_TIME WHERE LOCATION_SEQ >= '" + strLSeq + "' AND GZDD='" + strPCode + "' "; dc.ExeSql(Sql2); } catch { return; } } setCondition(); e.Cancel = true; }
private void GetTable() { string id = Request.QueryString["id"] as string; string outType = Request.QueryString["out"] as string; string pstart = Request.QueryString["pstart"] as string; string psize = Request.QueryString["psize"] as string; string filter = Request.QueryString["filter"] as string; if (id == null || id == string.Empty) { Response.End(); } if (outType == null || outType == string.Empty) { outType = "html"; } string strReturn = ""; string strSQL = ""; if (id == "faultplace") { string subSQL = "select t.rowid as id,t.fault_place_code as 代码,t.fault_place_name as 名称,b.pline_type_name as 生产线类型,a.company_name as 所属公司,t.delete_flag as 已删除,rownum as sq from code_fault_place t " + "left join code_company a on a.company_code=t.company_code " + "left join code_pline_type b on b.pline_type_code = t.pline_type_code "; if (filter == null || filter == string.Empty) { filter = ""; } else { string[] f = filter.Split(','); filter = ""; if (f[0] != string.Empty) { filter += "and t.fault_place_code like '%" + f[0] + "%' "; } if (f[1] != string.Empty) { filter += "and t.fault_place_name like '%" + f[1] + "%' "; } if (f[2] != string.Empty) { filter += "and b.pline_type_name like '%" + f[2] + "%' "; } if (f[3] != string.Empty) { filter += "and a.company_name like '%" + f[3] + "%' "; } } if (filter.StartsWith("and")) { filter = " where " + filter.Substring(3, filter.Length - 3); } subSQL = subSQL + filter + " order by t.rowid"; strSQL = "select * from(" + subSQL + ") "; string where = "where "; if (pstart == null || pstart == string.Empty) { pstart = "0"; } if (psize == null || psize == string.Empty) { psize = (Convert.ToInt32(pstart) + 16).ToString(); } else { psize = (Convert.ToInt32(pstart) + Convert.ToInt32(psize)).ToString(); } where += " sq > " + pstart + " and sq <" + psize; strSQL = strSQL + where; } dataConn con = new dataConn(); con.OpenConn(); con.theComd.CommandType = CommandType.Text; con.theComd.CommandText = strSQL; OracleDataReader dr = con.theComd.ExecuteReader(); if (outType == "html") { strReturn = ""; while (dr.Read()) { strReturn += "<tr><td><input type=\"checkbox\" id=\"" + dr[0].ToString() + "\" /></td><td>" + dr[1].ToString() + "</td><td>" + dr[2].ToString() + "</td><td>" + dr[3].ToString() + "</td><td>" + dr[4].ToString() + "</td><td>" + (("1" == dr[5].ToString()) ? "是" : " ") + "</td></tr>"; } } strReturn += ""; Response.Write(strReturn); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { //得到相关信息 userManager theUserManager = (userManager)Session["theUserManager"]; string theCompanyCode = theUserManager.getCompanyCode(); string theProgramCode = theUserManager.getProgCode(); //调用存储过程得到该程序号对应信息 dataConn theDataConn = new dataConn(); theDataConn.theComd.CommandType = CommandType.StoredProcedure; theDataConn.theComd.CommandText = "MW_QUERY_COMMONQUERY_SINGLE"; theDataConn.theComd.Parameters.Add("THECOMPANYCODE1", OracleDbType.Varchar2).Value = "01"; theDataConn.theComd.Parameters.Add("THECOMPANYCODE1", OracleDbType.Varchar2).Direction = ParameterDirection.Input; theDataConn.theComd.Parameters.Add("THEPROGRAMCODE1", OracleDbType.Varchar2).Value = "selectCompany"; theDataConn.theComd.Parameters.Add("THEPROGRAMCODE1", OracleDbType.Varchar2).Direction = ParameterDirection.Input; theDataConn.theComd.Parameters.Add("THEPROGRAMNAME1", OracleDbType.Varchar2, 50).Direction = ParameterDirection.InputOutput; theDataConn.theComd.Parameters.Add("THERETQUERYFIELDCODE1", OracleDbType.Varchar2, 300).Direction = ParameterDirection.InputOutput; theDataConn.theComd.Parameters.Add("THERETQUERYFIELDNAME1", OracleDbType.Varchar2, 300).Direction = ParameterDirection.InputOutput; theDataConn.theComd.Parameters.Add("THERETFIELDCODE1", OracleDbType.Varchar2, 300).Direction = ParameterDirection.InputOutput; theDataConn.theComd.Parameters.Add("THERETFIELDNAME1", OracleDbType.Varchar2, 300).Direction = ParameterDirection.InputOutput; theDataConn.theComd.Parameters.Add("THERETQUERYSQL1", OracleDbType.Varchar2, 300).Direction = ParameterDirection.InputOutput; theDataConn.theComd.Parameters.Add("THERETPRIMARYKEY1", OracleDbType.Varchar2, 300).Direction = ParameterDirection.InputOutput; theDataConn.OpenConn(); theDataConn.theComd.ExecuteNonQuery(); theProgramName = (string)theDataConn.theComd.Parameters["THEPROGRAMNAME1"].Value; theQueryFieldCode = (string)theDataConn.theComd.Parameters["THERETQUERYFIELDCODE1"].Value; theQueryFieldName = (string)theDataConn.theComd.Parameters["THERETQUERYFIELDNAME1"].Value; theFieldCode = (string)theDataConn.theComd.Parameters["THERETFIELDCODE1"].Value; theFieldName = (string)theDataConn.theComd.Parameters["THERETFIELDNAME1"].Value; theQuerySql = (string)theDataConn.theComd.Parameters["THERETQUERYSQL1"].Value; thePrimaryKey = (string)theDataConn.theComd.Parameters["THERETPRIMARYKEY1"].Value; theDataConn.CloseConn(); //相关属性赋值 SqlDataSource1.SelectCommand = theQuerySql + " " + theConditionStr; string[] thePrimaryKeyArray = thePrimaryKey.Split(','); GridView1.DataKeyNames = thePrimaryKeyArray; //动态生成列 if (!IsPostBack) { string[] theFieldCodeArray = theFieldCode.Split(','); string[] theFieldNameArray = theFieldName.Split(','); string[] theQueryFieldCodeArray = theQueryFieldCode.Split(','); string[] theQueryFieldNameArray = theQueryFieldName.Split(','); BoundField[] field = new BoundField[theFieldCodeArray.Length]; for (int i = 0; i < theFieldCodeArray.Length; i++) { field[i] = new BoundField(); field[i].DataField = theFieldCodeArray[i]; field[i].HeaderText = theFieldNameArray[i]; field[i].SortExpression = theFieldCodeArray[i]; GridView1.Columns.Add(field[i]); } //生成查询方式下拉框 ListItem[] listItem = new ListItem[theQueryFieldCodeArray.Length]; //增加空行 ListItem listItem1 = new ListItem(); listItem1.Value = ""; listItem1.Text = ""; DropDownList1.Items.Add(listItem1); for (int j = 0; j < theQueryFieldCodeArray.Length; j++) { listItem[j] = new ListItem(); listItem[j].Value = theQueryFieldCodeArray[j]; listItem[j].Text = theQueryFieldNameArray[j]; DropDownList1.Items.Add(listItem[j]); } } }
//protected void cmbPartNew_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) //{ // bool checkNoQAD = Convert.ToBoolean(e.Parameter); // if (checkNoQAD) // { // string sql = "select part pt_part,'非QAD件' pt_desc from atpubkflpart t where gzdd='" + cmbPline.Value.ToString() + "' and part_type='1'"; // dc.setTheSql(sql); // (sender as ASPxComboBox).DataSource = dc.GetTable(); // (sender as ASPxComboBox).ValueField = "pt_part"; // (sender as ASPxComboBox).TextField = "pt_desc"; // (sender as ASPxComboBox).DataBind(); // } // else // { // string sql = "select pt_part, pt_DESC2 pt_desc from copy_pt_mstr where pt_phantom=0 and pt_status in ('a','A','b','B','d','D','e','E','l','L','m','M','p','P','t','T') and pt_group in ('raw','RAW','M') order by pt_part"; // dc.setTheSql(sql); // (sender as ASPxComboBox).DataSource = dc.GetTable(); // (sender as ASPxComboBox).ValueField = "pt_part"; // (sender as ASPxComboBox).TextField = "pt_desc"; // (sender as ASPxComboBox).DataBind(); // } //} //protected void cmbPartNew2_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) //{ // bool checkNoQAD2 = Convert.ToBoolean(e.Parameter); // if (checkNoQAD2) // { // string sql = "select part pt_part,'非QAD件' pt_desc from atpubkflpart t where gzdd='" + cmbPline.Value.ToString() + "' and part_type='1'"; // dc.setTheSql(sql); // (sender as ASPxComboBox).DataSource = dc.GetTable(); // (sender as ASPxComboBox).ValueField = "pt_part"; // (sender as ASPxComboBox).TextField = "pt_desc"; // (sender as ASPxComboBox).DataBind(); // } // else // { // string sql = "select pt_part, pt_DESC2 pt_desc from copy_pt_mstr where pt_phantom=0 and pt_status in ('a','A','b','B','d','D','e','E','l','L','m','M','p','P','t','T') and pt_group in ('raw','RAW','M') order by pt_part"; // dc.setTheSql(sql); // (sender as ASPxComboBox).DataSource = dc.GetTable(); // (sender as ASPxComboBox).ValueField = "pt_part"; // (sender as ASPxComboBox).TextField = "pt_desc"; // (sender as ASPxComboBox).DataBind(); // } //} protected void BtnConfirm2_Click(object sender, EventArgs e) { //多对多替换 string thisPe = txtPe2.Text.Trim(); //站点 string thisSite = cmbPline.Value.ToString(); //登录人 userManager theUserManager = (userManager)Session["theUserManager"]; string userNmae = theUserManager.getUserName(); int maxCount = Math.Max(lstPtFrom.Items.Count, lstPtTo.Items.Count); int minCount = Math.Min(lstPtFrom.Items.Count, lstPtTo.Items.Count); string thisPart, thisPartNew; string thisFromDate = DateFrom2.Date.ToString("yyyy-MM-dd"); string thisToDate = DateTo2.Date.ToString("yyyy-MM-dd"); string thisXL = txtXl.Text.Trim(); string thisSL; //检查零件 for (int i = 0; i < ListConfig.Items.Count; i++) { string thisSO = ListConfig.Items[i].Value.ToString(); //多对多替换如果是3个零件换成5个零件,则插入5条记录,前3条一个对一个,后两条原零件为空 for (int fromCount = 0; fromCount < maxCount; fromCount++) { if (lstPtFrom.Items.Count == maxCount) { thisPart = lstPtFrom.Items[fromCount].Value.ToString(); } else if (fromCount < minCount) { thisPart = lstPtFrom.Items[fromCount].Value.ToString(); } else { thisPart = ""; } if (lstPtTo.Items.Count == maxCount) { string temp = lstPtTo.Items[fromCount].Value.ToString(); thisPartNew = temp.Split(';')[0].ToString(); thisSL = temp.Split(';')[1].ToString(); } else if (fromCount < minCount) { string temp = lstPtTo.Items[fromCount].Value.ToString(); thisPartNew = temp.Split(';')[0].ToString(); thisSL = temp.Split(';')[1].ToString(); } else { thisPartNew = ""; thisSL = "0"; } string check1 = CheckNoQAD2.Value.ToString().ToUpper(); //校验零件 string sql = ""; if (thisPart.Trim() != "") { sql = "select count(1) from copy_pt_mstr where pt_phantom=0 and pt_status in ('a','A','b','B','d','D','e','E','l','L','m','M','p','P','t','T') and pt_group in ('raw','RAW','M') and upper(pt_part)='" + thisPart + "'"; if (dc.GetValue(sql) == "0") { Response.Write("<script>alert('BOM零件" + thisPart + "非法!');</script>"); return; } } if (thisPartNew.Trim() != "") { if (check1 == "TRUE") { sql = "select count(1) from atpubkflpart t where gzdd='" + cmbPline.Value.ToString() + "' and part_type='1' and upper(part)='" + thisPartNew + "'"; if (dc.GetValue(sql) == "0") { Response.Write("<script>alert('替换零件" + thisPartNew + "非法!');</script>"); return; } } else { sql = "select count(1) from copy_pt_mstr where pt_phantom=0 and pt_status in ('a','A','b','B','d','D','e','E','l','L','m','M','p','P','t','T') and pt_group in ('raw','RAW','M') and upper(pt_part)='" + thisPartNew + "'"; if (dc.GetValue(sql) == "0") { Response.Write("<script>alert('替换零件" + thisPartNew + "非法!');</script>"); return; } } } } } for (int i = 0; i < ListConfig.Items.Count; i++) { //对每个SO执行一个删除 string thisSO = ListConfig.Items[i].Value.ToString(); BomReplaceFactory.MW_MODIFY_SJBOMTHSET("DELETE2", "", "", thisSO, thisPe, thisSite, userNmae, thisFromDate, thisToDate, "", "", ""); //得到组号 //BomReplaceFactory.FUNC_GET_NEWSID("MT",out id); dataConn theDataConn = new dataConn(); theDataConn.theComd.CommandType = CommandType.StoredProcedure; theDataConn.theComd.CommandText = "FUNC_GET_NEWSID"; theDataConn.theComd.Parameters.Add("in_type", OracleDbType.Varchar2).Value = "MT"; theDataConn.theComd.Parameters.Add("id", OracleDbType.Varchar2, 50).Direction = ParameterDirection.Output; theDataConn.OpenConn(); theDataConn.theComd.ExecuteNonQuery(); string id = theDataConn.theComd.Parameters["id"].Value.ToString(); theDataConn.CloseConn(); //多对多替换如果是3个零件换成5个零件,则插入5条记录,前3条一个对一个,后两条原零件为空 for (int fromCount = 0; fromCount < maxCount; fromCount++) { if (lstPtFrom.Items.Count == maxCount) { thisPart = lstPtFrom.Items[fromCount].Value.ToString(); } else if (fromCount < minCount) { thisPart = lstPtFrom.Items[fromCount].Value.ToString(); } else { thisPart = ""; } if (lstPtTo.Items.Count == maxCount) { string temp = lstPtTo.Items[fromCount].Value.ToString(); thisPartNew = temp.Split(';')[0].ToString(); thisSL = temp.Split(';')[1].ToString(); } else if (fromCount < minCount) { string temp = lstPtTo.Items[fromCount].Value.ToString(); thisPartNew = temp.Split(';')[0].ToString(); thisSL = temp.Split(';')[1].ToString(); } else { thisPartNew = ""; thisSL = "0"; } //根据so循环插入记录 BomReplaceFactory.MW_MODIFY_SJBOMTHSET("ADD2", thisPart, thisPartNew, thisSO, thisPe, thisSite, userNmae, thisFromDate, thisToDate, id, thisSL, thisXL); } } Response.Write("<script>alert('新增成功!');window.opener.location.href = '../mmsReplaceRelationshipSet/mmsReplaceRelationshipSet.aspx';window.location.href = '../mmsReplaceRelationshipSet/mmsReplaceRelationshipSetNew.aspx';</script>"); }
protected void Page_Load(object sender, EventArgs e) { string userAcc1; bool isValid = false, isOld = false; string userAcc = System.Web.HttpContext.Current.User.Identity.Name.Trim(); userAcc1 = userAcc; int len = userAcc.IndexOf('\\', 0); userAcc = userAcc.Substring(len + 1, userAcc.Length - len - 1).ToUpper(); //string strDomain = userAcc.Substring(0, len - 1); string strDomain = userAcc1.Substring(0, len); if (strDomain == "DCEC") //if (strDomain != "") //if (strDomain == "域名") { //判断用户名是否合法,并获取密码 string sqlY = "select a.user_code,a.user_password,b.company_code,b.company_name from code_user a left join code_company b on a.company_code=b.company_code where upper(user_code)='" + userAcc.ToUpper() + "'"; dataConn dc = new dataConn(); dc.OpenConn(); dc.setTheSql(sqlY); DataTable dt = dc.GetTable(); if (dt.Rows.Count > 0) { isValid = true; string theUserCode = dc.GetTable().Rows[0][0].ToString(); string theCompanyCode = dc.GetTable().Rows[0][2].ToString(); string thePlineCode = dc.GetTable().Rows[0][2].ToString(); string thePassword = thePubCs.AESDecrypt(dc.GetTable().Rows[0][1].ToString()); string thePlineName = dc.GetTable().Rows[0][3].ToString(); string theClientIp = Request.UserHostAddress; if (theUserCode.ToUpper() == thePassword.ToUpper()) { isOld = true; } string sql = string.Format("select func_get_user('{0}','MES','{1}','A') from dual", theCompanyCode, theUserCode); string theUserName = ""; string theUserId = ""; string theLoginStatus = ""; string theSessionCode = ""; bool theLoginFlag = false; dataConn theDataConn002 = new dataConn(); theDataConn002.OpenConn(); theDataConn002.setTheSql(sql); theUserId = theDataConn002.GetValue(); theDataConn002.CloseConn(); //在登录界面,从会话得到公司号,以后都是从用户对象里面得到 //theCompanyCode = (string)Session["theCompanyCode"]; loginManager theLoginManager = new loginManager(); theLoginManager.setCompanyCode(theCompanyCode); theLoginFlag = theLoginManager.loginIn(theUserId, thePubCs.AESEncrypt(thePassword), theClientIp, thePlineCode); //得到用户名称 theUserName = theLoginManager.getUserName(); theUserCode = theLoginManager.getUserCode(); if (theLoginFlag) { TxtEmployeeCode.Text = "ok"; TxtPassword.Text = theLoginManager.theLoginFlag; } else { TxtEmployeeCode.Text = "error"; TxtPassword.Text = theLoginManager.theLoginFlag; } theLoginStatus = theLoginManager.theLoginFlag; theSessionCode = theLoginManager.theSessionCode; theCompanyCode = theLoginManager.getTheCompanyCode(); //处理不同情况 switch (theLoginStatus) { case "0": //登录成功 //处理登录用户信息 userManager theUserManager = new userManager(theSessionCode); theUserManager.setLoginFlag(theLoginFlag); theUserManager.setPlineCode(thePlineCode); theUserManager.setPlineName(thePlineName); if (isOld) { theUserManager.setProgValue("/Rmes/Sam/sam2400/sam2400.aspx"); theUserManager.setProgCode("sam2400"); theUserManager.setProgName("用户密码维护"); } else { theUserManager.setProgValue("/Rmes/Login/RmesIndex.aspx"); theUserManager.setProgCode("rmesIndex"); theUserManager.setProgName("系统登录"); } theUserManager.setUserId(theUserId); theUserManager.setUserCode(theUserCode); theUserManager.setUserName(theUserName); theUserManager.setCompanyCode(theCompanyCode); Session["theUserManager"] = theUserManager; callbackResult = theLoginStatus; if (isOld) { Response.Redirect("/Rmes/Sam/sam2400/sam2400.aspx?progCode=sam2400&progName=用户密码维护"); } else { Response.Redirect("/Rmes/Login/RmesIndex.aspx?progCode=rmesIndex&progName=系统登录"); } break; default: callbackResult = theLoginStatus; break; } if (callbackResult == "0" && isOld) { callbackResult = "10"; } //Response.Write(callbackResult); Response.End(); } else { isValid = false; } dc.CloseConn(); } else { isValid = false; } //if (!IsPostBack) //{ // Session.Abandon(); // Session.Clear(); //} //现在只处理登录,从QueryString中得到ajax消息 if (!string.IsNullOrWhiteSpace(Request.QueryString["method"]) && Request.QueryString["method"].Equals("login") && !isValid) { //document.forms[0]['DropDownListPline'].value //document.forms[0]['TxtEmployeeCode'].value //document.forms[0]['TxtPassword'].value //thePlineName; string theUserCode = Request.QueryString["usercode"]; string theCompanyCode = Request.QueryString["companycode"]; string thePlineCode = Request.QueryString["companycode"]; string thePassword = Request.QueryString["password"]; string thePlineName = Request.QueryString["companyname"]; string theClientIp = Request.UserHostAddress; if (theUserCode.ToUpper() == thePassword.ToUpper()) { isOld = true; } string sql = string.Format("select func_get_user('{0}','MES','{1}','A') from dual", theCompanyCode, theUserCode); string theUserName = ""; string theUserId = ""; string theLoginStatus = ""; string theSessionCode = ""; bool theLoginFlag = false; dataConn theDataConn002 = new dataConn(); theDataConn002.OpenConn(); theDataConn002.setTheSql(sql); theUserId = theDataConn002.GetValue(); theDataConn002.CloseConn(); //在登录界面,从会话得到公司号,以后都是从用户对象里面得到 //theCompanyCode = (string)Session["theCompanyCode"]; loginManager theLoginManager = new loginManager(); theLoginManager.setCompanyCode(theCompanyCode); theLoginFlag = theLoginManager.loginIn(theUserId, thePubCs.AESEncrypt(thePassword), theClientIp, thePlineCode); //得到用户名称 theUserName = theLoginManager.getUserName(); theUserCode = theLoginManager.getUserCode(); if (theLoginFlag) { TxtEmployeeCode.Text = "ok"; TxtPassword.Text = theLoginManager.theLoginFlag; } else { TxtEmployeeCode.Text = "error"; TxtPassword.Text = theLoginManager.theLoginFlag; } theLoginStatus = theLoginManager.theLoginFlag; theSessionCode = theLoginManager.theSessionCode; theCompanyCode = theLoginManager.getTheCompanyCode(); //处理不同情况 switch (theLoginStatus) { case "0": //登录成功 //处理登录用户信息 userManager theUserManager = new userManager(theSessionCode); theUserManager.setLoginFlag(theLoginFlag); theUserManager.setPlineCode(thePlineCode); theUserManager.setPlineName(thePlineName); if (isOld) { theUserManager.setProgValue("/Rmes/Sam/sam2400/sam2400.aspx"); theUserManager.setProgCode("sam2400"); theUserManager.setProgName("用户密码维护"); } else { theUserManager.setProgValue("/Rmes/Login/RmesIndex.aspx"); theUserManager.setProgCode("rmesIndex"); theUserManager.setProgName("系统登录"); } theUserManager.setUserId(theUserId); theUserManager.setUserCode(theUserCode); theUserManager.setUserName(theUserName); theUserManager.setCompanyCode(theCompanyCode); Session["theUserManager"] = theUserManager; callbackResult = theLoginStatus; break; default: callbackResult = theLoginStatus; break; } if (callbackResult == "0" && isOld) { callbackResult = "10"; } Response.Write(callbackResult); Response.End(); } }
//计划调序 public void ASPxGridView1_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e) { string s = e.Parameters; string[] s1 = s.Split('|'); string type1 = s1[0]; string sql = ""; ASPxGridView atl1 = (ASPxGridView)sender; int count1 = atl1.Selection.Count; List <object> aa = atl1.GetSelectedFieldValues("RMES_ID"); List <object> flags = atl1.GetSelectedFieldValues("RUN_FLAG"); List <object> plancode = atl1.GetSelectedFieldValues("PLAN_CODE"); List <object> plinecode = atl1.GetSelectedFieldValues("PLINE_CODE"); switch (type1) { case "Confirm": if (flags.Contains("Y")) { e.Result = "Fail,包含不可操作项!"; //e.Result = "OK,上调成功!"; break; } for (int i = 0; i < count1; i++) { sql = "update data_plan set RUN_FLAG='Y' where rmes_id='" + aa[i] + "' and run_flag='N'"; dc.ExeSql(sql); } e.Result = "OK,已执行!"; break; case "Cancel": if (flags.Contains("N")) { e.Result = "Fail,包含不可操作项!"; //e.Result = "OK,上调成功!"; break; } for (int i = 0; i < count1; i++) { sql = "update data_plan set RUN_FLAG='N' where rmes_id='" + aa[i] + "' and run_flag='Y'"; dc.ExeSql(sql); } e.Result = "OK,已取消!"; break; case "Unlock": string password = s1[1]; for (int i = 0; i < count1; i++) { sql = "select yhmm from ms_skip_password where gzdd='" + plinecode[i] + "' and yhmm='" + password + "'"; dataConn dc = new dataConn(sql); DataTable dt = dc.GetTable(); if (dt.Rows.Count <= 0) { e.Result = "Fail,密码错误!"; } else { sql = "update atpujhb_tmp set flag='Y' where jhmc='" + plancode[i] + "'"; dc.ExeSql(sql); e.Result = "Password,解锁成功!"; } } break; default: break; } }
public void RaiseCallbackEvent(string eventArg) { //在这里调用登录处理事件 //处理登录 string thePlineCode = ""; string theUserCode = ""; string thePassword = ""; string theLoginStatus = ""; Boolean theLoginFlag = false; string theSessionCode = ""; string theCompanyCode = ""; string thePlineName = ""; //20071219 增加生产线名称 string theUserName = ""; string theUserId = ""; string theClientIp = Request.UserHostAddress; PubCs thePubCs = new PubCs(); //测试读取xml string theServerPath1 = Server.MapPath("~/").ToString(); theServerPath1 = theServerPath1 + "Rmes/Pub/Xml/RmesConfig.xml"; string theRet = thePubCs.ReadFromXml(theServerPath1, "SeparatorStr"); ArrayList theArrayList = thePubCs.SplitBySeparator(eventArg, theRet); string[] theString = thePubCs.ArrayListToString(theArrayList); theCompanyCode = theString[0]; theUserCode = theString[1].ToUpper(); thePassword = theString[2]; thePlineName = theString[3]; //用户代码和用户ID的转换 20110722 dataConn theDataConn002 = new dataConn(); theDataConn002.OpenConn(); theDataConn002.setTheSql("select func_get_user('" + theCompanyCode + "','MES','" + theUserCode + "','A') from dual"); theUserId = theDataConn002.GetValue(); theDataConn002.CloseConn(); //得到当前会话和公司号 userManager theUserManager1 = (userManager)Session["theUserManager"]; if (theUserManager1 != null) { theSessionCode = theUserManager1.theSessionCode; //theCompanyCode = theUserManager1.getCompanyCode(); } else { //theCompanyCode = (string)Session["theCompanyCode"]; } loginManager theLoginManager = new loginManager(); theLoginManager.setCompanyCode(theCompanyCode); theLoginFlag = theLoginManager.ReLoginIn(theUserId, thePubCs.AESEncrypt(thePassword), theClientIp, theSessionCode, thePlineCode); //得到用户名称 theUserName = theLoginManager.getUserName(); theUserCode = theLoginManager.getUserCode(); if (theLoginFlag) { TxtEmployeeCode.Text = "ok"; TxtPassword.Text = theLoginManager.theLoginFlag; } else { TxtEmployeeCode.Text = "error"; TxtPassword.Text = theLoginManager.theLoginFlag; } theLoginStatus = theLoginManager.theLoginFlag; theSessionCode = theLoginManager.theSessionCode; theCompanyCode = theLoginManager.getTheCompanyCode(); //处理不同情况 switch (theLoginStatus) { case "0": //登录成功 //处理登录用户信息 userManager theUserManager = new userManager(theSessionCode); theUserManager.setLoginFlag(theLoginFlag); theUserManager.setPlineCode(thePlineCode); theUserManager.setPlineName(thePlineName); theUserManager.setProgValue("/Rmes/Login/RmesIndex.aspx"); theUserManager.setProgCode("rmesIndex"); theUserManager.setProgName("系统登录"); theUserManager.setUserId(theUserId); theUserManager.setUserCode(theUserCode); theUserManager.setUserName(theUserName); theUserManager.setCompanyCode(theCompanyCode); Session["theUserManager"] = theUserManager; //在新的窗口打开无标题栏等信息 callbackResult = theLoginStatus; break; default: callbackResult = theLoginStatus; break; } }
protected void ASPxCbSubmit1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) { int count = 0; string oFlag, pline, station, pSeries, detectCode; char[] charSeparators = new char[] { ',' }; string[] collection = e.Parameter.Split(charSeparators); int cnt = collection.Length; oFlag = collection[0].ToString(); pline = collection[1].ToString(); station = collection[2].ToString(); pSeries = collection[3].ToString(); if (oFlag == "ADD") { //获取检测数据 List <string> s = new List <string>(); for (int i = 4; i < cnt; i++) { s.Add(collection[i].ToString()); } string[] s1 = s.ToArray(); if (ASPxGridView3.Selection.Count == 0) { e.Result = "Fail,请选择要增加的检测数据!"; return; } for (int i = 0; i < s1.Length; i++) { detectCode = s1[i].ToString(); string detectName = ""; string detectType = ""; string detectStandard = ""; string detectMax = ""; string detectMin = ""; string detectUnit = ""; string chSql = "select detect_name,detect_type,detect_standard,detect_max,detect_min,detect_unit from code_detect" + " where pline_code='" + pline + "' and detect_code='" + detectCode + "'"; dataConn chDc = new dataConn(chSql); DataTable chDt = chDc.GetTable(); if (chDt.Rows.Count > 0) { detectName = chDt.Rows[0]["detect_name"].ToString(); detectType = chDt.Rows[0]["detect_type"].ToString(); detectStandard = chDt.Rows[0]["detect_standard"].ToString(); detectMax = chDt.Rows[0]["detect_max"].ToString(); detectMin = chDt.Rows[0]["detect_min"].ToString(); detectUnit = chDt.Rows[0]["detect_unit"].ToString(); } //顺序号start string dSeq1 = ""; dataConn dc8 = new dataConn("select DETECT_SEQ from REL_STATION_DETECT_TEMP where pline_code ='" + pline + "' and PRODUCT_SERIES ='" + pSeries + "' and STATION_CODE ='" + station + "'"); if (dc8.GetState() == true) { string cSql = "select max(DETECT_SEQ) DETECT_SEQ_MAX from REL_STATION_DETECT_TEMP where pline_code ='" + pline + "' and PRODUCT_SERIES ='" + pSeries + "' and STATION_CODE ='" + station + "'"; dataConn dc1 = new dataConn(cSql); DataTable dt = dc1.GetTable(); string aa = dt.Rows[0]["DETECT_SEQ_MAX"].ToString(); dSeq1 = Convert.ToString(Convert.ToInt32(aa) + 1); } else { dSeq1 = "1"; } //顺序号end string inSqlTemp = "insert into REL_STATION_DETECT_TEMP(RMES_ID,PLINE_CODE,STATION_CODE,PRODUCT_SERIES,DETECT_CODE,DETECT_NAME,DETECT_TYPE," + "DETECT_STANDARD,DETECT_MAX,DETECT_MIN,DETECT_UNIT,DETECT_SEQ,MACHINENAME,INSERT_FLAG) " + "values(SEQ_RMES_ID.NEXTVAL,'" + pline + "','" + station + "','" + pSeries + "','" + detectCode + "','" + detectName + "','" + detectType + "'," + "'" + detectStandard + "','" + detectMax + "','" + detectMin + "','" + detectUnit + "','" + dSeq1 + "'," + "'" + GV_MachineName + "','3')"; dc.ExeSql(inSqlTemp); } e.Result = "OK,增加成功!"; return; } if (oFlag == "DELETE") { //获取工位 List <string> s = new List <string>(); for (int i = 4; i < cnt; i++) { s.Add(collection[i].ToString()); } string[] s1 = s.ToArray(); if (ASPxGridView2.Selection.Count == 0) { e.Result = "Fail,请选择要删除的检测数据!"; return; } for (int i = 0; i < s1.Length; i++) { detectCode = s1[i].ToString(); string sql = "select insert_flag from REL_STATION_DETECT_TEMP where PLINE_CODE='" + pline + "' " + " AND STATION_CODE='" + station + "' and PRODUCT_SERIES ='" + pSeries + "' " + " AND MACHINENAME='" + GV_MachineName + "' and detect_code='" + detectCode + "' "; dataConn dc1 = new dataConn(sql); DataTable dt1 = dc1.GetTable(); if (dt1.Rows[0]["insert_flag"].ToString() == "1") { string upSql = "update REL_STATION_DETECT_TEMP set insert_flag='2' where PLINE_CODE='" + pline + "' " + "AND STATION_CODE='" + station + "' and PRODUCT_SERIES ='" + pSeries + "' " + " AND MACHINENAME='" + GV_MachineName + "' and detect_code='" + detectCode + "' "; dc.ExeSql(upSql); } if (dt1.Rows[0]["insert_flag"].ToString() == "3") { string deSqlTemp = "DELETE FROM REL_STATION_DETECT_TEMP WHERE PLINE_CODE='" + pline + "' and PRODUCT_SERIES ='" + pSeries + "' " + " AND STATION_CODE='" + station + "' AND MACHINENAME='" + GV_MachineName + "' and detect_code='" + detectCode + "'"; dc.ExeSql(deSqlTemp); } } e.Result = "OK,删除成功!"; return; } if (collection[0] == "SURE") { string tempSql = "select RMES_ID,detect_code from REL_STATION_DETECT_TEMP"; dataConn tempDc = new dataConn(tempSql); DataTable tempDt = tempDc.GetTable(); for (count = 0; count < tempDt.Rows.Count; count++) { string rmesID = tempDt.Rows[count]["RMES_ID"].ToString(); detectCode = tempDt.Rows[count]["detect_code"].ToString(); string sql = "select insert_flag from REL_STATION_DETECT_TEMP where rmes_id='" + rmesID + "'"; dataConn dc1 = new dataConn(sql); DataTable dt1 = dc1.GetTable(); if (dt1.Rows[0]["insert_flag"].ToString() == "2") { //插入到日志表 try { string Sql2 = "INSERT INTO REL_STATION_DETECT_LOG (rmes_id,company_code,pline_code,station_code,product_series,detect_code,detect_name,detect_type,detect_standard," + "detect_max,detect_min,detect_unit,DETECT_SEQ,TEMP01,TEMP02,TEMP03,user_code,flag,rqsj)" + " SELECT rmes_id,company_code,pline_code,station_code,product_series,detect_code,detect_name,detect_type,detect_standard," + "detect_max,detect_min,detect_unit,DETECT_SEQ,TEMP01,TEMP02,TEMP03,'" + theUserCode + "' , 'DEL', SYSDATE FROM REL_STATION_DETECT WHERE rmes_id = '" + rmesID + "' "; dc.ExeSql(Sql2); } catch { return; } string dSql = "delete from REL_STATION_DETECT where rmes_id='" + rmesID + "'"; dc.ExeSql(dSql); } if (dt1.Rows[0]["insert_flag"].ToString() == "3") { string inSql = "insert into REL_STATION_DETECT(RMES_ID,COMPANY_CODE,PLINE_CODE,STATION_CODE,PRODUCT_SERIES,DETECT_CODE,DETECT_NAME,DETECT_TYPE," + "DETECT_STANDARD,DETECT_MAX,DETECT_MIN,DETECT_UNIT,DETECT_SEQ,input_person,input_time) " + "select RMES_ID,'" + theCompanyCode + "',PLINE_CODE,STATION_CODE,PRODUCT_SERIES,DETECT_CODE,DETECT_NAME,DETECT_TYPE," + "DETECT_STANDARD,DETECT_MAX,DETECT_MIN,DETECT_UNIT,DETECT_SEQ,'" + theUserId + "',sysdate from REL_STATION_DETECT_TEMP " + "where RMES_ID='" + rmesID + "'"; dc.ExeSql(inSql); //插入到日志表 try { string Sql2 = "INSERT INTO REL_STATION_DETECT_LOG (rmes_id,company_code,pline_code,station_code,product_series,detect_code,detect_name,detect_type,detect_standard," + "detect_max,detect_min,detect_unit,DETECT_SEQ,TEMP01,TEMP02,TEMP03,user_code,flag,rqsj)" + " SELECT rmes_id,company_code,pline_code,station_code,product_series,detect_code,detect_name,detect_type,detect_standard," + "detect_max,detect_min,detect_unit,DETECT_SEQ,TEMP01,TEMP02,TEMP03,'" + theUserCode + "' , 'ADD', SYSDATE FROM REL_STATION_DETECT WHERE rmes_id = '" + rmesID + "' "; dc.ExeSql(Sql2); } catch { return; } } } string sqlD = "DELETE from REL_STATION_DETECT_TEMP"; dc.ExeSql(sqlD); e.Result = "Sure,确认成功!"; return; } }
private void addfault() { string strTemp = Request.QueryString["fault"]; if (strTemp == null || strTemp == string.Empty) { Response.End(); } string[] str = strTemp.Split(','); for (int i = 0; i < str.Length; i++) { str[i] = str[i].TrimStart().TrimEnd(); } if (str[0] == string.Empty || str[1] == string.Empty) { Response.End(); } string[] code = new string[4]; string companycode = ""; string plinecode = ""; dataConn con = new dataConn(); con.OpenConn(); con.theComd.CommandType = CommandType.Text; string strSQL = "select company_code from code_fault_group t where t.fault_group_name='" + str[0] + "'"; con.theComd.CommandText = strSQL; companycode = con.theComd.ExecuteScalar().ToString(); strSQL = "select pline_type_code from code_fault_group t where t.fault_group_name='" + str[0] + "'"; con.theComd.CommandText = strSQL; plinecode = con.theComd.ExecuteScalar().ToString(); //fault_group strSQL = "select fault_group_code from code_fault_group t where t.fault_group_name='" + str[0] + "'"; con.theComd.CommandText = strSQL; code[0] = con.theComd.ExecuteScalar().ToString(); //fault_place strSQL = "select fault_place_code from code_fault_place t where t.fault_place_name='" + str[1] + "'"; con.theComd.CommandText = strSQL; code[1] = con.theComd.ExecuteScalar() as string; if (code[1] == null || code[1] == string.Empty) { strSQL = "select max(fault_place_code) from code_fault_place t"; con.theComd.CommandText = strSQL; object obj = con.theComd.ExecuteScalar(); strTemp = obj as string; int n = 1; int m = 3; if (strTemp != null) { n = Convert.ToInt32(strTemp.Substring(m, strTemp.Length - m)) + 1; } code[1] = "FPC" + string.Format("{0:D" + (strTemp.Length - m).ToString() + "}", n); strSQL = "insert into code_fault_place (company_code,fault_place_code,fault_place_name,pline_type_code) values('" + companycode + "','" + code[1] + "','" + str[1] + "','" + plinecode + "')"; con.theComd.CommandText = strSQL; if (con.theComd.ExecuteNonQuery() != 1) { code[1] = ""; } } if (str[2] != string.Empty && code[1] != "") { //fault_part strSQL = "select fault_part_code from code_fault_part t where t.fault_part_name='" + str[2] + "'"; con.theComd.CommandText = strSQL; code[2] = con.theComd.ExecuteScalar() as string; if (code[2] == null || code[2] == string.Empty) { strSQL = "select max(fault_part_code) from code_fault_part t"; con.theComd.CommandText = strSQL; object obj = con.theComd.ExecuteScalar(); strTemp = obj as string; int n = 1; int m = 4; if (strTemp != null) { n = Convert.ToInt32(strTemp.Substring(m, strTemp.Length - m)) + 1; } code[2] = "FPPC" + string.Format("{0:D" + (strTemp.Length - m).ToString() + "}", n); strSQL = "insert into code_fault_part (company_code,fault_part_code,fault_part_name,pline_type_code,fault_place_code) values('" + companycode + "','" + code[2] + "','" + str[2] + "','" + plinecode + "','" + code[1] + "')"; con.theComd.CommandText = strSQL; if (con.theComd.ExecuteNonQuery() != 1) { code[2] = ""; } } if (str[3] != string.Empty && code[2] != "") { //fault strSQL = "select fault_code from code_fault t where t.fault_name='" + str[3] + "'"; con.theComd.CommandText = strSQL; code[3] = con.theComd.ExecuteScalar() as string; if (code[3] == null || code[3] == string.Empty) { strSQL = "select max(fault_code) from code_fault t"; con.theComd.CommandText = strSQL; object obj = con.theComd.ExecuteScalar(); strTemp = obj as string; int n = 1; int m = 2; if (strTemp != null) { n = Convert.ToInt32(strTemp.Substring(m, strTemp.Length - m)) + 1; } code[3] = "FC" + string.Format("{0:D" + (strTemp.Length - m).ToString() + "}", n); strSQL = "insert into code_fault (company_code,fault_code,fault_name,pline_type_code) values('" + companycode + "','" + code[3] + "','" + str[3] + "','" + plinecode + "')"; con.theComd.CommandText = strSQL; if (con.theComd.ExecuteNonQuery() != 1) { code[3] = ""; } } } } int N = 0; string retCode = "", retName = ""; if (companycode != string.Empty && plinecode != string.Empty && code[0] != string.Empty && code[1] != string.Empty) { ///插入group_place关系表 strSQL = "insert into RMES_REL_GROUP_FAULTPLACE (company_code,fault_group_code,fault_place_code) values('" + companycode + "','" + code[0] + "','" + code[1] + "')"; con.theComd.CommandText = strSQL; try { N += con.theComd.ExecuteNonQuery(); } catch { N += 0; } retCode = code[0] + "_" + code[1]; retName = str[1]; if (code[2] != null && code[2] != string.Empty) { strSQL = "insert into RMES_REL_FAULTPLACE_FAULTPART (company_code,pline_type_code,fault_group_code,fault_place_code,fault_part_code) values('" + companycode + "','" + plinecode + "','" + code[0] + "','" + code[1] + "','" + code[2] + "')"; con.theComd.CommandText = strSQL; try { N += con.theComd.ExecuteNonQuery(); } catch { N += 0; } retCode += "_" + code[2]; retName = str[2]; if (code[3] != null && code[3] != string.Empty) { strSQL = "insert into RMES_REL_FAULTPART_FAULT (company_code,pline_type_code,fault_group_code,fault_place_code,fault_part_code,fault_code) values('" + companycode + "','" + plinecode + "','" + code[0] + "','" + code[1] + "','" + code[2] + "','" + code[3] + "')"; con.theComd.CommandText = strSQL; try { N += con.theComd.ExecuteNonQuery(); } catch { N += 0; } retCode += "_" + code[3]; retName = str[3]; } } } string strRet = "error:" + code[0] + "," + code[1] + "," + code[2] + "," + code[3] + "," + N.ToString(); if (N > 0) { strRet = "success:" + retCode + "," + retName; } Response.Expires = -1; Response.Write(strRet); Response.End(); }
protected void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { //判断超长 if (e.NewValues["COMPANY_CODE"].ToString().Length > 30) { e.RowError = "公司代码字节长度不能超过30!"; } if (e.NewValues["COMPANY_NAME"].ToString().Length > 30) { e.RowError = "公司名称字节长度不能超过30!"; } if (e.NewValues["COMPANY_NAME_BRIEF"].ToString().Length > 30) { e.RowError = "公司简称字节长度不能超过30!"; } if (e.NewValues["COMPANY_NAME_EN"].ToString().Length > 30) { e.RowError = "英文名称字节长度不能超过30!"; } if (e.NewValues["COMPANY_WEBSITE"].ToString().Length > 30) { e.RowError = "公司网址字节长度不能超过30!"; } if (e.NewValues["COMPANY_ADDRESS"].ToString().Length > 50) { e.RowError = "公司地址字节长度不能超过50!"; } //判断为空 if (e.NewValues["COMPANY_CODE"].ToString() == "" || e.NewValues["COMPANY_CODE"].ToString() == null) { e.RowError = "公司代码不能为空!"; } if (e.NewValues["COMPANY_NAME"].ToString() == "" || e.NewValues["COMPANY_NAME"].ToString() == null) { e.RowError = "公司名称不能为空!"; } if (e.NewValues["COMPANY_NAME_BRIEF"].ToString() == "" || e.NewValues["COMPANY_NAME_BRIEF"].ToString() == null) { e.RowError = "公司简称不能为空!"; } if (e.NewValues["COMPANY_NAME_EN"].ToString() == "" || e.NewValues["COMPANY_NAME_EN"].ToString() == null) { e.RowError = "英文名称不能为空!"; } if (e.NewValues["COMPANY_WEBSITE"].ToString() == "" || e.NewValues["COMPANY_WEBSITE"].ToString() == null) { e.RowError = "公司网址不能为空!"; } //新增判断键值重复 if (ASPxGridView1.IsNewRowEditing) { string chSql = "SELECT COMPANY_CODE, COMPANY_NAME, COMPANY_NAME_BRIEF, COMPANY_NAME_EN, COMPANY_WEBSITE, COMPANY_ADDRESS FROM CODE_COMPANY" + " WHERE COMPANY_CODE = '" + e.NewValues["COMPANY_CODE"].ToString() + "'"; dataConn dc = new dataConn(chSql); if (dc.GetState() == true) { e.RowError = "公司代码重复,请重新命名或分配!"; } } }
protected void Page_Load(object sender, EventArgs e) { userManager theUserManager = (userManager)Session["theUserManager"]; theCompanyCode = theUserManager.getCompanyCode(); theUserId = theUserManager.getUserId(); theUserCode = theUserManager.getUserCode(); theUserName = theUserManager.getUserName(); theProgramCode = "inv9100"; if (!IsPostBack) { //Session["9100PART"] = ""; //Session["9100USER"] = ""; dataConn theDataConn1 = new dataConn(" select FUNC_GET_PLANSITE('E','D')from dual"); theDataConn1.OpenConn(); string gQadSite1 = theDataConn1.GetValue(); if (gQadSite1 != "") { string sql1 = "select distinct in_user1 bgy from copy_in_mstr where upper(in_site)='" + gQadSite1 + "'"; Session["9100USER"] = sql1; SqlBgy.SelectCommand = sql1; SqlBgy.DataBind(); sql1 = "select distinct pt_part part from copy_pt_mstr where pt_phantom=0"; Session["9100PART"] = sql1; SqlPart.SelectCommand = sql1; SqlPart.DataBind(); } ASPxDateEdit1.Date = DateTime.Now; ASPxDateEdit3.Date = DateTime.Now.AddDays(1); } initCode(); if (Request["opFlag"] == "getEditSeries") { string str1 = "", str2 = "", str = ""; string pcode = Request["PCode"].ToString().Trim(); string qad = Request["QAD"].ToString().Trim(); dataConn theDataConn = new dataConn(" select FUNC_GET_PLANSITE('" + pcode + "','D')from dual"); theDataConn.OpenConn(); string gQadSite = theDataConn.GetValue(); if (gQadSite != "") { string sql = "select distinct in_user1 bgy from copy_in_mstr where upper(in_site)='" + gQadSite + "'"; Session["9100USER"] = sql; SqlBgy.SelectCommand = sql; SqlBgy.DataBind(); } if (qad == "false" || qad == "null")//若未勾选,显示所有实零件//|| qad == "null" { string sql = "select distinct pt_part part from copy_pt_mstr where pt_phantom=0"; Session["9100PART"] = sql; SqlPart.SelectCommand = sql; SqlPart.DataBind(); } else if (qad == "true")//若勾选,显示非QAD零件 { string sql = "select distinct part from atpubkflpart where part_type='1' and gzdd='" + pcode + "' "; Session["9100PART"] = sql; SqlPart.SelectCommand = sql; SqlPart.DataBind(); } this.Response.Write(str); this.Response.End(); } if (Request["opFlag"] == "getEditSeries2") { string str2 = ""; string part = Request["PART"].ToString().Trim(); string qad = Request["QAD"].ToString().Trim(); if (qad == "false" || qad == "null")//若未勾选 { string sql = "select pt_desc2 from copy_pt_mstr where upper(pt_part)='" + part.ToUpper() + "'"; DataTable dt = dc.GetTable(sql); if (dt.Rows.Count == 0) { str2 = " "; this.Response.Write(str2); this.Response.End(); return; } str2 = dt.Rows[0][0].ToString(); } else if (qad == "true")//若勾选 { string sql = "select part_desc from atpubkflpart where upper(pt_part)='" + part.ToUpper() + "' "; DataTable dt = dc.GetTable(sql); if (dt.Rows.Count == 0) { str2 = " "; this.Response.Write(str2); this.Response.End(); return; } str2 = dt.Rows[0][0].ToString(); } this.Response.Write(str2); this.Response.End(); } setCondition(); Query(); }