Esempio n. 1
0
 /// <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();
         }
     }
 }
Esempio n. 2
0
        /// <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);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="user"></param>
        public int CreatAcount(User user)
        {
            int num = 0;

            using (StoreAccess access = new StoreAccess(true))
            {
                try
                {
                    access.Open();
                    access.BeginTransaction();
                    num = access.Insert <User>(user);
                    access.Commit();
                }
                catch (Exception ex)
                {
                    access.RollBack();
                    access.Close();
                }
            }
            return(num);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        /// <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);
        }