Exemple #1
0
        public static R_BACKFLUSH_CHECK DataAdapert(DataSet data)
        {
            R_BACKFLUSH_CHECK obj = new R_BACKFLUSH_CHECK();

            if (data.Tables[0].Rows[0]["WORKORDERNO"] != System.DBNull.Value)
            {
                obj.WORKORDERNO = (System.String)data.Tables[0].Rows[0]["WORKORDERNO"];
            }
            if (data.Tables[0].Rows[0]["SKUNO"] != System.DBNull.Value)
            {
                obj.SKUNO = (System.String)data.Tables[0].Rows[0]["SKUNO"];
            }
            if (data.Tables[0].Rows[0]["SAP_STATION"] != System.DBNull.Value)
            {
                obj.SAP_STATION = (System.String)data.Tables[0].Rows[0]["SAP_STATION"];
            }
            if (data.Tables[0].Rows[0]["WORKORDER_QTY"] != System.DBNull.Value)
            {
                obj.WORKORDER_QTY = (System.Decimal)data.Tables[0].Rows[0]["WORKORDER_QTY"];
            }
            if (data.Tables[0].Rows[0]["BACKFLUSH_QTY"] != System.DBNull.Value)
            {
                obj.BACKFLUSH_QTY = (System.Decimal)data.Tables[0].Rows[0]["BACKFLUSH_QTY"];
            }
            if (data.Tables[0].Rows[0]["SFC_QTY"] != System.DBNull.Value)
            {
                obj.SFC_QTY = (System.Decimal)data.Tables[0].Rows[0]["SFC_QTY"];
            }
            if (data.Tables[0].Rows[0]["DIFF_QTY"] != System.DBNull.Value)
            {
                obj.DIFF_QTY = (System.Decimal)data.Tables[0].Rows[0]["DIFF_QTY"];
            }
            if (data.Tables[0].Rows[0]["SFC_STATION"] != System.DBNull.Value)
            {
                obj.SFC_STATION = (System.String)data.Tables[0].Rows[0]["SFC_STATION"];
            }
            if (data.Tables[0].Rows[0]["HAND_QTY"] != System.DBNull.Value)
            {
                obj.HAND_QTY = (System.Decimal)data.Tables[0].Rows[0]["HAND_QTY"];
            }
            if (data.Tables[0].Rows[0]["LAST_SFC_QTY"] != System.DBNull.Value)
            {
                obj.LAST_SFC_QTY = (System.Decimal)data.Tables[0].Rows[0]["LAST_SFC_QTY"];
            }
            if (data.Tables[0].Rows[0]["DIFF_QTY1"] != System.DBNull.Value)
            {
                obj.DIFF_QTY1 = (System.Decimal)data.Tables[0].Rows[0]["DIFF_QTY1"];
            }
            if (data.Tables[0].Rows[0]["DIFF_QTY2"] != System.DBNull.Value)
            {
                obj.DIFF_QTY2 = (System.Decimal)data.Tables[0].Rows[0]["DIFF_QTY2"];
            }
            if (data.Tables[0].Rows[0]["HISTORY_HAND_QTY"] != System.DBNull.Value)
            {
                obj.HISTORY_HAND_QTY = (System.Decimal)data.Tables[0].Rows[0]["HISTORY_HAND_QTY"];
            }
            if (data.Tables[0].Rows[0]["MRB_QTY"] != System.DBNull.Value)
            {
                obj.MRB_QTY = (System.Decimal)data.Tables[0].Rows[0]["MRB_QTY"];
            }
            if (data.Tables[0].Rows[0]["REC_TYPE"] != System.DBNull.Value)
            {
                obj.REC_TYPE = (System.String)data.Tables[0].Rows[0]["REC_TYPE"];
            }
            obj.AcceptChange();
            return(obj);
        }
Exemple #2
0
        public static List <R_BACKFLUSH_CHECK> DataAdapert(DataSet data, bool MulValue)
        {
            R_BACKFLUSH_CHECK        obj  = new R_BACKFLUSH_CHECK();
            List <R_BACKFLUSH_CHECK> retL = new List <R_BACKFLUSH_CHECK>();

            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                obj = new R_BACKFLUSH_CHECK();
                if (data.Tables[0].Rows[i]["WORKORDERNO"] != System.DBNull.Value)
                {
                    obj.WORKORDERNO = (System.String)data.Tables[0].Rows[i]["WORKORDERNO"];
                }
                if (data.Tables[0].Rows[i]["SKUNO"] != System.DBNull.Value)
                {
                    obj.SKUNO = (System.String)data.Tables[0].Rows[i]["SKUNO"];
                }
                if (data.Tables[0].Rows[i]["SAP_STATION"] != System.DBNull.Value)
                {
                    obj.SAP_STATION = (System.String)data.Tables[0].Rows[i]["SAP_STATION"];
                }
                if (data.Tables[0].Rows[i]["WORKORDER_QTY"] != System.DBNull.Value)
                {
                    obj.WORKORDER_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["WORKORDER_QTY"]);
                }
                if (data.Tables[0].Rows[i]["BACKFLUSH_QTY"] != System.DBNull.Value)
                {
                    obj.BACKFLUSH_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["BACKFLUSH_QTY"]);
                }
                if (data.Tables[0].Rows[i]["SFC_QTY"] != System.DBNull.Value)
                {
                    obj.SFC_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["SFC_QTY"]);
                }
                if (data.Tables[0].Rows[i]["DIFF_QTY"] != System.DBNull.Value)
                {
                    obj.DIFF_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["DIFF_QTY"]);
                }
                if (data.Tables[0].Rows[i]["SFC_STATION"] != System.DBNull.Value)
                {
                    obj.SFC_STATION = (System.String)data.Tables[0].Rows[i]["SFC_STATION"];
                }
                if (data.Tables[0].Rows[i]["HAND_QTY"] != System.DBNull.Value)
                {
                    obj.HAND_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["HAND_QTY"]);
                }
                if (data.Tables[0].Rows[i]["LAST_SFC_QTY"] != System.DBNull.Value)
                {
                    obj.LAST_SFC_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["LAST_SFC_QTY"]);
                }
                if (data.Tables[0].Rows[i]["DIFF_QTY1"] != System.DBNull.Value)
                {
                    obj.DIFF_QTY1 = Convert.ToDecimal(data.Tables[0].Rows[i]["DIFF_QTY1"]);
                }
                if (data.Tables[0].Rows[i]["DIFF_QTY2"] != System.DBNull.Value)
                {
                    obj.DIFF_QTY2 = Convert.ToDecimal(data.Tables[0].Rows[i]["DIFF_QTY2"]);
                }
                if (data.Tables[0].Rows[i]["HISTORY_HAND_QTY"] != System.DBNull.Value)
                {
                    obj.HISTORY_HAND_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["HISTORY_HAND_QTY"]);
                }
                if (data.Tables[0].Rows[i]["MRB_QTY"] != System.DBNull.Value)
                {
                    obj.MRB_QTY = Convert.ToDecimal(data.Tables[0].Rows[i]["MRB_QTY"]);
                }
                if (data.Tables[0].Rows[i]["REC_TYPE"] != System.DBNull.Value)
                {
                    obj.REC_TYPE = (System.String)data.Tables[0].Rows[i]["REC_TYPE"];
                }
                obj.AcceptChange();
                retL.Add(obj);
            }
            return(retL);
        }
        public void ToBackFlushCheck()
        {
            if (!isRun)
            {
                sfcdb = new OleExec(DBName, false);

                if (InterfacePublicValues.IsMonthly(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle))
                {
                    //月結不給拋賬
                    throw new Exception("This time is monthly,can't BackFlush");
                }

                if (_SAPWaitForBackFlushWo != null && _SAPWaitForBackFlushWo.Rows.Count > 0)
                {
                    T_R_BACKFLUSH_CHECK TR_BACKFLUSH_CHECK  = new T_R_BACKFLUSH_CHECK(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                    DataSet             BackFlushCheckTable = TR_BACKFLUSH_CHECK.GetTableConstruct(sfcdb);
                    WOBase WO;
                    T_R_BACKFLUSH_HISTORY TR_BACKFLUSH_HISTORY = new T_R_BACKFLUSH_HISTORY(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                    T_R_MRB TR_MRB = new T_R_MRB(sfcdb, MESDataObject.DB_TYPE_ENUM.Oracle);
                    foreach (DataRow dr in _SAPWaitForBackFlushWo.Rows)
                    {
                        //if (dr["AUFNR"].ToString() != "002510037542")
                        //if (dr["AUFNR"].ToString() != "002331000014")
                        //{
                        //    continue;
                        //}
                        DataRow bkItem = BackFlushCheckTable.Tables[0].NewRow();
                        bkItem["WORKORDERNO"]   = dr["AUFNR"];
                        bkItem["SKUNO"]         = dr["MATNR"];
                        bkItem["SAP_STATION"]   = dr["VORNR"];
                        bkItem["WORKORDER_QTY"] = Convert.ToInt64(Math.Ceiling(Convert.ToDecimal(dr["MGVRG"].ToString())));
                        bkItem["BACKFLUSH_QTY"] = Convert.ToInt64(Math.Ceiling(Convert.ToDecimal(dr["LMNGA"].ToString())));
                        try
                        {
                            WO = new WOBase(dr["AUFNR"].ToString(), sfcdb);
                            string SFCStation = WO.SAPMapping.GetSFCStation(bkItem["SAP_STATION"].ToString());
                            if (dr["AUFNR"].ToString().IndexOf("00257") == 0)
                            {
                                SFCStation = WO.Route.GetLastStation();
                            }
                            bkItem["SFC_STATION"] = SFCStation;
                            string LastSapStation = WO.SAPMapping.GetLastSAPStationCode();

                            if (dr["VORNR"].ToString() != LastSapStation)
                            {
                                if (dr["AUFNR"].ToString().IndexOf("00257") == 0)
                                {
                                    //處理HWD重工工單
                                    bkItem["SFC_QTY"] = WO.GetStationPassCount(SFCStation, false, sfcdb);
                                }
                                else
                                {
                                    bkItem["SFC_QTY"] = WO.GetStationPassCount(SFCStation, true, sfcdb);
                                }
                            }
                            else
                            {
                                bkItem["SFC_QTY"] = WO.GetStationPassCount(SFCStation, false, sfcdb);
                            }


                            //計算歷史拋帳數據
                            DataSet tmpData = TR_BACKFLUSH_HISTORY.GetBackFlushData(WO.WORKORDERNO, bkItem["SAP_STATION"].ToString(), sfcdb);

                            bkItem["LAST_SFC_QTY"] = tmpData.Tables[0].Rows[0]["C"];

                            //計算MRB的數量
                            tmpData           = TR_MRB.GetSNCountByWO(WO.WORKORDERNO, sfcdb);
                            bkItem["MRB_QTY"] = tmpData.Tables[0].Rows[0]["C"];

                            int   SFC_QTY      = Int32.Parse(bkItem["SFC_QTY"].ToString());
                            int   MRB_QTY      = Int32.Parse(bkItem["MRB_QTY"].ToString());
                            float SAP_QTY      = float.Parse(bkItem["BACKFLUSH_QTY"].ToString());
                            int   LAST_SFC_QTY = Int32.Parse(bkItem["LAST_SFC_QTY"].ToString());

                            int DIFF_QTY = SFC_QTY - LAST_SFC_QTY;
                            bkItem["DIFF_QTY"]  = DIFF_QTY;
                            bkItem["DIFF_QTY1"] = DIFF_QTY;
                            bkItem["DIFF_QTY2"] = SFC_QTY + MRB_QTY - SAP_QTY;

                            //處理異常數據
                            if (Int32.Parse(bkItem["DIFF_QTY"].ToString()) < 0)
                            {
                                WriteLog.WriteIntoMESLog(sfcdb, _BU, "Interface",
                                                         "MESInterface.HWD.BackFlush.BackFlushHelp",
                                                         "ToBackFlushCheck", dr["AUFNR"].ToString() + "," + dr["VORNR"].ToString() + ",DATA Err DIFF_QTY < 0", "", "System");
                                bkItem["DIFF_QTY"] = 0;
                            }


                            if (Int32.Parse(bkItem["DIFF_QTY"].ToString())
                                + float.Parse(bkItem["BACKFLUSH_QTY"].ToString())
                                > float.Parse(bkItem["WORKORDER_QTY"].ToString()))
                            {
                                bkItem["DIFF_QTY"] = 0;
                                WriteLog.WriteIntoMESLog(sfcdb, _BU, "Interface",
                                                         "MESInterface.HWD.BackFlush.BackFlushHelp",
                                                         "ToBackFlushCheck", dr["AUFNR"].ToString() + "," + dr["VORNR"].ToString() + ",DATA Err PassQTY > WORKORDER_QTY", "", "System");
                            }
                            BackFlushCheckTable.Tables[0].Rows.Add(bkItem);
                        }
                        catch (Exception ee)
                        {
                            WriteLog.WriteIntoMESLog(sfcdb, _BU, "Interface",
                                                     "MESInterface.HWD.BackFlush.BackFlushHelp",
                                                     "ToBackFlushCheck", dr["AUFNR"].ToString() + ":" + ee.Message, "", "System");
                            continue;
                        }
                    }
                    bkList = R_BACKFLUSH_CHECK.DataAdapert(BackFlushCheckTable, true);
                    if (addDataGridDelegate != null)
                    {
                        addDataGridDelegate("dgBACKFLUSH", BackFlushCheckTable.Tables[0]);
                    }
                    if (setCtrlEnableDelegate != null)
                    {
                        setCtrlEnableDelegate("btnCallRFC", true);
                    }
                }
            }
        }