Beispiel #1
0
 private void LoadSettingToUI()
 {
     if (File.Exists(SaveObject.Pathsave))
     {
         SettingClass               = new Model.SettingClass();
         SettingClass               = (Model.SettingClass)SaveObject.Load_data(SaveObject.Pathsave);
         txt_serverOffline.Text     = SettingClass.OfflineServer;
         txt_userOffline.Text       = SettingClass.userOffline;
         cb_serveroffline.IsChecked = SettingClass.usingOfftlineServer;
         passwordBox.Password       = SettingClass.password;
         txt_timmer.Text            = SettingClass.TimmerBackgroudWorker.ToString();
     }
 }
Beispiel #2
0
 public bool UpdateStatusLocalDatabase(string serno, string Status, Model.SettingClass settingClass)
 {
     try
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.Append(" update m_ERPMQC_REALTIME set status ='" + Status + "' where serno ='" + serno + "' ");
         LocalPLCSql localPLCSql = new LocalPLCSql();
         return(localPLCSql.sqlExecuteNonQuery(stringBuilder.ToString(), false, settingClass));
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateStatusLocalDatabase", ex.Message);
         return(false);
     }
 }
Beispiel #3
0
 private void LoadSettingToUI()
 {
     if (File.Exists(Algorithm.SaveObject.Pathsave))
     {
         SettingClass               = new Model.SettingClass();
         SettingClass               = (Model.SettingClass)Algorithm.SaveObject.Load_data(Algorithm.SaveObject.Pathsave);
         txt_listproductPath.Text   = SettingClass.PathListProduct;
         txt_serverOffline.Text     = SettingClass.OfflineServer;
         txt_userOffline.Text       = SettingClass.userOffline;
         cb_serveroffline.IsChecked = SettingClass.usingOfftlineServer;
         cb_StartupWindow.IsChecked = SettingClass.IsStartupWindow;
         txt_timer.Text             = SettingClass.timmer.ToString();
         txt_PLCTimeOut.Text        = SettingClass.PLCTimeOut.ToString();
         passwordBox.Password       = SettingClass.password;
     }
 }
Beispiel #4
0
        private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            SettingClass = new Model.SettingClass();
            SettingClass.OfflineServer       = txt_serverOffline.Text.Trim();
            SettingClass.userOffline         = txt_userOffline.Text.Trim();
            SettingClass.password            = passwordBox.Password;
            SettingClass.usingOfftlineServer = (bool)cb_serveroffline.IsChecked;
            try
            {
                SettingClass.TimmerBackgroudWorker = int.Parse(txt_timmer.Text.Trim());
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "convert str to int fail", ex.Message);
                SettingClass.TimmerBackgroudWorker = 30000;
            }


            SaveObject.Save_data(SaveObject.Pathsave, SettingClass);
        }
Beispiel #5
0
        public DataTable GetDataTable(string lot, DateTime dtFrom, DateTime dtTo, Model.SettingClass settingClass)
        {
            DataTable dt = new DataTable();

            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(" select * from m_ERPMQC_REALTIME where 1=1 and item !='' and status ='' ");
                stringBuilder.Append(" and lot = '" + lot + "' ");
                stringBuilder.Append(" and cast (inspectdate as datetime) + cast (inspecttime as datetime) >= '" + dtFrom.ToString("yyyyMMdd HH:mm:ss") + "'");
                stringBuilder.Append(" and  cast (inspectdate as datetime) + cast (inspecttime as datetime) <= '" + dtTo.ToString("yyyyMMdd HH:mm:ss") + "'");
                LocalPLCSql localPLCSql = new LocalPLCSql();
                localPLCSql.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt, settingClass);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "DataTable GetDataTable", ex.Message);
            }
            return(dt);
        }
Beispiel #6
0
        private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            SettingClass = new Model.SettingClass();
            SettingClass.OfflineServer       = txt_serverOffline.Text.Trim();
            SettingClass.userOffline         = txt_userOffline.Text.Trim();
            SettingClass.password            = passwordBox.Password;
            SettingClass.usingOfftlineServer = (bool)cb_serveroffline.IsChecked;
            SettingClass.IsStartupWindow     = (bool)cb_StartupWindow.IsChecked;
            SettingClass.PathListProduct     = txt_listproductPath.Text.Trim();

            try
            {
                SettingClass.timmer = int.Parse(txt_timer.Text.Trim());
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "convert str to int fail", ex.Message);
                SettingClass.timmer = 30000;
            }
            try
            {
                SettingClass.PLCTimeOut = int.Parse(txt_PLCTimeOut.Text.Trim());
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "convert timeout to int fail", ex.Message);
                SettingClass.timmer = 3000;
            }
            if ((bool)cb_StartupWindow.IsChecked)
            {
                StartUpWindow.RegistrationStartUp();
            }
            else
            {
                StartUpWindow.DeleteStartUp();
            }

            Algorithm.SaveObject.Save_data(Algorithm.SaveObject.Pathsave, SettingClass);
        }
Beispiel #7
0
        public string GetModelFromLot(string lot, Model.SettingClass setting)
        {
            string model = "";

            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("select distinct isnull(model,'') from m_ERPMQC_REALTIME where 1=1 ");
                stringBuilder.Append(" and lot = '" + lot + "'");


                LocalPLCSql sqlERPCON = new LocalPLCSql();
                model = sqlERPCON.sqlExecuteScalarString(stringBuilder.ToString(), setting);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "GetModelFromLot (string lot)", ex.Message);

                return("");
            }
            return(model);
        }
Beispiel #8
0
        public bool InsertToFactoryDatabase(DataTable dataTable, Model.SettingClass settingClass)
        {
            try
            {
                int           countInsertOK = 0;
                StringBuilder stringCommon  = new StringBuilder();
                stringCommon.Append(" insert into m_ERPMQC_REALTIME ( ");

                for (int i = 0; i < dataTable.Columns.Count; i++)
                {
                    {
                        if (i < dataTable.Columns.Count - 1)
                        {
                            stringCommon.Append(dataTable.Columns[i].ColumnName + ",");
                        }
                        else
                        {
                            stringCommon.Append(dataTable.Columns[i].ColumnName + ") values ( ");
                        }
                    }
                }
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    StringBuilder strValues = new StringBuilder();
                    for (int j = 0; j < dataTable.Columns.Count; j++)
                    {
                        string valueCell = dataTable.Rows[i][j].ToString();
                        if (j < dataTable.Columns.Count - 1)
                        {
                            strValues.Append(" '" + valueCell + "',");
                        }
                        else
                        {
                            strValues.Append("'" + valueCell + "')");
                        }
                    }

                    string StrInsert    = stringCommon.ToString() + strValues.ToString();
                    sqlCON sqlCON       = new sqlCON();
                    var    resultInsert = sqlCON.sqlExecuteNonQuery(StrInsert, false);
                    if (resultInsert)
                    {
                        UpdateStatusLocalDatabase(dataTable.Rows[i][0].ToString(), "OK", settingClass);
                        countInsertOK++;
                    }
                }
                if (dataTable.Rows.Count > countInsertOK)
                {
                    SystemLog.Output(SystemLog.MSG_TYPE.War, "Insert data has problem: ", dataTable.Rows.Count.ToString() + ">" + countInsertOK.ToString());
                }
                else if (dataTable.Rows.Count < countInsertOK)
                {
                    SystemLog.Output(SystemLog.MSG_TYPE.War, "Insert data has problem: ", dataTable.Rows.Count.ToString() + "<" + countInsertOK.ToString());
                }
                else
                {
                    return(true);
                }
            }

            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertToFactoryDatabase", ex.Message);
            }
            return(false);
        }
Beispiel #9
0
 public bool UploadLocalServertoFactoryDB(string lot, DateTime dtFrom, DateTime dtTo, Model.SettingClass settingClass)
 {
     try
     {
         var dtLotUpload = GetDataTable(lot, dtFrom, dtTo, settingClass);
         if (dtLotUpload.Rows.Count > 0)
         {
             var ResultUpload = InsertToFactoryDatabase(dtLotUpload, settingClass);
             return(ResultUpload);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "UploadLocalServertoFactoryDB", ex.Message);
     }
     return(false);
 }
        public bool InsertMQCMESUpdateRealtime(Model.MQCVariable mQCChanged, string TypeChange, string Line, Model.SettingClass setting)
        {
            try
            {
                if (TypeChange == "OPQTY")
                {
                    InsertToMQCMES_Realtime(mQCChanged.QRMES, mQCChanged.QRID, Line, "OUTPUT", mQCChanged.ListMQCQty[0].ToString(), "OP");
                }
                if (TypeChange == "NGQTY")
                {
                    for (int i = 0; i < mQCChanged.ListNG38.Count; i++)
                    {
                        if (mQCChanged.ListNG38[i] > 0)
                        {
                            InsertToMQCMES_Realtime(mQCChanged.QRMES, mQCChanged.QRID, Line, "NG" + (i + 1).ToString(), mQCChanged.ListNG38[i].ToString(), "NG");
                        }
                    }
                }
                if (TypeChange == "RWQTY")
                {
                    for (int i = 0; i < mQCChanged.ListRW38.Count; i++)
                    {
                        if (mQCChanged.ListRW38[i] > 0)
                        {
                            InsertToMQCMES_Realtime(mQCChanged.QRMES, mQCChanged.QRID, Line, "RW" + (i + 1).ToString(), mQCChanged.ListRW38[i].ToString(), "RW");
                        }
                    }
                }
                if (TypeChange == "Reset")
                {
                    InsertToMQCMES_Realtime(mQCChanged.QRMES, mQCChanged.QRID, Line, "Reset", "", "Reset");
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertMQCUpdateRealtime (DataMQC data, string Line, bool Isreset)", ex.Message);

                return(false);
            }

            return(true);
        }
Beispiel #11
0
        public bool InsertToMQC_Realtime(string lot, string line, string item, string data, string Remark, int judge, Model.SettingClass setting)
        {
            try
            {
                string datetimeserno = DateTime.Now.ToString("yyyyMMdd_HHmmss");
                string serno         = lot + "-" + datetimeserno;
                string site          = "B01";
                string factory       = "TECHLINK";
                string process       = "MQC";

                string status    = "";
                string date_     = DateTime.Now.ToString("yyyy-MM-dd");
                string time_     = DateTime.Now.ToString("HH:mm:ss");
                string sqlQuerry = "";

                // string model = GetModelFromLot(lot,setting);
                string model = GetModelFromLot(lot);// lay model tren server, neu ko lay dc thi lay o local
                if (model == "")
                {
                    model = GetModelFromLot(lot, setting);
                }
                sqlQuerry += "insert into m_ERPMQC_REALTIME (serno, lot, model, site, factory, line, process,item,inspectdate,inspecttime, data, judge,status,remark ) values( '";
                sqlQuerry += serno + "', '" + lot + "', '" + model + "', '" + site + "', '" + factory + "', '" + line +
                             "', '" + process + "', '" + item + "', '" + date_ + "', '" + time_ + "', '" + data + "', '" + judge.ToString() + "', '" + status + "', '" + Remark + "' )";
                LocalPLCSql localPLC = new LocalPLCSql();
                return(localPLC.sqlExecuteNonQuery(sqlQuerry, false, setting));
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertToMQC_Realtime(string lot, string line, string item, string data, string Remark, int judge)", ex.Message);
                return(false);
            }
        }
Beispiel #12
0
        public bool InsertMQCUpdateRealtime(DataMQC data, string Line, bool Isreset, Model.SettingClass setting)
        {
            try
            {
                if (Isreset)
                {
                    if (data.PLC_Barcode.Length == 26)
                    {
                        if (data.Good_Products_Total > 0)
                        {
                            InsertToMQC_Realtime(data.PLC_Barcode, Line, "OUTPUT", data.Good_Products_Total.ToString(), "OP", 1, setting);
                        }

                        for (int i = 1; i < 39; i++)
                        {
                            if (data.NG_Products_NG_[i - 1] > 0)
                            {
                                InsertToMQC_Realtime(data.PLC_Barcode, Line, "NG" + i.ToString(), data.NG_Products_NG_[i - 1].ToString(), "NG", 1, setting);
                            }
                        }



                        for (int i = 1; i < 39; i++)
                        {
                            if (data.RW_Products_NG_[i - 1] > 0)
                            {
                                InsertToMQC_Realtime(data.PLC_Barcode, Line, "RW" + i.ToString(), data.RW_Products_NG_[i - 1].ToString(), "RW", 1, setting);
                            }
                        }
                    }
                    else
                    {
                        SystemLog.Output(SystemLog.MSG_TYPE.War, "Barcode wrong formart ", data.PLC_Barcode);
                    }
                }
                else
                {
                    if (data.PLC_Barcode.Length == 26)
                    {
                        if (data.Good_Products_Total > 0)
                        {
                            InsertToMQC_Realtime(data.PLC_Barcode, Line, "OUTPUT", data.Good_Products_Total.ToString(), "OP", 0, setting);
                        }
                        if (data.NG_Products_Total > 0)
                        {
                            for (int i = 1; i < 39; i++)
                            {
                                if (data.NG_Products_NG_[i - 1] > 0)
                                {
                                    InsertToMQC_Realtime(data.PLC_Barcode, Line, "NG" + i.ToString(), data.NG_Products_NG_[i - 1].ToString(), "NG", 0, setting);
                                }
                            }
                        }
                        if (data.RW_Products_Total > 0)
                        {
                            for (int i = 1; i < 39; i++)
                            {
                                if (data.RW_Products_NG_[i - 1] > 0)
                                {
                                    InsertToMQC_Realtime(data.PLC_Barcode, Line, "RW" + i.ToString(), data.RW_Products_NG_[i - 1].ToString(), "RW", 0, setting);
                                }
                            }
                        }
                    }
                    else
                    {
                        SystemLog.Output(SystemLog.MSG_TYPE.War, "Barcode wrong formart ", data.PLC_Barcode);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertMQCUpdateRealtime (DataMQC data, string Line, bool Isreset)", ex.Message);

                return(false);
            }

            return(true);
        }