public static bool InsertMandate(MandateInfo mandate, List <SampleInfo> sampleList, ref string err) { string MandateSql = GSqlSentence.GetInsertInfoByD <MandateInfo>(mandate, "MandateInfo"); string sampleSql = GSqlSentence.GetInsertByList <SampleInfo>(sampleList, "SampleInfo"); List <TestItem> testItemList = GetItemIDs(mandate.TestingItems, mandate.YYCode); string testItemSql = GSqlSentence.GetInsertByList <TestItem>(testItemList, "TestItem"); string sql = "select count(*) from MandateInfo where YYCode='" + mandate.YYCode + "'"; try { if ((int)SQLBase.ExecuteScalar(sql) > 0) { err = "该委托单已添加"; return(false); } if (SQLBase.ExecuteNonQuery(MandateSql) > 0) { if (!UpdateYYCode(mandate.YYCode)) { err = "预约号更新失败"; return(false); } if (sampleList.Count > 0) { if (SQLBase.ExecuteNonQuery(sampleSql) <= 0) { err = "样品信息添加失败"; return(false); } } if (testItemList.Count > 0) { if (SQLBase.ExecuteNonQuery(testItemSql) <= 0) { err = "检测项目添加失败"; return(false); } } string content = "添加委托单信息"; if (!insertLog(mandate.YYCode, content)) { err = "更新日志失败"; return(false); } return(true); } err = "委托信息添加失败"; } catch (Exception e) { err = e.Message; } return(false); }
public static string GetNewPid() { string strCID = ""; string strYMD = DateTime.Now.ToString("yyyyMMdd"); string strSelPID = "select * from PurchaseApplication where DateRecord='" + strYMD + "'"; DataTable dtPMaxID = SQLBase.FillTable(strSelPID, "MainPP"); int intNewID = 0; if (dtPMaxID == null) { return(strCID); } if (dtPMaxID.Rows.Count == 0) { string strInsertID = "insert into PIDNo (PID,PidNo,DateRecord) values('S',0,'" + strYMD + "')"; SQLBase.ExecuteNonQuery(strInsertID, "SalesDBCnn"); intNewID = 0; } else { intNewID = Convert.ToInt32(dtPMaxID.Rows[0]["PidNo"]); } intNewID++; string str = "select PID, PidNo,DateRecord from PIDNo where DateRecord='" + strYMD + "'"; dtPMaxID = SQLBase.FillTable(strSelPID, "SalesDBCnn"); strCID = dtPMaxID.Rows[0]["CID"].ToString() + DateTime.Now.ToString("yyyyMMdd") + GFun.GetNum(intNewID, 3); return(strCID); }
public static string GetSPid(string folderBack) { string[] arr = folderBack.Split('/'); Acc_Account account = GAccount.GetAccountInfo(); int unitId = Convert.ToInt16(account.UnitID); string strPID = ""; string strYMD = DateTime.Now.ToString("yyMMdd"); string strSelPID = "select SPID, SPidNo from [" + arr[0] + "].." + arr[6] + " where DateRecord='" + strYMD + "'"; DataTable dtPMaxID = SQLBase.FillTable(strSelPID); int intNewID = 0; if (dtPMaxID == null) { return(strPID); } if (dtPMaxID.Rows.Count == 0) { string strInsertID = "insert into [" + arr[0] + "].." + arr[6] + " (SPID,SPidNo,DateRecord) values('P',0,'" + strYMD + "')"; SQLBase.ExecuteNonQuery(strInsertID); intNewID = 0; } else { intNewID = Convert.ToInt32(dtPMaxID.Rows[0]["SPidNo"]); } intNewID++; string strUpdateID = "update [" + arr[0] + "].." + arr[6] + " set SPidNo='" + intNewID + "' where DateRecord ='" + strYMD + "'"; SQLBase.ExecuteNonQuery(strUpdateID); strPID = dtPMaxID.Rows[0]["SPID"].ToString() + DateTime.Now.ToString("yyMMdd") + GFun.GetNum(unitId, 4) + GFun.GetNum(intNewID, 4); return(strPID); }
public static bool UpdateMcode(string type, string MCode) { string year = DateTime.Now.ToString("yyyy"); string MaxValue; if (type == "F" || type == "B") { MaxValue = MCode.Substring(6); } else { MaxValue = MCode.Substring(7); } string sql = "select count(*) from tk_ConfigMIDRecord where Year='" + year + "' and type ='" + type + "'"; int count = (int)SQLBase.ExecuteScalar(sql); if (count > 0) { sql = "update tk_ConfigMIDRecord set MaxValue =" + MaxValue + " where Year='" + year + "' and type='" + type + "'"; } else { sql = "insert into tk_ConfigMIDRecord(year,type,MaxValue) values ('" + year + "','" + type + "'," + MaxValue + ")"; } if (SQLBase.ExecuteNonQuery(sql) > 0) { return(true); } else { return(false); } }
public static bool SaveRepeal(string YYCode, string RepealReason, string MCode) { string sql = "update MandateInfo set state=-1,RepealReason='" + RepealReason + "' where YYCode='" + YYCode + "'"; if (SQLBase.ExecuteNonQuery(sql) > 0) { sql = "select count(*) from TaskOrder where Mid='" + MCode + "'"; if ((int)SQLBase.ExecuteScalar(sql) > 0) { sql = "update TaskOrder set state=-1 where Mid='" + MCode + "'"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { return(false); } } sql = "select count(*) from ConsumptionInfo where YYCode ='" + YYCode + "'"; if ((int)SQLBase.ExecuteScalar(sql) > 0) { sql = "select sum(Amount) from ConsumptionInfo where type=0 and YYCode ='" + YYCode + "'"; double Amount = Convert.ToDouble(SQLBase.ExecuteScalar(sql)); sql = "select a.ClienName from ClientPayInfo a left join MandateInfo b on a.ClienName= b.ClienName where YYCode ='" + YYCode + "'"; DataTable dt = SQLBase.FillTable(sql); if (dt.Rows.Count > 0) { sql = "update ClientPayInfo set Money = Money+" + Amount + " where ClienName = '" + dt.Rows[0]["ClienName"].ToString() + "'"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { return(false); } } else { sql = "select ClienName from MandateInfo where yycode='" + YYCode + "'"; DataTable dt2 = SQLBase.FillTable(sql); sql = "insert into ClientPayInfo(ClienName,Money) values('" + dt2.Rows[0]["ClienName"] + "'," + Amount + ")"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { return(false); } } sql = "update ConsumptionInfo set type=2 where type=0 and YYCode ='" + YYCode + "'"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { return(false); } } if (!insertLog(YYCode, "撤销委托单")) { return(false); } return(true); } return(false); }
public static bool UpdateYYCode(string YYCode) { string YYMMDD = YYCode.Substring(1, 8); string sql = "select count(*) from TK_ConfingIDRecord where type='mandate' and OneWord='L' "; int count = (int)SQLBase.ExecuteScalar(sql); if (count > 0) { sql = "update TK_ConfingIDRecord set MaxValue =" + YYCode.Substring(9, 3) + ", YMD ='" + YYMMDD + "' where type='mandate' and OneWord='L'"; } else { sql = "insert into TK_ConfingIDRecord(YMD, OneWord, MaxValue, Type) values ('" + YYMMDD + "','L'," + YYCode.Substring(9, 3) + ",'mandate')"; } return(SQLBase.ExecuteNonQuery(sql) > 0); }
public static bool UpdateOId(string OId) { string YYMMDD = OId.Substring(2, 8); string sql = "select count(*) from TK_ConfingIDRecord where type='Operation' and OneWord='FX' "; int count = (int)SQLBase.ExecuteScalar(sql); if (count > 0) { sql = "update TK_ConfingIDRecord set MaxValue =" + OId.Substring(10, 2) + ", YMD ='" + YYMMDD + "' where type='Operation' and OneWord='FX'"; } else { sql = "insert into TK_ConfingIDRecord(YMD, OneWord, MaxValue, Type) values ('" + YYMMDD + "','FX'," + OId.Substring(10, 2) + ",'Operation')"; } return(SQLBase.ExecuteNonQuery(sql) > 0); }
public static bool SavePayInfo(PayInfo payInfo, List <ConsumptionInfo> list, double yk, ref string err) { if (payInfo != null) { string paySql = GSqlSentence.GetInsertInfoByD <PayInfo>(payInfo, "PayInfo"); if (SQLBase.ExecuteNonQuery(paySql) <= 0) { err = "缴费信息添加失败"; return(false); } if (!UpdatePayId(payInfo.PayId)) { err = "缴费单号更新失败"; return(false); } } string conSql = GSqlSentence.GetInsertByList <ConsumptionInfo>(list, "ConsumptionInfo"); if (SQLBase.ExecuteNonQuery(conSql) <= 0) { err = "消费信息添加失败"; return(false); } if (yk > 0) { string sql = "update ClientPayInfo set Money = Money-" + yk + " where ClienName ='" + payInfo.PayCompany + "'"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { err = "更新余额失败"; return(false); } } string YYCode = ""; string Content = ""; for (int i = 0; i < list.Count; i++) { YYCode += list[i].YYCode + ","; Content += "缴费,缴费状态为" + list[i].Type + ","; } if (!insertLog(YYCode.Substring(0, YYCode.Length - 1), Content.Substring(0, Content.Length - 1))) { err = "更新日志失败"; return(false); } return(true); }
public static bool RestPwd(string userId, ref string err) { string sql = ""; sql = "update UM_UserSystem set LoginPwd = '1',Validate = '" + DateTime.Now.AddDays(1) + "' where UserId = " + userId; if (SQLBase.ExecuteNonQuery(sql, AccountCnn) > 0) { sql = "update UM_UserNew set UserPwd = '1' where UserId = " + userId; SQLBase.ExecuteNonQuery(sql, AccountCnn); err = "保存成功!"; return(true); } else { err = "保存失败!"; return(false); } }
public static bool SaveProductPlan(tk_Product_Plan record, List <tk_Product_PlanDetail> delist, ref string strErr) { int count = 0; try { string strInsert = GSqlSentence.GetInsertInfoByD <tk_Product_Plan>(record, "[BGOI_Produce].[dbo].tk_Product_Plan"); if (strInsert != "") { count = SQLBase.ExecuteNonQuery(strInsert, "MainProduce"); } if (count <= 0) { strErr = "计划单保存失败!"; return(false); } string strInsertList = ""; if (delist.Count > 0) { strInsertList = GSqlSentence.GetInsertByList <tk_Product_PlanDetail>(delist, "tk_Product_PlanDetail"); if (strInsertList != "") { count = SQLBase.ExecuteNonQuery(strInsertList, "MainProduce"); } } if (count > 0) { return(true); } else { return(false); } } catch (Exception ex) { strErr = ex.Message; return(false); } }
public static bool UpdatePayInfo(PayInfo payInfo, string YYCode, ref string err) { string sql = "select PayType from PayInfo where payId='" + payInfo.PayId + "'"; string pType = SQLBase.ExecuteScalar(sql).ToString(); string paySql = GSqlSentence.GetUpdateInfoByD <PayInfo>(payInfo, "PayId", "PayInfo"); if (SQLBase.ExecuteNonQuery(paySql) <= 0) { err = "缴费信息更新失败"; return(false); } sql = "update ConsumptionInfo set type=" + payInfo.PayType + " where PayId='" + payInfo.PayId + "'"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { err = "消费信息更新失败"; return(false); } if (pType != payInfo.PayType && payInfo.PayType == "2") { sql = "select ClienName from ClientPayInfo where ClienName = '" + payInfo.PayCompany + "'"; DataTable dt = SQLBase.FillTable(sql); if (dt.Rows.Count > 0) { sql = "update ClientPayInfo set Money = Money+" + payInfo.PayMoney + " where ClienName = '" + payInfo.PayCompany + "'"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { return(false); } } else { sql = "insert into ClientPayInfo(ClienName,Money) values('" + payInfo.PayCompany + "'," + payInfo.PayMoney + ")"; if (SQLBase.ExecuteNonQuery(sql) <= 0) { return(false); } } } return(true); }
public static bool UpdatePayId(string PayId) { try { string YYMMDD = PayId.Substring(0, 8); string sql = "select count(*) from TK_ConfingIDRecord where type='Pay' and OneWord='JF'"; int count = (int)SQLBase.ExecuteScalar(sql); if (count > 0) { sql = "update TK_ConfingIDRecord set MaxValue =" + PayId.Substring(10, 3) + ", YMD ='" + YYMMDD + "' where type='Pay' and OneWord='JF'"; } else { sql = "insert into TK_ConfingIDRecord(YMD, OneWord, MaxValue, Type) values ('" + YYMMDD + "','JF'," + PayId.Substring(10, 3) + ",'Pay')"; } return(SQLBase.ExecuteNonQuery(sql) > 0); } catch (Exception) { return(false); } }
public static bool insertLog(string YYCode, string content) { tk_Log log = null; List <tk_Log> list = new List <tk_Log>(); string[] YYCodes = YYCode.Split(','); string[] Contents = content.Split(','); for (int i = 0; i < YYCodes.Length; i++) { log = new tk_Log() { ID = Convert.ToDecimal(DateTime.Now.ToString("yyyyMMddHHmmss")), LogTime = DateTime.Now, YYCode = YYCodes[i], Content = Contents[i], Actor = GAccount.GetAccountInfo().UserName, Unit = GAccount.GetAccountInfo().UnitName }; list.Add(log); } string logSql = GSqlSentence.GetInsertByList <tk_Log>(list, "tk_Log"); return(SQLBase.ExecuteNonQuery(logSql) > 0); }
public static bool SaveOperationAnalysis(OperationAnalysis oa, List <OperationTask> list, ref string err) { string sql = GSqlSentence.GetInsertInfo <OperationAnalysis>(oa); if (SQLBase.ExecuteNonQuery(sql) > 0) { sql = GSqlSentence.GetInsertByList <OperationTask>(list, "OperationTask"); if (SQLBase.ExecuteNonQuery(sql) > 0) { if (UpdateOId(oa.OId)) { return(true); } err = "编号更新失败"; return(false); } err = "任务信息保存失败"; return(false); } err = "保存失败"; return(false); }
public static bool UpdatePwd(string oldPwd, string newPwd, int userId, ref string err) { string sql = "select count(*) from UM_UserNew where UserId=" + userId + " and UserPwd='" + oldPwd + "'"; int count = Convert.ToInt32(SQLBase.ExecuteScalar(sql, AccountCnn)); if (count <= 0) { err = "原密码错误!"; return(false); } sql = "update UM_UserSystem set LoginPwd = '" + newPwd + "',Validate = NULL where UserId = " + userId; if (SQLBase.ExecuteNonQuery(sql, AccountCnn) > 0) { sql = "update UM_UserNew set UserPwd = '" + newPwd + "' where UserId = " + userId; SQLBase.ExecuteNonQuery(sql, AccountCnn); err = "保存成功!"; return(true); } else { err = "保存失败!"; return(false); } }
public static bool SaveAccept(string YYCode, string MCode, string AcceptPeople, string type, ref string err) { string sql = "update MandateInfo set MCode='" + MCode + "',AcceptPeople='" + AcceptPeople + "',AcceptTime='" + DateTime.Now.ToString() + "',state=1 where YYCode='" + YYCode + "'"; if (SQLBase.ExecuteNonQuery(sql) > 0) { if (!UpdateMcode(type, MCode)) { err = "委托单号更新失败"; return(false); } //sql = "update sampleInfo set sampleCode='" + MCode + ".'+right('00',2-len(convert(varchar(2),serialNumber)))+convert(varchar(2),serialNumber) where YYCode='" + YYCode + "'"; sql = "select YYCode,Number,serialNumber from SampleInfo where YYCode ='" + YYCode + "' order by serialNumber"; DataTable dt = SQLBase.FillTable(sql); //未完 int number = 0; for (int i = 0; i < dt.Rows.Count; i++) { string sampleCode = ""; if ((int)dt.Rows[i]["Number"] > 1) { string strartStr = (number + 1).ToString(); string endStr = (number + (int)dt.Rows[i]["Number"]).ToString(); if (strartStr.Length < 2) { strartStr = "0" + strartStr; } if (endStr.Length < 2) { endStr = "0" + endStr; } sampleCode = MCode + "-" + strartStr + "-" + endStr; number = Convert.ToInt32(endStr); } else { if ((number + 1).ToString().Length > 2) { sampleCode = MCode + "-" + (number + 1); } else { string result = "00" + (number + 1); sampleCode = MCode + "-" + result.Substring(result.Length - 2, 2); } number += 1; } sql = "update sampleInfo set sampleCode='" + sampleCode + "' where YYCode='" + YYCode + "' and serialNumber=" + dt.Rows[i]["serialNumber"]; if (SQLBase.ExecuteNonQuery(sql) <= 0) { err = "样品编号更新失败"; return(false); } } sql = "insert into TaskOrder(MId,CreateTime,CreateUser,state) values('" + MCode + "','" + DateTime.Now.ToString() + "','" + GAccount.GetAccountInfo().UserName + "',9)"; if (SQLBase.ExecuteNonQuery(sql) > 0) { string content = "受理委托单并创建任务单"; if (!insertLog(YYCode, content)) { err = "日志更新失败"; return(false); } return(true); } else { err = "任务单创建失败"; return(false); } } err = "受理失败"; return(false); }
public static bool SaveUpdatePlan(tk_Product_Plan record, List <tk_Product_PlanDetail> delist, ref string strErr) { //SqlTransaction sqltra = con.BeginTransaction();//开始事务 try { string strUpdate = "update BGOI_Produce.dbo.tk_Product_Plan set Specifieddate=@Specifieddate,Plannedmonth=@Plannedmonth," + "Remarks=@Remarks,Formulation=@Formulation where JHID=@JHID"; SqlParameter[] param = { new SqlParameter("@Specifieddate", SqlDbType.DateTime), new SqlParameter("@Plannedmonth", SqlDbType.NVarChar), new SqlParameter("@Remarks", SqlDbType.NVarChar), new SqlParameter("@Formulation", SqlDbType.NVarChar), new SqlParameter("@JHID", SqlDbType.NVarChar) }; param[0].Value = Convert.ToDateTime(record.Specifieddate); param[1].Value = record.Plannedmonth; param[2].Value = record.Remarks == null ? "" : record.Remarks; param[3].Value = record.Formulation; param[4].Value = record.JHID; string InserNewOrdersHIS = "insert into BGOI_Produce.dbo.tk_Product_Plan_HIS (JHID,UnitID,Plannedyear,Plannedmonth,Specifieddate,Formulation,Remarks,State,Approvalstatus,CreateUser,CreateTime,Validate,NCreateTime,NCreateUser)" + "select JHID,UnitID,Plannedyear,Plannedmonth,Specifieddate,Formulation,Remarks,State,Approvalstatus,CreateUser,CreateTime,Validate,'" + DateTime.Now + "','" + GAccount.GetAccountInfo().UserName + "' from BGOI_Produce.dbo.tk_Product_Plan where JHID ='" + record.JHID + "'"; int count = 0; count = SQLBase.ExecuteNonQuery(InserNewOrdersHIS, "MainProduce"); if (count <= 0) { strErr = "历史记录更新失败"; return(false); } count = SQLBase.ExecuteNonQuery(strUpdate, param, "MainProduce"); if (count <= 0) { strErr = "计划信息更新失败"; return(false); } string strInsertDetailHIS = "insert into BGOI_Produce.dbo.tk_Product_PlanDetail_HIS(JHID,DID,PID,Name,Specifications,Finishedproduct,finishingproduct,Spareparts,notavailable,Total,plannumber,demandnumber,Remarks,CreateUser,CreateTime,Validate,NCreateUser,NCreateTime) select JHID,DID,PID,Name,Specifications,Finishedproduct,finishingproduct,Spareparts,notavailable,Total,plannumber,demandnumber,Remarks,CreateUser,CreateTime,Validate,'" + GAccount.GetAccountInfo().UserName + "','" + DateTime.Now + "'" + " from BGOI_Produce.dbo.tk_Product_PlanDetail where JHID='" + record.JHID + "'"; count = SQLBase.ExecuteNonQuery(strInsertDetailHIS, "MainProduce"); if (count < 0) { strErr = "历史记录更新失败"; return(false); } string strDeleteDetail = "delete tk_Product_PlanDetail where JHID='" + record.JHID + "'"; count = SQLBase.ExecuteNonQuery(strDeleteDetail, "MainProduce"); if (count < 0) { return(false); } if (delist.Count > 0) { string strUpdateList = GSqlSentence.GetInsertByList <tk_Product_PlanDetail>(delist, "tk_Product_PlanDetail"); count = SQLBase.ExecuteNonQuery(strUpdateList, "MainProduce"); if (count <= 0) { return(false); } } return(true); } catch (Exception ex) { strErr = ex.Message; //trans.Close(true); return(false); } }
public static int UpdatezhunchuApproval(string IsPass, string Opinion, string Remark, string PID, string webkey, string folderBack, string RelevanceID, ref string a_strErr) { int intInsertBas = 0; int intUpdateBas = 0; int intLog = 0; int intAllBas = 0; //string strstate = ""; //int intstate = 0; Acc_Account account = GAccount.GetAccountInfo(); string UserId = account.UserID.ToString(); string[] arr = folderBack.Split('/'); int state = 0; if (IsPass == "是") { state = 1; } else { state = -1; } //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/51/55/tk_PID/54/tk_UserLog //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/23/22/tk_PID/10/tk_UserLog //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/62/61/tk_PID/29/tk_UserLog 年度 //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/10/73/tk_PID/75/tk_UserLog 恢复供货 string strInsertBas = "update [" + arr[0] + "].." + arr[1] + " set ApprovalMan = '" + UserId + "',ApprovalTime = '" + DateTime.Now + "',IsPass = '******',Opinion = '" + Opinion + "'," + "Remark = '" + Remark + "',State = '" + state + "' where PID = '" + PID + "' and ApprovalPersons = '" + UserId + "'"; string strUpdateBas = ""; if (state == -1) { if (arr[2].IndexOf("..") > 0) { strUpdateBas = "update " + arr[2] + " set State = '" + arr[7] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[2].IndexOf("..") > 0 && arr[7] == "29") { strUpdateBas = "update " + arr[2] + " set nState = '" + arr[7] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[7] == "29") { strUpdateBas = "update " + arr[2] + " set nState = '" + arr[7] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } else { strUpdateBas = "update [" + arr[0] + "].." + arr[2] + " set State = '" + arr[7] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } } string strInsertLog = "insert into [" + arr[0] + "].." + arr[8] + " values ('" + RelevanceID + "','" + webkey + "审批操作','" + webkey + "审批操作成功','" + DateTime.Now + "','" + account.UserName + "','" + webkey + "审批')"; if (strInsertBas != "") { intInsertBas = SQLBase.ExecuteNonQuery(strInsertBas, CommandType.Text, null); } if (strUpdateBas != "") { intUpdateBas = SQLBase.ExecuteNonQuery(strUpdateBas, CommandType.Text, null); } if (strInsertLog != "") { intLog = SQLBase.ExecuteNonQuery(strInsertLog, "SupplyCnn"); } string str = "select ApprovalLevel,SUBSTRING(AppType,1,1) as Type,SUBSTRING(AppType,3,1) as num from [" + arr[0] + "].." + arr[1] + " where PID = '" + PID + "' and state = '0'"; DataTable dt = SQLBase.FillTable(str); string Type = ""; int num = 0; int bol = 0; int Hcount = 0; for (int i = 0; i < dt.Rows.Count; i++) { Type = dt.Rows[i]["Type"].ToString(); if (Type == "1") { bol = 1; break; } if (Type == "2") { bol = 1; break; } if (Type == "3") { num = Convert.ToInt16(dt.Rows[i]["num"]); string level = dt.Rows[i]["ApprovalLevel"].ToString(); string str1 = "select count(*) from [" + arr[0] + "].." + arr[1] + " where PID = '" + PID + "' and state = '1' and AppType = '3-" + num + "'"; DataTable dt2 = SQLBase.FillTable(str1); if (dt2.Rows.Count > 0) { Hcount = Convert.ToInt16(dt2.Rows[0][0]); } if (Hcount < num) { bol = 1; break; } } } //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/23/22/tk_PID/10/tk_UserLog 准出停止 //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/26/25/tk_PID/10/tk_UserLog 准出暂停 //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/29/28/tk_PID/10/tk_UserLog 准出淘汰 //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/62/61/tk_PID/29/tk_UserLog 年度 //BGOI_BasMan/tk_SApproval/tk_SupplierBas/SID/10/73/tk_PID/75/tk_UserLog 恢复供货 string strAllBas = ""; if (bol == 0 && state != -1) { if (arr[2].IndexOf("..") > 0 && arr[4] == "23") { strAllBas = "update " + arr[2] + " set State = '" + arr[4] + "',wstate='3' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[2].IndexOf("..") > 0 && arr[4] == "26") { strAllBas = "update " + arr[2] + " set State = '" + arr[4] + "',wstate='2' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[2].IndexOf("..") > 0 && arr[4] == "29") { strAllBas = "update " + arr[2] + " set State = '" + arr[4] + "',wstate='4' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[2].IndexOf("..") > 0 && arr[4] == "10") { strAllBas = "update " + arr[2] + " set State = '" + arr[4] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[2].IndexOf("..") > 0 && arr[4] == "4") { strAllBas = "update " + arr[2] + " set State = '" + arr[4] + "',wstate='0' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[2].IndexOf("..") > 0 && arr[4] == "62") { strAllBas = "update " + arr[2] + " set nState = '" + arr[4] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[4] == "23") { strAllBas = "update [" + arr[0] + "].." + arr[2] + " set State = '" + arr[4] + "',wstate='3' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[4] == "26") { strAllBas = "update [" + arr[0] + "].." + arr[2] + " set State = '" + arr[4] + "',wstate='2' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[4] == "29") { strAllBas = "update [" + arr[0] + "].." + arr[2] + " set State = '" + arr[4] + "',wstate='4' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[4] == "10") { strAllBas = "update [" + arr[0] + "].." + arr[2] + " set State = '" + arr[4] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } else if (arr[4] == "4") { strAllBas = "update [" + arr[0] + "].." + arr[2] + " set State = '" + arr[4] + "',wstate='0' where " + arr[3] + " = '" + RelevanceID + "'"; } else { strAllBas = "update [" + arr[0] + "].." + arr[2] + " set nState = '" + arr[4] + "',wstate='1' where " + arr[3] + " = '" + RelevanceID + "'"; } } else { strAllBas = ""; } if (strAllBas != "") { intAllBas = SQLBase.ExecuteNonQuery(strAllBas, "SupplyCnn"); } return(intInsertBas + intUpdateBas); }
public static bool UpdateMandate(MandateInfo mandate, List <SampleInfo> sampleList, ref string err) { string MandateSql = GSqlSentence.GetUpdateInfoByD(mandate, "YYCode", "MandateInfo"); if (mandate.MCode != "" && mandate.MCode != null) { string MCode = mandate.MCode; int number = 0; for (int i = 0; i < sampleList.Count; i++) { string sampleCode = ""; if (sampleList[i].Number > 1) { string strartStr = (number + 1).ToString(); string endStr = (number + sampleList[i].Number).ToString(); if (strartStr.Length < 2) { strartStr = "0" + strartStr; } if (endStr.Length < 2) { endStr = "0" + endStr; } sampleCode = MCode + "-" + strartStr + "-" + endStr; number = Convert.ToInt32(endStr); } else { if ((number + 1).ToString().Length > 2) { sampleCode = MCode + "-" + (number + 1); } else { string result = "00" + (number + 1); sampleCode = MCode + "-" + result.Substring(result.Length - 2, 2); } number += 1; } sampleList[i].SampleCode = sampleCode; } } string sampleSql = GSqlSentence.GetInsertByList <SampleInfo>(sampleList, "SampleInfo"); List <TestItem> testItemList = GetItemIDs(mandate.TestingItems, mandate.YYCode); string testItemSql = GSqlSentence.GetInsertByList <TestItem>(testItemList, "TestItem"); string sql = ""; if (SQLBase.ExecuteNonQuery(MandateSql) > 0) { sql = "delete SampleInfo where YYCode='" + mandate.YYCode + "'"; if (SQLBase.ExecuteNonQuery(sql) >= 0) { if (sampleList.Count > 0) { if (SQLBase.ExecuteNonQuery(sampleSql) <= 0) { err = "样品信息添加失败"; return(false); } } } sql = "delect TestItem where YYCode='" + mandate.YYCode + "'"; if (SQLBase.ExecuteNonQuery(sql) >= 0) { if (testItemList.Count > 0) { if (SQLBase.ExecuteNonQuery(testItemSql) <= 0) { err = "检测项目添加失败"; return(false); } } } string content = "修改委托单信息"; if (!insertLog(mandate.YYCode, content)) { err = "更新日志失败"; return(false); } return(true); } err = "委托信息更新失败"; return(false); }