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 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 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 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 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 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); }