/// <summary> /// 必须按照格式【什么人,干什么事,什么类型】 /// </summary> /// <param name="log"></param> public static void RecordLog(string logs1, string logs2, string logs3) { using (StoreAccess access = new StoreAccess(true)) { try { string strSQL = access.CommandFormate("INSERT INTO [Table_Log] ([Logtime] ,[LogUser],[Remark],[Type]) VALUES ({0}Logtime,{0}LogUser,{0}Remark,{0}Type)"); access.Open(); access.BeginTransaction(); access.Insert(strSQL, parmater => { parmater.Add(parmater.CreateParameter("Logtime", DateTime.Now)); parmater.Add(parmater.CreateParameter("LogUser", logs1)); parmater.Add(parmater.CreateParameter("Remark", logs2)); parmater.Add(parmater.CreateParameter("Type", logs3)); }); access.Commit(); } catch (DbException db) { access.RollBack(); access.Close(); } } }
public static LoginResult Login(string account, string password, out User loginUser) { loginUser = null; using (StoreAccess access = new StoreAccess()) { try { User user = access.Login(account, password); if (user == null) { return(LoginResult.ValidateError); } else { loginUser = user; return(LoginResult.Success); } } catch (DbException err) { return(LoginResult.NetError); } finally { access.Close(); } } }
/// <summary> /// 删除用户怇 /// </summary> /// <param name="acount"></param> /// <param name="type">1:条件删除 2:全部删除</param> /// <returns></returns> public int DeleteAcount(object acount, int type) { int num = 0; string sql = string.Empty; if (type == 1) { sql = string.Format("DELETE FROM [Table_User] WHERE [Id] = {0}", acount); } else { sql = "DELETE FROM [Table_User]"; } using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); num = access.Delete(sql); access.Commit(); } catch (Exception ex) { access.RollBack(); access.Close(); } } return(num); }
/// <summary> /// 仓库结构修改 /// </summary> public int StoreStructUpdate(params string[] store) { int count = 0; using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); string strSQL = access.CommandFormate("UPDATE [dbo].[Table_Warehouse] SET [StoreStaus] = {0}StoreStaus,[Type]={0}Type WHERE [Row]={0}Row AND [Column]={0}Column AND [Layer]={0}Layer"); count = access.Update(strSQL, (parmarter) => { parmarter.Add(parmarter.CreateParameter("StoreStaus", store[0])); parmarter.Add(parmarter.CreateParameter("Type", store[1])); parmarter.Add(parmarter.CreateParameter("Row", store[2])); parmarter.Add(parmarter.CreateParameter("Column", store[3])); parmarter.Add(parmarter.CreateParameter("Layer", store[4])); }); access.Commit(); } catch (DbException ex) { LogBusiness.RecordLog("管理员", ex.Message, "修改仓库结构数据操作异常"); access.RollBack(); access.Close(); } } return(count); }
/// <summary> /// 保存到货数据 /// </summary> /// <param name="invoice"></param> public int SaveDataToCaeche(List <InvoiceVerify> invoice) { int num = 0; using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); for (int i = 0; i < invoice.Count; i++) { num += access.Insert(invoice[i]); //string strSQL = access.CommandFormate("INSERT INTO [Table_InvoiceVerify] ([InvoiceNumber],[SupplierCode],[Result],[MaterialNumber],[MaterialName],[Count],[Batch],[Barcode],[Time],[Iquantity]) VALUES ({0}InvoiceNumber,{0}SupplierCode,{0}Result,{0}MaterialNumber,{0}MaterialName,{0}Count,{0}Batch,{0}Barcode,{0}Time,{0}Iquantity)"); //access.Insert(strSQL, paramater => //{ // paramater.Add(paramater.CreateParameter("Barcode", invoice[i].Barcode)); // paramater.Add(paramater.CreateParameter("InvoiceNumber", invoice[i].InvoiceNumber)); // paramater.Add(paramater.CreateParameter("SupplierCode", invoice[i].SupplierCode)); // paramater.Add(paramater.CreateParameter("Result", invoice[i].Result)); // paramater.Add(paramater.CreateParameter("MaterialNumber", invoice[i].MaterialNumber)); // paramater.Add(paramater.CreateParameter("MaterialName", invoice[i].MaterialName)); // paramater.Add(paramater.CreateParameter("Count", invoice[i].Count)); // paramater.Add(paramater.CreateParameter("Batch", invoice[i].Batch)); // paramater.Add(paramater.CreateParameter("Time", invoice[i].Time)); // paramater.Add(paramater.CreateParameter("Iquantity", invoice[i].Iquantity)); //}); } access.Commit(); } catch (DbException ex) { LogBusiness.RecordLog(userAcount, "保存到货数据异常" + ex.Message, "保存到货数据"); access.RollBack(); access.Close(); MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Information); //throw; } return(num); } }
/// <summary> /// 修改 /// </summary> /// <param name="user"></param> /// <returns></returns> public int ResizeAcount(User user) { int num = 0; using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); num = access.Update <User>(user); access.Commit(); } catch (Exception ex) { access.RollBack(); access.Close(); } } return(num); }
public int SaveMessage(Semi_finishedProducts product) { int num = 0; using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); num = access.Insert(product); access.Commit(); } catch (DbException ex) { access.Close(); access.RollBack(); MessageBox.Show(ex.Message, "错误"); } } return(num); }
/// <summary> /// 补充物料信息 /// </summary> public int AddMaterialForLining(MaterialSupplement material) { int num = 0; using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); num = access.Insert <MaterialSupplement>(material); access.Commit(); } catch (DbException ex) { LogBusiness.RecordLog(userAcount, "录入补充物料异常" + ex.Message, "录入补充到货数据"); access.RollBack(); access.Close(); } } return(num); }
public int SaveConcession(CooperativeDecision decision) { int num = 0; using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); num = access.Insert(decision); access.Commit(); } catch (DbException db) { access.RollBack(); access.Close(); LogBusiness.RecordLog(name, db.Message + "异常", "保存让步接收结果"); MessageBox.Show("出错" + db.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } return(num); }
public int SaveTestData(VerifyRecode recode) { int num = 0; using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); num = access.Insert(recode); access.Commit(); } catch (Exception ex) { access.RollBack(); access.Close(); LogBusiness.RecordLog(name, ex.Message + "异常", "保存检测结果"); MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(num); }
/// <summary> /// 创建仓库 /// </summary> /// <param name="starStoreUnit">起始位置</param> /// <param name="endStoreUnit">终止位置</param> /// <param name="type">仓库类型</param> /// <returns>创建成功与否</returns> public bool CreatStroe(string starStoreUnit, string endStoreUnit, int type) { bool result = false; string[] unitStar = starStoreUnit.Split('-'); string[] unitEnd = endStoreUnit.Split('-'); int rowStar = Convert.ToInt16(unitStar[0]); int columnStar = (int)Convert.ToChar(unitStar[1]) - 64; int layerStar = Convert.ToInt16(unitStar[2]); int rowEnd = Convert.ToInt16(unitEnd[0]); int columnEnd = (int)Convert.ToChar(unitEnd[1]) - 64; int layerEnd = Convert.ToInt16(unitEnd[2]); if (rowStar > rowEnd || columnStar > columnEnd || layerStar > layerEnd) { MessageBox.Show("所填写的信息不正确,请重新填写"); return(false); } string[] store = new string[(rowEnd - rowStar + 1) * (columnEnd - columnStar + 1) * (layerEnd - layerStar + 1)]; //if (rowStar == 1 && columnStar == 1 && layerStar == 1) //{ // for (int i = 0; i < rowEnd; i++) // { // for (int j = 0; j < columnEnd; j++) // { // for (int k = 0; k < layerEnd; k++) // { // store[i * columnEnd * layerEnd + j * layerEnd + k] = string.Format("{0}-{1}-{2}", i + 1, Convert.ToChar(j + 65), k + 1); // } // } // } //} //else for (int i = 0; i < rowEnd - rowStar + 1; i++) { for (int j = 0; j < columnEnd - columnStar + 1; j++) { for (int k = 0; k < layerEnd - layerStar + 1; k++) { store[i * (columnEnd - columnStar + 1) * layerEnd + j * (layerEnd - layerStar + 1) + k] = string.Format("{0}-{1}-{2}", rowStar + i, Convert.ToChar(columnStar + j + 64), layerStar + k); } } } using (StoreAccess access = new StoreAccess(true)) { try { access.Open(); access.BeginTransaction(); for (int i = 0; i < store.Length; i++) { string[] storeParameter = store[i].Split('-'); string sql = access.CommandFormate("INSERT INTO [dbo].[Table_Warehouse]([Row],[Column],[Layer],[StoreStaus],[MaxCount],[Status],[Type]) VALUES({0}Row,{0}Column,{0}Layer,{0}StoreStaus,{0}MaxCount,{0}Status,{0}Type)"); access.Insert(sql, (parameter) => { parameter.Add(parameter.CreateParameter("Row", storeParameter[0])); parameter.Add(parameter.CreateParameter("Column", storeParameter[1])); parameter.Add(parameter.CreateParameter("Layer", storeParameter[2])); parameter.Add(parameter.CreateParameter("StoreStaus", 0)); parameter.Add(parameter.CreateParameter("MaxCount", 20000)); parameter.Add(parameter.CreateParameter("Status", 0)); parameter.Add(parameter.CreateParameter("Type", type)); }); } access.Commit(); result = true; } catch (DbException ex) { LogBusiness.RecordLog("管理员", ex.Message, "创建仓库结构数据操作异常"); access.RollBack(); access.Close(); } } return(result); }