//保存的时候,如果是圆机则更新AvaWidth和GEKComment的信息;带子和横机都只更新GEKComment信息 protected void btnSave_Click(object sender, EventArgs e) { DbTransaction tran = DataAccess.DefaultDB.BeginTransaction(); try { if (ViewState["MGType"].ToString() == "Fabric") { #region 保存数据 List <AvaWidthModel> listAWM = avaWidth.GetAvaWidth(); QcavailablewidthModelList qcAvaWidthList = CreateAvaWidth(listAWM); QcmaininfoModel mainModel = new QcmaininfoModel(); mainModel.QualityCode = tQC.Text; mainModel.Remark = txtAvaRemark.Text; if (!string.IsNullOrEmpty(HidArributeValue.Value)) { string[] strArray = HidArributeValue.Value.Replace("<>", "#").Split('#'); //todo by mengjw mainModel.QC_Ref_PPO = strArray[10]; mainModel.QC_Ref_GP = strArray[11] == "null" ? "" : strArray[11];; mainModel.HF_Ref_PPO = strArray[12]; mainModel.HF_Ref_GP = strArray[13] == "null" ? "" : strArray[13];; mainModel.RF_Remark = strArray[14]; //add by zheng zhou 2016-8-3 保存QC,HF的修改日志 if (Request.Form["hd_HF_Ref_GP_Old"] != (strArray[13] == "null" ? "" : strArray[13]) || Request.Form["hd_HF_Ref_PPO_Old"] != (strArray[12] == "null" ? "" : strArray[12]) || Request.Form["hd_QC_Ref_GP_Old"] != (strArray[11] == "null" ? "" : strArray[11]) || Request.Form["hd_QC_Ref_PPO_Old"] != (strArray[10] == "null" ? "" : strArray[10])) { QC_HF_ChangeLogModel changeModel = new QC_HF_ChangeLogModel(); QC_HF_ChangeLogManager changeManager = new QC_HF_ChangeLogManager(); changeModel.QualityCode = tQC.Text.Trim(); changeModel.HF_Ref_GP_New = strArray[13] == "null" ? "" : strArray[13]; changeModel.HF_Ref_PPO_New = strArray[12] == "null" ? "" : strArray[12]; changeModel.QC_Ref_GP_New = strArray[11] == "null" ? "" : strArray[11]; changeModel.QC_Ref_PPO_New = strArray[10] == "null" ? "" : strArray[10]; changeModel.HF_Ref_GP_Old = Request.Form["hd_HF_Ref_GP_Old"]; changeModel.HF_Ref_PPO_Old = Request.Form["hd_HF_Ref_PPO_Old"]; changeModel.QC_Ref_GP_Old = Request.Form["hd_QC_Ref_GP_Old"]; changeModel.QC_Ref_PPO_Old = Request.Form["hd_QC_Ref_PPO_Old"]; changeModel.CreateDate = System.DateTime.Now; changeModel.Creator = HttpContext.Current.Session["UserId"].ToString(); changeManager.AddModel(changeModel, tran); } //////////////////////////////////////////////// } qcAvaWidthManager.DeleteModel(new QcavailablewidthModel() { QualityCode = tQC.Text }, tran); qcAvaWidthManager.AddModels(qcAvaWidthList, tran); qcMainManager.UpdateModelRemark(mainModel, tran); #endregion } // add by zheng zhou 2016-8-2 按照是否点击选择ppono,分不同的方法保留qcCustomer对象 QccustomerlibraryModel qcCustomer = CreateCustomer(); if (qcCustomer.BuyerId == "**X") { qcCustomerManager.UpdateModelThree(qcCustomer, tran); } else { qcCustomerManager.UpdateModelOne(qcCustomer, tran); } //////////////////////////////////////////////////////////////////////////////////// tran.Commit(); if (ViewState["MGType"].ToString() == "Fabric" && !string.IsNullOrEmpty(HidArributeValue.Value)) { //added by hejianh 2020-04-20 对接系统质量&手感参办自动更新 string[] strArrayStr = HidArributeValue.Value.Replace("<>", "#").Split('#'); string HF_Ref_GP_New = strArrayStr[13] == "null" ? "" : strArrayStr[13]; string HF_Ref_PPO_New = strArrayStr[12] == "null" ? "" : strArrayStr[12]; string QC_Ref_GP_New = strArrayStr[11] == "null" ? "" : strArrayStr[11]; string QC_Ref_PPO_New = strArrayStr[10] == "null" ? "" : strArrayStr[10]; string HF_Ref_GP_Old = Request.Form["hd_HF_Ref_GP_Old"]; string HF_Ref_PPO_Old = Request.Form["hd_HF_Ref_PPO_Old"]; string QC_Ref_GP_Old = Request.Form["hd_QC_Ref_GP_Old"]; string QC_Ref_PPO_Old = Request.Form["hd_QC_Ref_PPO_Old"]; string remark_New = strArrayStr[14] == "null" ? "" : strArrayStr[14]; string remark_Old = Request.Form["remark_Old"]; if (HF_Ref_GP_New != HF_Ref_GP_Old || HF_Ref_PPO_New != HF_Ref_PPO_Old || QC_Ref_GP_New != QC_Ref_GP_Old || QC_Ref_PPO_New != QC_Ref_PPO_Old || remark_New != remark_Old) { //创建和数据库的连接 string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; OracleConnection oraCon = new OracleConnection(connString); //打开连接 oraCon.Open(); OracleCommand oraCmd = new OracleCommand(); //新建一个事务对象的实例 OracleTransaction oraTact = oraCon.BeginTransaction(); oraCmd.Connection = oraCon; //绑定事务对象到命令 oraCmd.Transaction = oraTact; try { //将一个表的满足某条件的行的指定的列插入到另一个表 oraCmd.CommandText = "INSERT INTO ESCMOWNER.QCMAININFO_SYNC_LOG(SYNC_LOG_ID,QUALITY_CODE,SYNC_TO_ESCM_FLAG,CREATE_USER_ID,CREATE_DATE) SELECT QCMAININFO_SYNC_LOG_SEQ.NEXTVAL,'" + tQC.Text.Trim().ToString() + "','N','" + HttpContext.Current.Session["UserId"].ToString() + "',SYSDATE FROM DUAL"; int r = oraCmd.ExecuteNonQuery(); r = 10; //没有错误,执行提交命令 oraTact.Commit(); } catch (Exception ex) { //出现错误,执行回滚命令 oraTact.Rollback(); //弹出窗口显示错误 Response.Write("<script>alert('" + ex.Message + "')</script>"); } finally { //关闭连接 oraCon.Close(); } //插入数据库完毕后做调用webserver // webservice调用地址 //string url = "http://192.168.27.80/YPD_DEV/YPDWebService.asmx?op=SyncQualityHandfeelReference"; //测试地址 string url = "http://192.168.7.187/YPD/YPDWebService.asmx?op=SyncQualityHandfeelReference"; //正式地址 // SOAP格式内容,参数为:http://www.what21.com StringBuilder param = new StringBuilder(); param.Append("<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\" > "); param.Append("<soap12:Body>"); param.Append("<SyncQualityHandfeelReference xmlns=\"http://tempuri.org/\">"); param.Append("<qualityCodes>" + tQC.Text.Trim().ToString() + "</qualityCodes>"); param.Append("<userId>" + HttpContext.Current.Session["UserId"].ToString() + "</userId>"); param.Append("</SyncQualityHandfeelReference>"); param.Append("</soap12:Body>"); param.Append("</soap12:Envelope>"); try { // 创建HttpWebRequest对象 HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); // 设置POST调用方法 httpRequest.Method = "POST"; // 设置HTTP头ContentType //httpRequest.ContentType = "application/soap+xml;charset=UTF-8;action=\"http://192.168.27.80/YPD_DEV/YPDWebService.asmx?op=SyncQualityHandfeelReference\""; //测试地址 httpRequest.ContentType = "application/soap+xml;charset=UTF-8;action=\"http://192.168.7.187/YPD/YPDWebService.asmx?op=SyncQualityHandfeelReference\""; //正式地址 // 设置HTTP头SOAPAction的值 httpRequest.Headers.Add("SOAPAction", "urn:world"); // 调用内容 byte[] bytes = Encoding.UTF8.GetBytes(param.ToString()); // 设置HTTP头内容的长度 httpRequest.ContentLength = param.ToString().Length; using (Stream reqStream = httpRequest.GetRequestStream()) { reqStream.Write(bytes, 0, bytes.Length); reqStream.Flush(); } // HttpWebRequest发起调用 using (HttpWebResponse myResponse = (HttpWebResponse)httpRequest.GetResponse()) { // StreamReader对象 StreamReader sr = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); // 返回结果 string responseString = sr.ReadToEnd(); Console.WriteLine("调用结果" + responseString); } } catch (Exception ex) { //弹出窗口显示错误 //Response.Write("<script>alert('" + ex.Message + "')</script>"); } } //added by hejianh 2020-04-20 对接系统质量&手感参办自动更新 } //Response.Write("<script language='JavaScript'>alert('Success');</script>"); //ClientScript.RegisterClientScriptBlock(typeof(string), "js", "SearchQC1();", true); ClientScript.RegisterStartupScript(this.GetType(), "", "<script>SearchQC1();</script>"); } catch (Exception ex) { tran.Rollback(); Response.Write("<script language='JavaScript'>alert('" + ex.Message.Replace("'", " ").Replace("\"", " ").Replace("\n", " ").Replace("\r", " ") + "');</script>"); return; } // Response.Write("<script language='JavaScript'>alert('Successfully updated!');window.location='EditQC.aspx?MG=" + ViewState["MGType"].ToString() + "&QC=" + tQC.Text + "&customerId=" + tCustomerId.Text + "';</script>"); }
//保存的时候,如果是圆机则更新AvaWidth和GEKComment的信息;带子和横机都只更新GEKComment信息 protected void btnSave_Click(object sender, EventArgs e) { DbTransaction tran = DataAccess.DefaultDB.BeginTransaction(); try { if (ViewState["MGType"].ToString() == "Fabric") { List <AvaWidthModel> listAWM = avaWidth.GetAvaWidth(); QcavailablewidthModelList qcAvaWidthList = CreateAvaWidth(listAWM); QcmaininfoModel mainModel = new QcmaininfoModel(); mainModel.QualityCode = tQC.Text; mainModel.Remark = txtAvaRemark.Text; if (!string.IsNullOrEmpty(HidArributeValue.Value)) { string[] strArray = HidArributeValue.Value.Replace("<>", "#").Split('#'); //todo by mengjw mainModel.QC_Ref_PPO = strArray[10]; mainModel.QC_Ref_GP = strArray[11] == "null" ? "" : strArray[11];; mainModel.HF_Ref_PPO = strArray[12]; mainModel.HF_Ref_GP = strArray[13] == "null" ? "" : strArray[13];; mainModel.RF_Remark = strArray[14]; //add by zheng zhou 2016-8-3 保存QC,HF的修改日志 if (Request.Form["hd_HF_Ref_GP_Old"] != (strArray[13] == "null" ? "" : strArray[13]) || Request.Form["hd_HF_Ref_PPO_Old"] != (strArray[12] == "null" ? "" : strArray[12]) || Request.Form["hd_QC_Ref_GP_Old"] != (strArray[11] == "null" ? "" : strArray[11]) || Request.Form["hd_QC_Ref_PPO_Old"] != (strArray[10] == "null" ? "" : strArray[10])) { QC_HF_ChangeLogModel changeModel = new QC_HF_ChangeLogModel(); QC_HF_ChangeLogManager changeManager = new QC_HF_ChangeLogManager(); changeModel.QualityCode = tQC.Text.Trim(); changeModel.HF_Ref_GP_New = strArray[13] == "null" ? "" : strArray[13]; changeModel.HF_Ref_PPO_New = strArray[12] == "null" ? "" : strArray[12]; changeModel.QC_Ref_GP_New = strArray[11] == "null" ? "" : strArray[11]; changeModel.QC_Ref_PPO_New = strArray[10] == "null" ? "" : strArray[10]; changeModel.HF_Ref_GP_Old = Request.Form["hd_HF_Ref_GP_Old"]; changeModel.HF_Ref_PPO_Old = Request.Form["hd_HF_Ref_PPO_Old"]; changeModel.QC_Ref_GP_Old = Request.Form["hd_QC_Ref_GP_Old"]; changeModel.QC_Ref_PPO_Old = Request.Form["hd_QC_Ref_PPO_Old"]; changeModel.CreateDate = System.DateTime.Now; changeModel.Creator = HttpContext.Current.Session["UserId"].ToString(); changeManager.AddModel(changeModel, tran); } //////////////////////////////////////////////// } qcAvaWidthManager.DeleteModel(new QcavailablewidthModel() { QualityCode = tQC.Text }, tran); qcAvaWidthManager.AddModels(qcAvaWidthList, tran); qcMainManager.UpdateModelRemark(mainModel, tran); } // add by zheng zhou 2016-8-2 按照是否点击选择ppono,分不同的方法保留qcCustomer对象 QccustomerlibraryModel qcCustomer = CreateCustomer(); if (qcCustomer.BuyerId == "**X") { qcCustomerManager.UpdateModelThree(qcCustomer, tran); } else { qcCustomerManager.UpdateModelOne(qcCustomer, tran); } //////////////////////////////////////////////////////////////////////////////////// tran.Commit(); Response.Write("<script language='JavaScript'>alert('Success')</script>"); } catch (Exception ex) { tran.Rollback(); Response.Write("<script language='JavaScript'>alert('" + ex.Message.Replace("'", " ").Replace("\"", " ").Replace("\n", " ").Replace("\r", " ") + "');</script>"); return; } // Response.Write("<script language='JavaScript'>alert('Successfully updated!');window.location='Edit_Ref.aspx?MG=" + ViewState["MGType"].ToString() + "&QC=" + tQC.Text + "&customerId=" + tCustomerId.Text + "';</script>"); }