Ejemplo n.º 1
0
        } //CheckLoc

        public string BackLogTOMasterData()
        {//โยกข้อมูลจาก Backlog ==> MasterData
         //  try
         //   {

            /*    var UpdateMSData = (from MS_B in DbFile.Master_Backlog.DefaultIfEmpty()
             *                      join MD_D1 in DbFile.Master_Data on MS_B.B_SO equals MD_D1.B_SO into MDs
             *                      from MD_D in MDs
             *                      select new
             *                      {
             *                          MS_B.B_SO,
             *                          D_SO = MD_D.B_SO
             *                      }).ToList();
             */
            //   var filteredSO = DbFile.Master_Backlog.Where(a => !DbFile.Master_Data.Select(b => b.B_SO).Contains(a.B_SO)).ToList();
            //var filteredSO = DbFile.Master_Backlog.ToList();

            /* var  filteredSO = (from a in DbFile.Master_Backlog
             *                 where !DbFile.Master_Data.Any(b => b.B_SO == a.B_SO)
             *                 select a).ToList();
             * // */
            List <Master_Backlog> MSB = DbFile.Master_Backlog.Where(a => !DbFile.Master_Data.Select(b => b.B_SO).Contains(a.B_SO)).ToList();
            var data1 = new Master_Data();

            foreach (var MSBs in MSB)
            {
                data1.B_SO           = MSBs.B_SO;
                data1.B_PO           = MSBs.B_PO;
                data1.B_Customer     = MSBs.B_Customer;
                data1.B_Material     = MSBs.B_Material;
                data1.B_Material_Des = MSBs.B_Material_Des;
                //   data1.Date_Create = MSBs.Date_Create;
                //   data1.Date_PFD = MSBs.Date_PFD;
                //  data1.Date_Delivery = MSBs.Date_Delivery;
                data1.B_Cutting_Length = MSBs.B_Cutting_Length;
                data1.B_Order_QTY      = MSBs.B_Order_QTY;
                data1.B_Order_Unit     = MSBs.B_Order_Unit;
                DbFile.Master_Data.Add(data1);
                DbFile.SaveChanges();
            }

            //  DbFile.Master_Data.Add();


            /*
             *              var Data = new List<Master_Data>();
             *              for (int i = 0; i < resultList.Count; i++)
             *              {
             *                  Data.Add(new Master_Data
             *                  {
             *
             *                  });
             *                  // Data.B_SO = resultList.,
             *                  //  Field_Value_EN = product.ListProductFields[i].Field_Value_EN
             *              };
             */
            // DbFile.Master_Data.Add(resultList);
            //  var SUM_OUT = dataOUT.Sum(a => a.Cal_QTY_Balance);
            // var result = DbFile.OTIF_TR_Cal.Where(a => a.Cal_SO.Equals(SO)).Where(b => b.Cal_Machine.Equals(MAC)).Where(c => c.Cal_Status.Equals("IN")).ToList();
            // result.ForEach(x => x.Cal_QTY_Balance = (x.Cal_QTY - SUM_OUT));
            // DbFile.SaveChanges();
            return(null);
            //  }
            //  catch { return null; }
        } //CheckLoc
Ejemplo n.º 2
0
        }// */

        private string SavePrint(int ID)//กวาดข้อมูล Backlog,Planner ไปลงตาราง Master Data
        {
            try
            {
                var MS_PL         = DbFile.Master_Planner.Where(y => y.ID.Equals(ID)).FirstOrDefault();
                var MS_BackLog    = DbFile.Master_Backlog.Where(y => y.B_SO == MS_PL.PL_SO).FirstOrDefault();
                var MS_Production = DbFile.Master_Production.Where(y => y.PD_SO == MS_PL.PL_SO).FirstOrDefault();
                var CheckMData    = DbFile.Master_Data.Where(y => y.PL_Tag == MS_PL.PL_Tag).FirstOrDefault();
                var MData         = new Master_Data();
                if (CheckMData != null) //Edit
                {
                    if (MS_BackLog != null)
                    {
                        CheckMData.B_SO           = MS_BackLog.B_SO;
                        CheckMData.B_SO           = MS_BackLog.B_SO;
                        CheckMData.B_Customer     = MS_BackLog.B_Customer;
                        CheckMData.B_Material     = MS_BackLog.B_Material;
                        CheckMData.B_Material_Des = MS_BackLog.B_Material_Des;
                        //  CheckMData.Date_Create = MS_BackLog.Date_Create;
                        //  CheckMData.Date_PFD = MS_BackLog.Date_PFD;
                        //  CheckMData.Date_Delivery = MS_BackLog.Date_Delivery;
                        CheckMData.B_Cutting_Length = MS_BackLog.B_Cutting_Length;
                        CheckMData.B_Order_QTY      = MS_BackLog.B_Order_QTY;
                        CheckMData.B_Order_Unit     = MS_BackLog.B_Order_Unit;
                    }
                    if (MS_Production != null)
                    {
                        CheckMData.B_Cutting_Length = MS_Production.PD_CuttingLength;
                    }

                    CheckMData.PL_Machine = MS_PL.PL_Machine;
                    CheckMData.PL_Process = MS_PL.PL_Process;
                    CheckMData.PL_Type    = MS_PL.PL_Type;
                    CheckMData.PL_Qty     = MS_PL.PL_Qty;
                    CheckMData.PL_Tag     = MS_PL.PL_Tag;
                    CheckMData.PL_Qty_T   = MS_PL.PL_Qty_T;
                    CheckMData.PL_Color   = MS_PL.PL_Color;
                    DbFile.SaveChanges();
                    return("S");
                }
                else //Add
                {
                    if (MS_BackLog != null)
                    {
                        MData.B_SO           = MS_BackLog.B_SO;
                        MData.B_SO           = MS_BackLog.B_SO;
                        MData.B_Customer     = MS_BackLog.B_Customer;
                        MData.B_Material     = MS_BackLog.B_Material;
                        MData.B_Material_Des = MS_BackLog.B_Material_Des;
                        //     MData.Date_Create = MS_BackLog.Date_Create;
                        //    MData.Date_PFD = MS_BackLog.Date_PFD;
                        //   MData.Date_Delivery = MS_BackLog.Date_Delivery;
                        MData.B_Cutting_Length = MS_BackLog.B_Cutting_Length;
                        MData.B_Order_QTY      = MS_BackLog.B_Order_QTY;
                        MData.B_Order_Unit     = MS_BackLog.B_Order_Unit;
                    }
                    else
                    {
                        MData.B_SO = MS_PL.PL_SO;
                    }

                    if (MS_Production != null)
                    {
                        MData.B_Cutting_Length = MS_Production.PD_CuttingLength;
                    }
                    MData.PL_Machine = MS_PL.PL_Machine;
                    MData.PL_Process = MS_PL.PL_Process;
                    MData.PL_Type    = MS_PL.PL_Type;
                    MData.PL_Qty     = MS_PL.PL_Qty;
                    MData.PL_Tag     = MS_PL.PL_Tag;
                    MData.PL_Qty_T   = MS_PL.PL_Qty_T;
                    MData.PL_Color   = MS_PL.PL_Color;
                    DbFile.Master_Data.Add(MData);
                    DbFile.SaveChanges();
                    return("S");
                }
            }
            catch { return("N"); }
        }//*/