Ejemplo n.º 1
0
        //盤點
        public String DeviceInventoryIntoDB(String sStaffID, String sZoneNo, String sZoneSN, String sFuncCode, List <String> InfoList, String sCopper)
        {
            //取得松電工的支號
            String sProd = (sCopper.Equals("4")) ? InfoList[3].ToString() : InfoList[0].ToString();
            ////二維條碼支號為InfoList[0],一維條碼支號為InfoList[1]
            //String sProd = (InfoList.Count == 12) ? InfoList[0].ToString() : InfoList[1].ToString();

            String sResult = "";

            try
            {
                //表示盤點資料與庫存資料相符
                if (db.Inventory.Where(i => i.Prod == sProd).Count() > 0)
                {
                    //如果地點不同,代表地點條碼掃瞄有誤
                    //if (db.Inventory.Where(i => i.Prod == sProd && i.ZoneID == sZoneID).Count() == 0)
                    //{
                    //    sResult = "此銅箔的庫位資料比對不符!!";
                    //}
                    //else
                    //{
                    //取得ZoneID
                    //String sZoneID;
                    var data = db.Inventory.Where(i => i.Prod == sProd).FirstOrDefault();

                    sResult = sProd + ",庫存與實際盤點資料相符!!";
                    //將盤點資料,寫入tempinventory資料表
                    //且要此筆資料尚未盤點過,表示尚未寫入tempinventory
                    if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                    {
                        InsertTempInventory(InfoList, data.ZoneID, sStaffID, sFuncCode, sZoneSN, sCopper);
                    }
                    //}
                }
                else
                {
                    //取得ZoneID
                    //String sZoneID = GetZoneID(sZoneNo);
                    var Info = new ImportInventory();
                    //二維條碼
                    if (InfoList.Count == 12 && sCopper.Equals("1"))
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[7].Substring(0, 4)),
                                                  int.Parse(InfoList[7].Substring(4, 2)),
                                                  int.Parse(InfoList[7].Substring(6, 2)));
                        Info = new ImportInventory
                        {
                            Thickness       = InfoList[2],
                            Widt            = InfoList[3],
                            Type            = InfoList[10],
                            Prod            = InfoList[0],
                            Leng            = int.Parse((InfoList[4])),
                            NewWeight       = float.Parse(InfoList[5]),
                            SrnmType        = sFuncCode,
                            ProductDate     = dt,
                            TransactionDate = DateTime.Now,
                            StaffID         = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            Splice = InfoList[6],
                            Ptno   = InfoList[11],
                            //CustomerNO = "b",
                            PackNo     = InfoList[9],
                            Thickness2 = InfoList[1]
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //松電工
                    else if (InfoList.Count == 12 && sCopper.Equals("4"))
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[9].Substring(0, 4)),
                                                  int.Parse(InfoList[9].Substring(4, 2)),
                                                  int.Parse(InfoList[9].Substring(6, 2)));
                        Info = new ImportInventory
                        {
                            Thickness       = InfoList[5],
                            Widt            = InfoList[6],
                            Type            = InfoList[11],
                            Prod            = InfoList[3],
                            Leng            = int.Parse((InfoList[7])),
                            NewWeight       = float.Parse(InfoList[2]),
                            SrnmType        = sFuncCode,
                            ProductDate     = dt,
                            TransactionDate = DateTime.Now,
                            StaffID         = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            Splice = InfoList[8],
                            Ptno   = InfoList[0],
                            //CustomerNO = "b",
                            PackNo     = InfoList[10],
                            Thickness2 = InfoList[4]
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //日系一般
                    else if (InfoList.Count == 9 && sCopper.Equals("5"))
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[5].Substring(0, 2)) + 2000,
                                                  int.Parse(InfoList[5].Substring(2, 2)),
                                                  int.Parse(InfoList[5].Substring(4, 2)));
                        Info = new ImportInventory
                        {
                            //Thickness = InfoList[1],日系一般沒有此項資料
                            Widt            = InfoList[2],
                            Type            = InfoList[6],
                            Prod            = InfoList[0],
                            Leng            = int.Parse((InfoList[3])),
                            NewWeight       = float.Parse(InfoList[4]),
                            SrnmType        = sFuncCode,
                            ProductDate     = dt,
                            TransactionDate = DateTime.Now,
                            StaffID         = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            //Splice = InfoList[5],沒有接頭數
                            //CustomerNO = sCustomer,
                            //CtlNo1 = sCtlNo1,
                            //CtlNo2 = sCtlNo2,
                            Thickness2 = InfoList[1],
                            Ptno       = InfoList[7]
                                         //特殊記項為,InfoList[8],尚無用到
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //一維條碼
                    else if (InfoList.Count == 9)
                    //else
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[6].Substring(0, 2)) + 2000,
                                                  int.Parse(InfoList[6].Substring(2, 2)),
                                                  int.Parse(InfoList[6].Substring(4, 2)));
                        Info = new ImportInventory
                        {
                            //Thickness = InfoList[2],
                            //Widt = InfoList[3],
                            //Type = InfoList[9],
                            //Prod = InfoList[1],
                            //Leng = int.Parse((InfoList[4])),
                            //NewWeight = float.Parse(InfoList[5]),
                            //SrnmType = sFuncCode,
                            //ProductDate = dt,
                            //TransactionDate = DateTime.Now,
                            //StaffID = sStaffID,
                            //ZoneID = sZoneID,
                            //ZoneSN = sZoneSN,
                            //Splice = InfoList[6],
                            ////Ptno = InfoList[11]

                            Thickness       = InfoList[1],
                            Widt            = InfoList[2],
                            Type            = InfoList[8],
                            Prod            = InfoList[0],
                            Leng            = int.Parse((InfoList[3])),
                            NewWeight       = float.Parse(InfoList[4]),
                            SrnmType        = sFuncCode,
                            ProductDate     = dt,
                            TransactionDate = DateTime.Now,
                            StaffID         = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            Splice = InfoList[5],
                            //CustomerNO = "b"
                            //Ptno = InfoList[11]
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //將差異資料寫入ImportInventory資料表
                    //且要此筆資料尚未盤點過
                    if (db.ImportInventory.Where(i => i.Prod == sProd).Count() == 0)
                    {
                        db.ImportInventory.Add(Info);
                        db.SaveChanges();
                        sResult = "true";
                    }
                    else
                    {
                        sResult = sProd + ",已盤點過,請將此筆資料匯入庫存資料庫!!";
                    }
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                sResult = ex.ToString();
            }
            return(sResult);
        }
Ejemplo n.º 2
0
        //盤點
        public String DeviceInventoryIntoDB(String sStaffID, String sZoneNo, String sZoneSN, String sFuncCode, List<String> InfoList, String sCopper)
        {
            //取得松電工的支號
            String sProd = (sCopper.Equals("4")) ? InfoList[3].ToString() : InfoList[0].ToString();
            ////二維條碼支號為InfoList[0],一維條碼支號為InfoList[1]
            //String sProd = (InfoList.Count == 12) ? InfoList[0].ToString() : InfoList[1].ToString();

            String sResult = "";
            try
            {
                //表示盤點資料與庫存資料相符
                if (db.Inventory.Where(i => i.Prod == sProd).Count() > 0)
                {
                    //如果地點不同,代表地點條碼掃瞄有誤
                    //if (db.Inventory.Where(i => i.Prod == sProd && i.ZoneID == sZoneID).Count() == 0)
                    //{
                    //    sResult = "此銅箔的庫位資料比對不符!!";
                    //}
                    //else
                    //{
                    //取得ZoneID
                    //String sZoneID;
                    var data = db.Inventory.Where(i => i.Prod == sProd).FirstOrDefault();

                        sResult = sProd + ",庫存與實際盤點資料相符!!";
                        //將盤點資料,寫入tempinventory資料表
                        //且要此筆資料尚未盤點過,表示尚未寫入tempinventory
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, data.ZoneID, sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    //}
                }
                else
                {
                    //取得ZoneID
                    //String sZoneID = GetZoneID(sZoneNo);
                    var Info = new ImportInventory();
                    //二維條碼
                    if (InfoList.Count == 12 && sCopper.Equals("1"))
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[7].Substring(0, 4)),
                                                  int.Parse(InfoList[7].Substring(4, 2)),
                                                  int.Parse(InfoList[7].Substring(6, 2)));
                        Info = new ImportInventory
                        {
                            Thickness = InfoList[2],
                            Widt = InfoList[3],
                            Type = InfoList[10],
                            Prod = InfoList[0],
                            Leng = int.Parse((InfoList[4])),
                            NewWeight = float.Parse(InfoList[5]),
                            SrnmType = sFuncCode,
                            ProductDate = dt,
                            TransactionDate = DateTime.Now,
                            StaffID = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            Splice = InfoList[6],
                            Ptno = InfoList[11],
                            //CustomerNO = "b",
                            PackNo = InfoList[9],
                            Thickness2 = InfoList[1]
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //松電工
                    else if (InfoList.Count == 12 && sCopper.Equals("4"))
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[9].Substring(0, 4)),
                                                  int.Parse(InfoList[9].Substring(4, 2)),
                                                  int.Parse(InfoList[9].Substring(6, 2)));
                        Info = new ImportInventory
                        {
                            Thickness = InfoList[5],
                            Widt = InfoList[6],
                            Type = InfoList[11],
                            Prod = InfoList[3],
                            Leng = int.Parse((InfoList[7])),
                            NewWeight = float.Parse(InfoList[2]),
                            SrnmType = sFuncCode,
                            ProductDate = dt,
                            TransactionDate = DateTime.Now,
                            StaffID = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            Splice = InfoList[8],
                            Ptno = InfoList[0],
                            //CustomerNO = "b",
                            PackNo = InfoList[10],
                            Thickness2 = InfoList[4]
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //日系一般
                    else if (InfoList.Count == 9 && sCopper.Equals("5"))
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[5].Substring(0, 2)) + 2000,
                                                  int.Parse(InfoList[5].Substring(2, 2)),
                                                  int.Parse(InfoList[5].Substring(4, 2)));
                        Info = new ImportInventory
                        {
                            //Thickness = InfoList[1],日系一般沒有此項資料
                            Widt = InfoList[2],
                            Type = InfoList[6],
                            Prod = InfoList[0],
                            Leng = int.Parse((InfoList[3])),
                            NewWeight = float.Parse(InfoList[4]),
                            SrnmType = sFuncCode,
                            ProductDate = dt,
                            TransactionDate = DateTime.Now,
                            StaffID = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            //Splice = InfoList[5],沒有接頭數
                            //CustomerNO = sCustomer,
                            //CtlNo1 = sCtlNo1,
                            //CtlNo2 = sCtlNo2,
                            Thickness2 = InfoList[1],
                            Ptno = InfoList[7]
                            //特殊記項為,InfoList[8],尚無用到
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //一維條碼
                    else if (InfoList.Count == 9)
                    //else
                    {
                        //設定日期格式
                        DateTime dt = SetDateTime(int.Parse(InfoList[6].Substring(0, 2)) + 2000,
                                                  int.Parse(InfoList[6].Substring(2, 2)),
                                                  int.Parse(InfoList[6].Substring(4, 2)));
                        Info = new ImportInventory
                        {
                            //Thickness = InfoList[2],
                            //Widt = InfoList[3],
                            //Type = InfoList[9],
                            //Prod = InfoList[1],
                            //Leng = int.Parse((InfoList[4])),
                            //NewWeight = float.Parse(InfoList[5]),
                            //SrnmType = sFuncCode,
                            //ProductDate = dt,
                            //TransactionDate = DateTime.Now,
                            //StaffID = sStaffID,
                            //ZoneID = sZoneID,
                            //ZoneSN = sZoneSN,
                            //Splice = InfoList[6],
                            ////Ptno = InfoList[11]

                            Thickness = InfoList[1],
                            Widt = InfoList[2],
                            Type = InfoList[8],
                            Prod = InfoList[0],
                            Leng = int.Parse((InfoList[3])),
                            NewWeight = float.Parse(InfoList[4]),
                            SrnmType = sFuncCode,
                            ProductDate = dt,
                            TransactionDate = DateTime.Now,
                            StaffID = sStaffID,
                            //ZoneID = sZoneID,
                            ZoneSN = sZoneSN,
                            Splice = InfoList[5],
                            //CustomerNO = "b"
                            //Ptno = InfoList[11]
                        };
                        //將盤點資料寫入tempinventory資料表
                        //且要此筆資料尚未盤點過
                        if (db.TempInventory.Where(i => i.Prod == sProd).Count() == 0)
                        {
                            InsertTempInventory(InfoList, "", sStaffID, sFuncCode, sZoneSN, sCopper);
                        }
                    }
                    //將差異資料寫入ImportInventory資料表
                    //且要此筆資料尚未盤點過
                    if (db.ImportInventory.Where(i => i.Prod == sProd).Count() == 0)
                    {
                        db.ImportInventory.Add(Info);
                        db.SaveChanges();
                        sResult = "true";
                    }
                    else
                    {
                        sResult = sProd + ",已盤點過,請將此筆資料匯入庫存資料庫!!";
                    }

                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                sResult = ex.ToString();
            }
            return sResult;
        }