示例#1
0
        public string GetTB039_Down(string date_)
        {
            string _TC002     = "";
            string dateFormat = date_.Substring(1);
            string firstvalue = dateFormat + "9999";
            sqlCON data       = new sqlCON();
            string check9999  = data.sqlExecuteScalarString("select count(*) TRANSNO from m_SFTKEY where TRANSNO = '" + firstvalue + "'");

            if (int.Parse(check9999) != 0)
            {
                string minTB002 = data.sqlExecuteScalarString("select min(TRANSNO) from m_SFTKEY where TRANSNO like '" + dateFormat + "%'");
                int    valueset = int.Parse(minTB002.Trim().Substring(7, 4));
                valueset = valueset - 1;
                _TC002   = dateFormat + valueset.ToString("0000");
            }
            else
            {
                _TC002 = firstvalue;
            }
            //insertnextvalue
            string sqlinsert = "insert into m_SFTKEY(TRANSNO, datetimeRST) values ('" + _TC002 + "', getdate()) ";

            data.sqlExecuteNonQuery(sqlinsert, false);
            return(_TC002);
        }
示例#2
0
        public string GetCodeNGFrom_process(string Dept, string PLCNG)
        {
            string        Str = "";
            StringBuilder sql = new StringBuilder();

            sql.Append("select  itemcode ");
            sql.Append("from m_process ");
            sql.Append("where 1=1 ");
            sql.Append("and modelcode = '" + Dept + "' ");
            sql.Append("and processcode = '" + PLCNG + "' ");
            sqlCON data = new sqlCON();

            Str = data.sqlExecuteScalarString(sql.ToString());
            return(Str);
        }
示例#3
0
        public void GetListLOT()
        {
            try
            {
                string   sqlgetListLOT = "select distinct lot  from m_ERPMQC_REALTIME  where data not like '0' and status  like '' ";
                ComboBox cmb_          = new ComboBox();
                sqlCON   data          = new sqlCON();
                data.getComboBoxData(sqlgetListLOT, ref cmb_);
                string inspectdate = DateTime.Now.ToString("yyyy-MM-dd");
                string inspecttime = DateTime.Now.ToString("HH:mm:ss");
                string DateUp      = DateTime.Now.ToString("yyyyMMdd");
                string TimeUp      = DateTime.Now.ToString("HH:mm:ss");
                string TimeSerno   = DateTime.Now.ToString("HHmmss");
                //   if (cmb_.Items.Count == 0) return;
                for (int cmbitem = 0; cmbitem < cmb_.Items.Count; cmbitem++)
                {
                    string        serno       = cmb_.Items[cmbitem].ToString().Split(';')[0] + "-" + DateUp + "_" + TimeSerno;
                    DataTable     table       = new DataTable();
                    StringBuilder sqlGetTable = new StringBuilder();
                    sqlGetTable.Append("select '" + serno + "' as serno,");
                    sqlGetTable.Append("lot, model, site, factory, line, process,item,");
                    sqlGetTable.Append("'" + inspectdate + "' as inspectdate,");
                    sqlGetTable.Append("'" + inspecttime + "' as inspecttime,");
                    sqlGetTable.Append("sum(cast(data as int)) as data,");
                    sqlGetTable.Append("'0' as judge , status, remark from m_ERPMQC_REALTIME  ");
                    sqlGetTable.Append("where data not like '0' and status  like '' and lot = '" + cmb_.Items[cmbitem].ToString() + "'");
                    sqlGetTable.Append("group by item,lot,model,site, factory, line, process, item,  status, remark");
                    data.sqlDataAdapterFillDatatable(sqlGetTable.ToString(), ref table);

                    int intCountOK = CounterỌKERP(ref table);
                    int intCountNG = CounterNGERP(ref table);
                    strLot = table.Rows[0]["lot"].ToString();
                    string code = table.Rows[0]["serno"].ToString().Split('-')[0];
                    string No   = table.Rows[0]["serno"].ToString().Split('-')[1];
                    //string serno = table.Rows[0]["serno"].ToString();
                    string typeNG      = "";
                    int    checkdouble = 0;
                    //check file trung
                    string sqlERP      = "select count(*) from m_ERPMQC_Error where serno = '" + serno + "'";
                    string sqlERPError = "select count(*) from m_ERPMQC_REALTIME where serno = '" + serno + "'";
                    checkdouble = int.Parse(data.sqlExecuteScalarString(sqlERP)) + int.Parse(data.sqlExecuteScalarString(sqlERPError));
                    //An Them Code Check Nguyen Vat Lieu ngay 10/05/2019
                    string               MaLSX        = code + "-" + No;
                    Material             material     = new Material();
                    bool                 IsDuSoLuong  = false;
                    bool                 IsNVL        = false;
                    List <string>        _messages    = new List <string>();
                    List <MaterialAdapt> listMaterial = new List <MaterialAdapt>();
                    double               SL_UPload    = intCountOK + intCountNG;
                    //Chua ma Lenh San xuat vao 2 truong dang dua vao
                    bool        IsResultheck = material.KiemtraNguyenVatLieu(code, No, SL_UPload, out IsDuSoLuong, out IsNVL, out listMaterial, out _messages);
                    insertERP   classinsert  = new insertERP();
                    DefectClass defectClass  = new DefectClass();
                    if ((intCountNG + intCountOK > 0) && checkdouble == 0)
                    {
                        //update to realtime

                        if (IsResultheck == true)
                        {
                            classinsert.InsertdataToERP(table.Rows[0]["lot"].ToString(), intCountOK.ToString(), intCountNG.ToString(), DateUp, TimeUp);
                            classinsert.updateERP(table.Rows[0]["lot"].ToString(), intCountOK.ToString(), intCountNG.ToString(), DateUp, TimeUp);
                            classinsert.InsertdataToSFT(table.Rows[0]["lot"].ToString(), intCountOK.ToString(), intCountNG.ToString(), DateUp, TimeUp);
                            classinsert.UpdatedataToSFT(table.Rows[0]["lot"].ToString(), intCountOK.ToString(), intCountNG.ToString(), DateUp, TimeUp);


                            for (int i = 0; i < table.Rows.Count; i++)
                            {
                                typeNG = table.Rows[i]["item"].ToString();
                                string SL = table.Rows[i]["data"].ToString();

                                if (int.Parse(SL) > 0 && typeNG.Contains("NG"))
                                {
                                    var insert = defectClass.InsertToSFT_OP_EXCEPT(MaLSX, typeNG, int.Parse(SL), classinsert.Sequence_OP_REAL_RUN);
                                }
                            }
                            classinsert.InsertToERPMQC(table);
                            classinsert.UpdateToERPMQC_Realtime("OK", strLot);
                            classinsert.updateERPMQC(table.Rows[0]["serno"].ToString());
                            classinsert.UpdateToERPMQC_Error("OK", table.Rows[0]["serno"].ToString());
                        }
                        else //insert to Temperate database
                        {
                            classinsert.InsertToERPMQC_Error(table);
                            classinsert.InsertToERPMQC(table);
                            classinsert.UpdateToERPMQC_Realtime("OK", strLot);
                        }
                    }
                }
                UpdateFromERPMQC_ErrorToSFT_ERP(); //waiting
            }

            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, " GetListLOT", ex.Message);
            }
        }