/// <summary> /// 更新一条数据 /// </summary> public string Update(TH.Model._8D报告 model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update UFDLImport.._8D报告 set "); if (model.TaskID != null) { strSql.Append("TaskID=" + model.TaskID + ","); } else { strSql.Append("TaskID= null ,"); } if (model.组长 != null) { strSql.Append("组长='" + model.组长 + "',"); } else { strSql.Append("组长= null ,"); } if (model.品管部 != null) { strSql.Append("品管部='" + model.品管部 + "',"); } else { strSql.Append("品管部= null ,"); } if (model.工程部 != null) { strSql.Append("工程部='" + model.工程部 + "',"); } else { strSql.Append("工程部= null ,"); } if (model.制造部 != null) { strSql.Append("制造部='" + model.制造部 + "',"); } else { strSql.Append("制造部= null ,"); } if (model.调查情况 != null) { strSql.Append("调查情况='" + model.调查情况 + "',"); } if (model.调查情况签名 != null) { strSql.Append("调查情况签名='" + model.调查情况签名 + "',"); } if (model.调查情况日期 != null && model.调查情况日期 != DateTime.MinValue) { strSql.Append("调查情况日期='" + model.调查情况日期 + "',"); } if (model.临时措施 != null) { strSql.Append("临时措施='" + model.临时措施 + "',"); } if (model.临时措施责任人 != null) { strSql.Append("临时措施责任人='" + model.临时措施责任人 + "',"); } if (model.临时措施完成时限 != null && model.临时措施完成时限 != DateTime.MinValue) { strSql.Append("临时措施完成时限='" + model.临时措施完成时限 + "',"); } if (model.临时措施结果验证 != null) { strSql.Append("临时措施结果验证='" + model.临时措施结果验证 + "',"); } if (model.原因分析 != null) { strSql.Append("原因分析='" + model.原因分析 + "',"); } if (model.纠正措施 != null) { strSql.Append("纠正措施='" + model.纠正措施 + "',"); } if (model.纠正措施责任人 != null) { strSql.Append("纠正措施责任人='" + model.纠正措施责任人 + "',"); } if (model.纠正措施完成时限 != null && model.纠正措施完成时限 != DateTime.MinValue) { strSql.Append("纠正措施完成时限='" + model.纠正措施完成时限 + "',"); } if (model.纠正措施结果验证 != null) { strSql.Append("纠正措施结果验证='" + model.纠正措施结果验证 + "',"); } if (model.预防措施 != null) { strSql.Append("预防措施='" + model.预防措施 + "',"); } if (model.预防措施责任人 != null) { strSql.Append("预防措施责任人='" + model.预防措施责任人 + "',"); } if (model.预防措施完成时限 != null && model.预防措施完成时限 != DateTime.MinValue) { strSql.Append("预防措施完成时限='" + model.预防措施完成时限 + "',"); } if (model.预防措施结果验证 != null) { strSql.Append("预防措施结果验证='" + model.预防措施结果验证 + "',"); } if (model.效果 != null) { strSql.Append("效果='" + model.效果 + "',"); } if (model.效果签名 != null) { strSql.Append("效果签名='" + model.效果签名 + "',"); } if (model.再次提交 != null) { strSql.Append("再次提交='" + model.再次提交 + "',"); } if (model.再次提交日期 != null && model.再次提交日期 != DateTime.MinValue) { strSql.Append("再次提交日期='" + model.再次提交日期 + "',"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where IDHead=" + model.IDHead + " "); return(strSql.ToString()); }
private void btnSave() { if (sState != "edit") { throw new Exception("请先点击编辑,并编辑数据后保存"); } if (label状态.Text == "批准") { throw new Exception("已经批准,不能编辑"); } txtIDHead.Focus(); TH.Model._8D报告 model = new TH.Model._8D报告(); if (txtIDHead.Text.Trim() == "") { throw new Exception("获得单据ID失败"); } string sSQL = "select * from UFDLImport.._8D报告 where idHead = " + txtIDHead.Text.Trim(); DataTable dt = clsSQLCommond.ExecQuery(sSQL); if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["状态"].ToString().Trim().ToLower() == "true" && dt.Rows[0]["审批人"].ToString().Trim() != "") { throw new Exception("单据已经批准"); } model.IDHead = ReturnObjectToLong(txtIDHead.Text.Trim()); model.TaskID = ReturnObjectToLong(txtTaskID.Text.Trim()); if (txt组长.Text.Trim() == "" && txt品管部.Text.Trim() == "" && txt工程部.Text.Trim() == "" && txt制造部.Text.Trim() == "") { throw new Exception("组长,品管部,工程部,制造部 必须至少填写一栏"); } model.组长 = txt组长.Text.Trim(); model.品管部 = txt品管部.Text.Trim(); model.工程部 = txt工程部.Text.Trim(); model.制造部 = txt制造部.Text.Trim(); if (txt调查情况.Text.Trim() == "") { throw new Exception("调查情况 必输"); } model.调查情况 = txt调查情况.Text.Trim(); if (txt签名.Text.Trim() == "") { throw new Exception("签名 必输"); } model.调查情况签名 = txt签名.Text.Trim(); if (ReturnObjectToDatetime(dtm签名日期.DateTime.ToString("yyyy-MM-dd")) < ReturnObjectToDatetime("2000-1-1")) { throw new Exception("调查签名日期 必输"); } model.调查情况日期 = ReturnObjectToDatetime(dtm签名日期.DateTime.ToString("yyyy-MM-dd")); if (txt临时措施.Text.Trim() == "") { throw new Exception("临时措施 必输"); } model.临时措施 = txt临时措施.Text.Trim(); if (txt临时措施责任人.Text.Trim() == "") { throw new Exception("临时措施责任人 必输"); } model.临时措施责任人 = txt临时措施责任人.Text.Trim(); if (ReturnObjectToDatetime(dtm临时措施完成时限.DateTime.ToString("yyyy-MM-dd")) < ReturnObjectToDatetime("2000-1-1")) { throw new Exception("临时措施完成时限 必输"); } model.临时措施完成时限 = ReturnObjectToDatetime(dtm临时措施完成时限.DateTime.ToString("yyyy-MM-dd")); if (txt临时措施结果验证.Text.Trim() == "") { throw new Exception("临时措施结果验证 必输"); } model.临时措施结果验证 = txt临时措施结果验证.Text.Trim(); if (txt原因分析.Text.Trim() == "") { throw new Exception("原因分析 必输"); } model.原因分析 = txt原因分析.Text.Trim(); if (txt纠正措施.Text.Trim() == "") { throw new Exception("纠正措施 必输"); } model.纠正措施 = txt纠正措施.Text.Trim(); if (txt纠正措施责任人.Text.Trim() == "") { throw new Exception("纠正措施责任人 必输"); } model.纠正措施责任人 = txt纠正措施责任人.Text.Trim(); if (ReturnObjectToDatetime(dtm纠正措施完成时限.DateTime.ToString("yyyy-MM-dd")) < ReturnObjectToDatetime("2000-1-1")) { throw new Exception("纠正措施完成时限 必输"); } model.纠正措施完成时限 = ReturnObjectToDatetime(dtm纠正措施完成时限.DateTime.ToString("yyyy-MM-dd")); if (txt纠正措施结果验证.Text.Trim() == "") { throw new Exception("纠正措施结果验证 必输"); } model.纠正措施结果验证 = txt纠正措施结果验证.Text.Trim(); if (txt预防措施.Text.Trim() == "") { throw new Exception("预防措施 必输"); } model.预防措施 = txt预防措施.Text.Trim(); if (txt预防措施责任人.Text.Trim() == "") { throw new Exception("预防措施责任人 必输"); } model.预防措施责任人 = txt预防措施责任人.Text.Trim(); if (ReturnObjectToDatetime(dtm预防措施完成时限.DateTime.ToString("yyyy-MM-dd")) < ReturnObjectToDatetime("2000-1-1")) { throw new Exception("预防措施完成时限 必输"); } model.预防措施完成时限 = ReturnObjectToDatetime(dtm预防措施完成时限.DateTime.ToString("yyyy-MM-dd")); if (txt预防措施结果验证.Text.Trim() == "") { throw new Exception("预防措施结果验证 必输"); } model.预防措施结果验证 = txt预防措施结果验证.Text.Trim(); model.效果 = txt效果.Text.Trim(); model.效果签名 = txt效果签名.Text.Trim(); TH.DAL._8D报告 dal = new TH.DAL._8D报告(); sSQL = "select count(1) from UFDLImport.._8D报告 where IDHead = " + model.IDHead.ToString(); dt = clsSQLCommond.ExecQuery(sSQL); int iCou = ReturnObjectToInt(dt.Rows[0][0]); if (iCou == 0) { sSQL = dal.Add(model); } else { model.再次提交 = sUserName; model.再次提交日期 = DateTime.Now; sSQL = dal.Update(model); } iCou = clsSQLCommond.ExecSql(sSQL); if (iCou > 0) { MessageBox.Show("保存成功"); SetEnable(false); } #region 发送邮件给品管 sSQL = @" select distinct sEMail from dbo._UserInfo left join UFDLImport.._vendUid on vchrUid=uid and accid = 200 and accyear = 111111 left join @u8.vendor on cVenCode = vendCode left join @u8.Department d on d.cDepCode=_UserInfo.cDepCode where d.cdepcode = '6'and isnull(sEMail,'') <> '' "; sSQL = sSQL.Replace("111111", FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName.Substring(11, 4)); dt = clsSQLCommond.ExecQuery(sSQL); if (dt == null || dt.Rows.Count < 1) { throw new Exception("获得品管邮箱失败"); } string sMail = ""; for (int i = 0; i < dt.Rows.Count; i++) { if (sMail == "") { sMail = dt.Rows[i]["sEMail"].ToString().Trim(); } else { sMail = sMail + ";" + dt.Rows[i]["sEMail"].ToString().Trim(); } } if (sMail.Trim() == "") { throw new Exception("获得供应商邮箱失败"); } string sText = "杜乐8D改进报告:" + txt编号.Text.Trim() + " 已拒绝"; if (sMail.Trim() != "") { btnSendMail(sText, sMail); } #endregion }
/// <summary> /// 增加一条数据 /// </summary> public string Add(TH.Model._8D报告 model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.IDHead != null) { strSql1.Append("IDHead,"); strSql2.Append("" + model.IDHead + ","); } if (model.TaskID != null) { strSql1.Append("TaskID,"); strSql2.Append("" + model.TaskID + ","); } if (model.组长 != null) { strSql1.Append("组长,"); strSql2.Append("'" + model.组长 + "',"); } if (model.品管部 != null) { strSql1.Append("品管部,"); strSql2.Append("'" + model.品管部 + "',"); } if (model.工程部 != null) { strSql1.Append("工程部,"); strSql2.Append("'" + model.工程部 + "',"); } if (model.制造部 != null) { strSql1.Append("制造部,"); strSql2.Append("'" + model.制造部 + "',"); } if (model.调查情况 != null) { strSql1.Append("调查情况,"); strSql2.Append("'" + model.调查情况 + "',"); } if (model.调查情况签名 != null) { strSql1.Append("调查情况签名,"); strSql2.Append("'" + model.调查情况签名 + "',"); } if (model.调查情况日期 != null && model.调查情况日期 != DateTime.MinValue) { strSql1.Append("调查情况日期,"); strSql2.Append("'" + model.调查情况日期 + "',"); } if (model.临时措施 != null) { strSql1.Append("临时措施,"); strSql2.Append("'" + model.临时措施 + "',"); } if (model.临时措施责任人 != null) { strSql1.Append("临时措施责任人,"); strSql2.Append("'" + model.临时措施责任人 + "',"); } if (model.临时措施完成时限 != null && model.临时措施完成时限 != DateTime.MinValue) { strSql1.Append("临时措施完成时限,"); strSql2.Append("'" + model.临时措施完成时限 + "',"); } if (model.临时措施结果验证 != null) { strSql1.Append("临时措施结果验证,"); strSql2.Append("'" + model.临时措施结果验证 + "',"); } if (model.原因分析 != null) { strSql1.Append("原因分析,"); strSql2.Append("'" + model.原因分析 + "',"); } if (model.纠正措施 != null) { strSql1.Append("纠正措施,"); strSql2.Append("'" + model.纠正措施 + "',"); } if (model.纠正措施责任人 != null) { strSql1.Append("纠正措施责任人,"); strSql2.Append("'" + model.纠正措施责任人 + "',"); } if (model.纠正措施完成时限 != null && model.纠正措施完成时限 != DateTime.MinValue) { strSql1.Append("纠正措施完成时限,"); strSql2.Append("'" + model.纠正措施完成时限 + "',"); } if (model.纠正措施结果验证 != null) { strSql1.Append("纠正措施结果验证,"); strSql2.Append("'" + model.纠正措施结果验证 + "',"); } if (model.预防措施 != null) { strSql1.Append("预防措施,"); strSql2.Append("'" + model.预防措施 + "',"); } if (model.预防措施责任人 != null) { strSql1.Append("预防措施责任人,"); strSql2.Append("'" + model.预防措施责任人 + "',"); } if (model.预防措施完成时限 != null && model.预防措施完成时限 != DateTime.MinValue) { strSql1.Append("预防措施完成时限,"); strSql2.Append("'" + model.预防措施完成时限 + "',"); } if (model.预防措施结果验证 != null) { strSql1.Append("预防措施结果验证,"); strSql2.Append("'" + model.预防措施结果验证 + "',"); } if (model.效果 != null) { strSql1.Append("效果,"); strSql2.Append("'" + model.效果 + "',"); } if (model.效果签名 != null) { strSql1.Append("效果签名,"); strSql2.Append("'" + model.效果签名 + "',"); } strSql.Append("insert into UFDLImport.._8D报告("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); return(strSql.ToString()); }