コード例 #1
0
ファイル: insertERPSFCTC.cs プロジェクト: tranducan/MESDb2ERP
        public void UpdatedataToSFT(string barcode, string output, string NG, string date, string time)
        {
            try
            {
                string datetime = date + " " + time;

                SQLSFTTLVN2 data = new SQLSFTTLVN2();
                string[]    QR   = barcode.Split(';');
                string[]    ML   = QR[0].Split('-');

                string        datetimefrist = data.sqlExecuteScalarString("select distinct ARRIVETIME from SFT_OP_REALRUN where  ID = '" + QR[0] + "' and OPID = 'B01---B01' and SEQUENCE  = 0");
                StringBuilder update        = new StringBuilder();
                update.Append("update SFT_OP_REALRUN set ALERADYDEFECTQTY = ALERADYDEFECTQTY+  " + NG + ",");
                update.Append("OUTQTY = OUTQTY+ " + output + ",");
                update.Append("DEFECTQTY = DEFECTQTY+ " + NG + ",");
                update.Append("ARRIVEQTY = ARRIVEQTY + (" + NG + "+" + output + "),");
                if (datetimefrist == "")
                {
                    update.Append("ARRIVETIME = '" + datetime + "',");
                }
                update.Append("OUTTIME ='" + datetime + "',");
                update.Append("OR019 =OR019 +" + NG + ",");
                update.Append("UNIT = 'PCS',");
                update.Append("OR012 = OR012 -" + NG + ",");  //a Long them vao
                update.Append("OR020 = OR020 - (" + NG + "+" + output + ")");
                update.Append("where ID = '" + QR[0] + "' and OPID = 'B01---B01' and SEQUENCE  = 0");
                data.sqlExecuteNonQuery(update.ToString(), false);

                //update toSFT_OP_REALRUN B02
                StringBuilder UpdateB02 = new StringBuilder();
                UpdateB02.Append("update SFT_OP_REALRUN set OR017 =  OR017 -" + NG + ",");
                UpdateB02.Append("OR012 =OR012- " + NG + ","); //a Long them vao
                UpdateB02.Append("OR020 = OR020 +  " + output + " ");
                UpdateB02.Append("where ID = '" + QR[0] + "' and OPID = 'B02---B01' and SEQUENCE = 0");
                data.sqlExecuteNonQuery(UpdateB02.ToString(), false);//chi dieu se kiem tra lai co up hay ko

                //update into LOT table B01
                string updateLOTB01 = "update LOT set TYPE = 0, LOTSIZE =  LOTSIZE -(" + output + "+" + NG + "),ISPLANNED = 0  where ID = '" + QR[0] + "' and ERP_OPSEQ = '0010' and ERP_OPID = 'B01' and STATUS !='50'";
                data.sqlExecuteNonQuery(updateLOTB01, false);


                //update to MODETAIL
                StringBuilder updateMODETAIL = new StringBuilder();
                updateMODETAIL.Append("update MODETAIL  set MO019 = MO019 - " + NG + ",TOTALEXCEPTQTY  = TOTALEXCEPTQTY - " + NG + ",LASTMAINTAINDATETIME = '" + datetime + "' where CMOID = '" + QR[0] + "'");
                data.sqlExecuteNonQuery(updateMODETAIL.ToString(), false);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, " UpdatedataToSFT(string barcode)", ex.Message);
            }
        }
コード例 #2
0
ファイル: insertERPSFCTC.cs プロジェクト: tranducan/MESDb2ERP
 public void updateERPMQC(string serno)
 {
     try
     {
         StringBuilder update = new StringBuilder();
         update.Append("update m_ERPMQC set status = 'OK' where serno = '" + serno + "'");
         sqlCON data = new sqlCON();
         data.sqlExecuteNonQuery(update.ToString(), false);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "updateERPMQC(string serno)", ex.Message);
     }
 }
コード例 #3
0
ファイル: insertERPSFCTC.cs プロジェクト: tranducan/MESDb2ERP
 public bool UpdateToERPMQC_Realtime(string Status, string lot)
 {
     try
     {
         StringBuilder sqlupdate = new StringBuilder();
         sqlupdate.Append("update m_ERPMQC_REALTIME set status = '" + Status + "' where ");
         sqlupdate.Append("lot = '" + lot + "' and data not like '0' and status  like ''");
         sqlCON data = new sqlCON();
         data.sqlExecuteNonQuery(sqlupdate.ToString(), false);
         return(true);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "  UpdateToERPMQC_Realtime(string Status, string lot)", ex.Message);
         return(false);
     }
 }
コード例 #4
0
ファイル: insertERPSFCTC.cs プロジェクト: tranducan/MESDb2ERP
 public bool UpdateToERPMQC_Error(string Status, string serno)
 {
     try
     {
         StringBuilder sqlupdate = new StringBuilder();
         sqlupdate.Append("update m_ERPMQC_Error set status = '" + Status + "' where ");
         sqlupdate.Append("serno = '" + serno + "'");
         sqlCON data = new sqlCON();
         data.sqlExecuteNonQuery(sqlupdate.ToString(), false);
         return(true);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, " UpdateToERPMQC_Error(string Status, string serno)", ex.Message);
         return(false);
     }
 }
コード例 #5
0
 public void sqlDataAdapterFillDatatable(string sql, ref DataTable dt)
 {
     try
     {
         SqlCommand     cmd     = new SqlCommand();
         SqlDataAdapter adapter = new SqlDataAdapter();
         {
             cmd.CommandText       = sql;
             cmd.Connection        = conn;
             adapter.SelectCommand = cmd;
             adapter.Fill(dt);
         }
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ex.Message);
     }
 }
コード例 #6
0
ファイル: DefectClass.cs プロジェクト: tranducan/MESDb2ERP
        public bool InsertToSFT_OP_EXCEPT(string codeSX, string PLCNG, int QTYNG, int sequence)

        {
            try
            {
                string   SFTNGCode      = GetCodeNGFrom_process("B01", PLCNG);
                string[] DefectSFTArray = GetDefectItemFromSFT(SFTNGCode);
                //   int _sequence = GetSequence_SFT_OP_EXCEPT(codeSX, "defect", DefectSFTArray[0], DefectSFTArray[1],  "10", "B01", "B01");
                var insert = InsertDefect2SFT_OP_EXCEPT(codeSX, sequence, QTYNG, "B01---B01", "ERP", "defect", DefectSFTArray[0],
                                                        DefectSFTArray[1], "0010", "B01", 0, 0);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertToSFT_OP_EXCEPT(string codeSX,string PLCNG, int QTYNG)", ex.Message);
                return(false);
            }
            return(true);
        }
コード例 #7
0
        public SqlConnection conn = DBUtils.GetDBConnection(); //get from user database

        public string sqlExecuteScalarString(string sql)
        {
            String outstring;

            try
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                conn.Open();
                outstring = cmd.ExecuteScalar().ToString();
                conn.Close();
                return(outstring);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ex.Message);
                return(String.Empty);
            }
        }
コード例 #8
0
ファイル: LocalPLCSql.cs プロジェクト: tranducan/MESDb2ERP
        public SqlConnection conn = new SqlConnection(); //get from user database

        public string sqlExecuteScalarString(string sql, Model.SettingClass settingClass)
        {
            String outstring;

            try
            {
                conn = DBUtils.GetLocalPLCConnection(settingClass.OfflineServer, "ERPSOFT", settingClass.userOffline, settingClass.password);
                SqlCommand cmd = new SqlCommand(sql, conn);
                conn.Open();
                outstring = cmd.ExecuteScalar().ToString();
                conn.Close();
                return(outstring);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ex.Message);
                return(String.Empty);
            }
        }
コード例 #9
0
ファイル: LocalPLCSql.cs プロジェクト: tranducan/MESDb2ERP
 public void sqlDataAdapterFillDatatable(string sql, ref DataTable dt, Model.SettingClass settingClass)
 {
     try
     {
         conn = DBUtils.GetLocalPLCConnection(settingClass.OfflineServer, "ERPSOFT", settingClass.userOffline, settingClass.password);
         SqlCommand     cmd     = new SqlCommand();
         SqlDataAdapter adapter = new SqlDataAdapter();
         {
             cmd.CommandText       = sql;
             cmd.Connection        = conn;
             adapter.SelectCommand = cmd;
             adapter.Fill(dt);
         }
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ex.Message);
     }
 }
コード例 #10
0
        public static void exportcsvToPLC(string linkListProduct)
        {
            try
            {
                string path = linkListProduct;
                File.Delete(path + "ListProduct.csv");
                StringBuilder sql = new StringBuilder();
                sql.Append(@"
select TA001+'-'+RTRIM(TA002)+';'+TA003+';'+TA004+';'+ RTRIM(TA006),  RTRIM(TC047),RTRIM(TA010),  RTRIM(TA011), RTRIM(TA012)  ,TA001,TA002,TA003,TA004, TA006 from SFCTA 
left join SFCTC on TA001 = TC004 and TA002 = TC005
where 1=1
and TA004 = 'B01'
and TA011+TA012 <TA010
group by TA001,TA002,TA003,TA004, TA006, TA010, TA011,TA012, TC047
");
                DataTable dtshow = new DataTable();
                sqlERPCON data   = new sqlERPCON();
                data.sqlDataAdapterFillDatatable(sql.ToString(), ref dtshow);

                StringBuilder builder     = new StringBuilder();
                int           rowcount    = dtshow.Rows.Count;
                int           columncount = dtshow.Columns.Count;
                List <string> cols        = new List <string>();

                // builder.AppendLine(string.Join("\t", cols.ToArray()));
                for (int i = 0; i < rowcount; i++)
                {
                    cols = new List <string>();
                    for (int j = 0; j < 5; j++) //Chỉ lay 4 cọt đâu thôi, yêu cầu của Đức
                    {
                        cols.Add(dtshow.Rows[i][j].ToString() + @",");
                    }
                    builder.AppendLine(string.Join("", cols.ToArray()));
                }
                System.IO.File.WriteAllText(path + "ListProduct.csv", builder.ToString());
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "exportcsvToPLC()", ex.Message);
            }
        }
コード例 #11
0
ファイル: insertERPSFCTC.cs プロジェクト: tranducan/MESDb2ERP
 public bool InsertToERPMQC(DataTable table)
 {
     try
     {
         for (int i = 0; i < table.Rows.Count; i++)
         {
             if (table.Rows[i]["data"].ToString().Trim() != "0" && double.Parse(table.Rows[i]["data"].ToString()) > 0)
             {
                 StringBuilder sqlInsert = new StringBuilder();
                 sqlInsert.Append("insert into m_ERPMQC ");
                 sqlInsert.Append(@"(serno, lot, model, site, factory, line, process, item, inspectdate, inspecttime, data, judge, status, remark )");
                 sqlInsert.Append(" values ( ");
                 sqlInsert.Append("'" + table.Rows[i]["serno"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["lot"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["model"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["site"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["factory"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["line"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["process"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["item"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["inspectdate"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["inspecttime"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["data"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["judge"].ToString() + "' , ");
                 sqlInsert.Append("'" + table.Rows[i]["status"].ToString() + "', ");
                 sqlInsert.Append("'" + table.Rows[i]["remark"].ToString() + "' ) ");
                 sqlCON data = new sqlCON();
                 data.sqlExecuteNonQuery(sqlInsert.ToString(), false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertToERPMQC(DataTable table)", ex.Message);
         return(false);
     }
 }
コード例 #12
0
ファイル: DefectClass.cs プロジェクト: tranducan/MESDb2ERP
        public string [] GetDefectItemFromSFT(string defectCode)
        {
            string[] strDefectItem = new string[2];
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append(@"
select l.CIL003,s.CIS003 from dbo.SFT_COLLECTITEM_SUBLINE s 
inner join dbo.SFT_COLLECTITEM_LINE  l on s.CIS001 = l.CIL002
where 1=1
 ");
                sql.Append("and s.CIS002  = '" + defectCode + "' ");
                SQLSFTTLVN2 sQLCommon = new SQLSFTTLVN2();
                DataTable   dt        = new DataTable();
                sQLCommon.sqlDataAdapterFillDatatable(sql.ToString(), ref dt);
                strDefectItem = dt.Rows[0].ItemArray.Select(x => x.ToString()).ToArray();
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "GetDefectItemFromSFT (string defectCode)", ex.Message);
            }
            return(strDefectItem);
        }
コード例 #13
0
ファイル: DefectClass.cs プロジェクト: tranducan/MESDb2ERP
        public int GetSequence_SFT_OP_EXCEPT(string ID, string EXCEPTTYPE, string EXCEPTGROUP, string EXCEPTREASON, string ERP_OPSEQ,
                                             string ERP_OPID, string ERP_WSID)
        {
            int sequence = 0;

            try
            {
                StringBuilder sql  = new StringBuilder();
                string        temp = "";
                sql.Append(@"
select max(SEQUENCE) from  SFT_OP_EXCEPT where 1=1
 ");
                sql.Append("and ID = '" + ID + "' ");
                sql.Append("and EXCEPTTYPE = '" + EXCEPTTYPE + "' ");
                sql.Append("and EXCEPTGROUP = '" + EXCEPTGROUP + "' ");
                sql.Append("and EXCEPTREASON = '" + EXCEPTREASON + "' ");
                sql.Append("and ERP_OPSEQ = '" + ERP_OPSEQ + "' ");
                sql.Append("and ERP_OPID = '" + ERP_OPID + "' ");
                sql.Append("and ERP_WSID = '" + ERP_WSID + "' ");
                SQLSFTTLVN2 sQLCommon = new SQLSFTTLVN2();
                temp = sQLCommon.sqlExecuteScalarString(sql.ToString());
                if (temp != null && temp != "")
                {
                    sequence = int.Parse(temp) + 1;
                }
                else
                {
                    sequence = 0;
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, " GetSequence_SFT_OP_EXCEPT", ex.Message);
            }
            return(sequence);
        }
コード例 #14
0
        public void UpdateFromERPMQC_ErrorToSFT_ERP()
        {
            try
            {
                StringBuilder sqlquery = new StringBuilder();
                sqlquery.Append(@"select distinct
serno,lot,model,site,factory,line,process,item,inspectdate,inspecttime,data,judge,status,remark
from m_ERPMQC_Error 
where status !='OK' ");
                sqlCON    data    = new sqlCON();
                DataTable dtTable = new DataTable();
                data.sqlDataAdapterFillDatatable(sqlquery.ToString(), ref dtTable);

                for (int i = 0; i < dtTable.Rows.Count; i++)
                {
                    Material             material     = new Material();
                    bool                 IsDuSoLuong  = false;
                    bool                 IsNVL        = false;
                    List <string>        _messages    = new List <string>();
                    List <MaterialAdapt> listMaterial = new List <MaterialAdapt>();
                    //Chua ma Lenh San xuat vao 2 truong dang dua vao
                    string code    = dtTable.Rows[i]["serno"].ToString().Split('-')[0];
                    string No      = dtTable.Rows[i]["serno"].ToString().Split('-')[1];
                    double dataQTY = dtTable.Rows[i]["data"].ToString() != null?double.Parse(dtTable.Rows[i]["data"].ToString()) : 0;

                    string      DateUp       = DateTime.Parse(dtTable.Rows[i]["inspectdate"].ToString()).ToString("yyyyMMdd");
                    string      TimeUp       = dtTable.Rows[i]["inspecttime"].ToString().Substring(0, 8);
                    string      typeNG       = "";
                    string      MaLSX        = code + "-" + No;
                    bool        IsResultheck = material.KiemtraNguyenVatLieu(code, No, dataQTY, out IsDuSoLuong, out IsNVL, out listMaterial, out _messages);
                    DefectClass defectClass  = new DefectClass();
                    if (IsNVL && (dtTable.Rows[i]["data"].ToString() != "0"))
                    {//Update Status
                        string    test        = dtTable.Rows[i]["remark"].ToString();
                        int       countOK     = dtTable.Rows[i]["remark"].ToString() == "OP" ? int.Parse(dtTable.Rows[i]["data"].ToString()) : 0;
                        int       countNG     = dtTable.Rows[i]["remark"].ToString() == "NG" ? int.Parse(dtTable.Rows[i]["data"].ToString()) : 0;
                        insertERP classinsert = new insertERP();
                        classinsert.InsertdataToERP(dtTable.Rows[i]["lot"].ToString(), countOK.ToString(), countNG.ToString(), DateUp, TimeUp);
                        classinsert.updateERP(dtTable.Rows[i]["lot"].ToString(), countOK.ToString(), countNG.ToString(), DateUp, TimeUp);
                        classinsert.InsertdataToSFT(dtTable.Rows[i]["lot"].ToString(), countOK.ToString(), countNG.ToString(), DateUp, TimeUp);
                        classinsert.UpdatedataToSFT(dtTable.Rows[i]["lot"].ToString(), countOK.ToString(), countNG.ToString(), DateUp, TimeUp);
                        classinsert.updateERPMQC(dtTable.Rows[i]["serno"].ToString());
                        classinsert.UpdateToERPMQC_Error("OK", dtTable.Rows[i]["serno"].ToString());
                        // for (int j = 0; j < dtTable.Rows.Count; j++)
                        {
                            typeNG = dtTable.Rows[i]["item"].ToString();
                            string SL = dtTable.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);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateFromERPMQC_ErrorToSFT_ERP ()", ex.Message);
            }
        }
コード例 #15
0
 private void ItemExit_Click(object sender, EventArgs e)
 {
     this.Close();
     Environment.Exit(0);
     SystemLog.Output(SystemLog.MSG_TYPE.Err, "MES TO ERP", e.ToString());
 }
コード例 #16
0
ファイル: insertERPSFCTC.cs プロジェクト: tranducan/MESDb2ERP
        public void InsertdataToERP(string barcode, string output, string NG, string date, string time)
        {
            try
            {
                string[] QR = barcode.Split(';');
                string[] ML = QR[0].Split('-');
                //string date = DateTime.Now.ToString("yyyyMMdd");
                //string time = DateTime.Now.ToString("HH:mm:ss");
                // string month = DateTime.Now.ToString("yyMM");
                string    month     = date.Substring(2, 6);
                sqlERPCON sqlERPCON = new sqlERPCON();
                // An chinh sua
                string TC002 = GetTC002();
                TO008 = TC002;
                TOID  = "D201-" + TC002; //chay thuc te
                //
                string TC047 = sqlERPCON.sqlExecuteScalarString("select distinct TA006 from MOCTA where TA001 = '" + ML[0] + "' and TA002 = '" + ML[1] + "'");
                ITEMID_TC047 = TC047;
                string TC048 = sqlERPCON.sqlExecuteScalarString("select distinct TA034 from MOCTA where TA001 = '" + ML[0] + "' and TA002 = '" + ML[1] + "'");
                ITEMNAME_TC048 = TC048;
                SQLSFTTLVN2 sQLSFTTLVN2 = new SQLSFTTLVN2();
                ITEMDESCRIPTION = sQLSFTTLVN2.sqlExecuteScalarString("select distinct  ITEMDESCRIPTION from  SFT_TRANSORDER_LINE where TRANSORDERTYPE = 'D101' and KEYID = '" + QR[0] + "'");


                string TA007 = sqlERPCON.sqlExecuteScalarString("select distinct TA007 from SFCTA where TA004 ='B01' and  TA001 = '" + ML[0] + "' and TA002 = '" + ML[1] + "'");
                int    TC036 = int.Parse(output) + int.Parse(NG);
                // AN chinh sua
                TRANSNO = GetTB039(date);                       //update to transfer table

                sqlERPCON     sqlInsert      = new sqlERPCON(); //
                StringBuilder sqlInsertSFCTC = new StringBuilder();
                sqlInsertSFCTC.Append("insert into SFCTC ");
                sqlInsertSFCTC.Append(@"(COMPANY,CREATOR,USR_GROUP,CREATE_DATE,MODIFIER,MODI_DATE,FLAG,CREATE_TIME,CREATE_AP,CREATE_PRID,MODI_TIME,MODI_AP,MODI_PRID,");
                sqlInsertSFCTC.Append(@"TC001,TC002,TC003,TC004,TC005,TC006,TC007,TC008,TC009,TC010,TC011,TC012,TC013,TC014,TC015,TC016,TC017,TC018,TC019,TC020,");
                sqlInsertSFCTC.Append(@"TC021,TC022,TC023,TC024,TC025,TC026,TC027,TC033,TC034,TC035,TC036,TC037,TC038,TC039,TC040,");
                sqlInsertSFCTC.Append(@"TC041,TC042,TC043,TC044,TC045,TC046,TC047,TC048,TC049,TC050,TC051,TC055)");
                sqlInsertSFCTC.Append(" values ( ");
                sqlInsertSFCTC.Append("'TECHLINK','BQC01','JG01','" + date + "','BQC01','" + date + "',2,'" + time + "','SFT','Sftb03','" + time + "','SFT','',");
                sqlInsertSFCTC.Append("'D201','" + TC002 + "','0001','" + ML[0] + "','" + ML[1] + "','" + QR[1] + "','" + QR[2] + "','0020','B02','PCS','','','1'," + output + ",0," + NG + ",0,0,0,0,");
                sqlInsertSFCTC.Append("0,'Y','B01','',0,'N','N','" + date + "','" + date + "','N'," + TC036 + ",0,'" + date + "','0','',");
                sqlInsertSFCTC.Append("'B01',0,0,0,0,0,'" + TC047 + "','" + TC048 + "','" + ITEMDESCRIPTION + "','KG','0','N'");  //update new 21-oct
                sqlInsertSFCTC.Append(")");
                sqlInsert.sqlExecuteNonQuery(sqlInsertSFCTC.ToString(), false);


                StringBuilder sqlInsertSFCTB = new StringBuilder();
                sqlInsertSFCTB.Append("insert into SFCTB ");
                sqlInsertSFCTB.Append("(COMPANY,CREATOR,USR_GROUP,CREATE_DATE,MODIFIER,MODI_DATE,FLAG,CREATE_TIME,CREATE_AP,CREATE_PRID,MODI_TIME,MODI_AP,MODI_PRID,");
                sqlInsertSFCTB.Append("TB001,TB002,TB003,TB004,TB005,TB006,TB007,TB008,TB009,TB010,TB011,TB012,TB013,TB014,TB015,TB016,TB017,TB018,TB019,TB020,");
                sqlInsertSFCTB.Append(" TB021,TB022,TB023,TB024,TB025,TB026,TB031,TB036,TB037,TB038,TB039,");
                sqlInsertSFCTB.Append("TB200,TB201,TB202)");

                sqlInsertSFCTB.Append(" values ( ");
                sqlInsertSFCTB.Append("'TECHLINK','BQC01','JG01','" + date + "','BQC01','" + date + "',2,'" + time + "','SFT','Sftb03','" + time + "','SFT','',");
                sqlInsertSFCTB.Append("'D201','" + TC002 + "','" + date + "','1','B01','" + TA007 + "','1','B01','" + TA007 + "','TL',0,'N','Y','','" + date + "','ERP','N','','1','',");
                sqlInsertSFCTB.Append("'','1','1','','" + month + "',0.2,'0','VND',1,'D201','" + TRANSNO + "',");
                sqlInsertSFCTB.Append(int.Parse(output) + int.Parse(NG) + "," + output + "," + NG + " "); //ap them chi dieu yeu cau
                sqlInsertSFCTB.Append(")");
                sqlInsert.sqlExecuteNonQuery(sqlInsertSFCTB.ToString(), false);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertdataToERP(string barcode, string output, string NG)", ex.Message);
            }
        }
コード例 #17
0
ファイル: insertERPSFCTC.cs プロジェクト: tranducan/MESDb2ERP
        public void InsertdataToSFT(string barcode, string output, string NG, string date, string time)
        {
            //  TOID = "D201-190xxxxx"; //chay thu nghiem
            try
            {
                string[] QR = barcode.Split(';');
                string[] ML = QR[0].Split('-');

                //  string datetime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss");
                string      datetime   = date + " " + time;
                SQLSFTTLVN2 data       = new SQLSFTTLVN2();
                string      str_OUTQTY = data.sqlExecuteScalarString("select sum(OUTQTY) as OUTQTY from SFT_OP_REALRUN where ID = '" + QR[0] + "' and OPID = 'B01---B01' and SEQUENCE not like 0");
                double      OUTQTY     = 0;
                if (str_OUTQTY == "" || str_OUTQTY == null)
                {
                    OUTQTY = 0;
                }
                else
                {
                    OUTQTY = double.Parse(str_OUTQTY);
                }
                LOTSIZE_B02 = OUTQTY + int.Parse(output);
                int SEQUENCE = int.Parse(data.sqlExecuteScalarString("select max(SEQUENCE) from SFT_OP_REALRUN where ID = '" + QR[0] + "'")) + 1;
                //An them vao de lam bao phe
                Sequence_OP_REAL_RUN = SEQUENCE;
                /////////////////////
                int SEQUENCE_SFT_WS_RUN     = int.Parse(data.sqlExecuteScalarString("select max(SEQUENCE) from SFT_WS_RUN where ID = '" + QR[0] + "'")) + 1;
                int SEQUENCE_SFT_WS_RUN_OUT = SEQUENCE_SFT_WS_RUN + 1;
                int Total = int.Parse(output) + int.Parse(NG);
                // string date = DateTime.Now.ToString("yyyyMMdd");
                // string month = DateTime.Now.ToString("yyyyMM");
                string month = date.Substring(0, 6);


                //insert  into SFT_OP_REALRUN
                StringBuilder sqlInsertSFT_OP_REALRUN = new StringBuilder();
                sqlInsertSFT_OP_REALRUN.Append(@"insert into SFT_OP_REALRUN ");
                sqlInsertSFT_OP_REALRUN.Append(@"(ID,SEQUENCE,OPID,OUTQTY,OUTTIME,ALERADYDEFECTQTY,");                             //1
                sqlInsertSFT_OP_REALRUN.Append(" DEFECTQTY,OPERID,OUTUNIT,ERP_OPSEQ,MANWORKTIME,COINSTYPE,");                      //2
                sqlInsertSFT_OP_REALRUN.Append("TOID,ERP_OPID,ERP_WSID,OR002,OR003,OR004,OR013,OR014,OR019,TOSN,");                //3
                sqlInsertSFT_OP_REALRUN.Append("STARTQTY,ENDQTY,REWORKQTY,FINISHRATE,OPDESCRIPTION,QTYPER,");                      //4
                sqlInsertSFT_OP_REALRUN.Append("OUTQTYPER,COMPLEXION,TA007,TA034,TA046,TA047,TA048,TA049,");                       //5
                sqlInsertSFT_OP_REALRUN.Append("TB068,TB070,TB087,OR009,PKUNIT,OR018,OR031,OR036,OR037,OR045,OR046,OR047,OR044,"); //6
                sqlInsertSFT_OP_REALRUN.Append("OR048,OR049,OR050,OR051,OR052,OR055,TB053,TB069,");                                //7
                sqlInsertSFT_OP_REALRUN.Append("TA050,TA051,PRODUCTION_REPORTID,PRODUCTION_REPORTSN,TB059,TB060,TB061,TB062,TB063,TB067)");
                sqlInsertSFT_OP_REALRUN.Append(" values ( ");

                sqlInsertSFT_OP_REALRUN.Append("'" + QR[0] + "'," + SEQUENCE + ",'B01---B01'," + output + ",'" + datetime + "'," + NG + ",");                //1
                sqlInsertSFT_OP_REALRUN.Append(NG + ",'BQC01','PCS','0010',500,'VND',");                                                                     //2
                sqlInsertSFT_OP_REALRUN.Append("'" + TOID + "','B01','B01','0020','B02','B01'," + SEQUENCE_SFT_WS_RUN_OUT + ",'BQC01'," + NG + ",'0001' ,"); //3
                sqlInsertSFT_OP_REALRUN.Append("0, 0,0,0,'',0,");                                                                                            //4
                sqlInsertSFT_OP_REALRUN.Append("1,1,NULL,NULL,'',0,0,NULL,");                                                                                //5
                sqlInsertSFT_OP_REALRUN.Append("0,0,'',0,'',0,1,0,0,'',0,'',0,");                                                                            //6
                sqlInsertSFT_OP_REALRUN.Append("0,0,'','',0,'N',0,'', ");                                                                                    //7
                sqlInsertSFT_OP_REALRUN.Append("NULL, NULL,'','','',0,'N', 'N', '1', 'N'");
                sqlInsertSFT_OP_REALRUN.Append(")");
                data.sqlExecuteNonQuery(sqlInsertSFT_OP_REALRUN.ToString(), false);

                //check from LOt table
                string sqlcheckLOT = "select count(*) from LOT where ID = '" + QR[0] + "'";
                if (int.Parse(data.sqlExecuteScalarString(sqlcheckLOT)) == 1)

                {
                    //insert into LOT table B02
                    StringBuilder sqlinsertSFT_LoT = new StringBuilder();
                    sqlinsertSFT_LoT.Append(@"insert into LOT ");
                    sqlinsertSFT_LoT.Append(" ( ID,TYPE,MOID,ITEMID,LOTSIZE,STATUS,ISPLANNED,UNIT,");
                    sqlinsertSFT_LoT.Append("QTYPER,ERP_OPSEQ,ERP_OPID,ERP_WSID,LOT004,LOT005,");
                    sqlinsertSFT_LoT.Append("RELEASEDATETIME,DUEDATETIME,PRIORITY,ROUTESEQ,STEPSEQ,ALTID,OPERATIONSEQ,EQUIPMENTID,OPERATEDTIME,REMAINTIME,MFGFLAG,");
                    sqlinsertSFT_LoT.Append("QTIME1,QTIME2,QTIME3,QTIME4,QTIME5,QTIME6,QTIME7,QTIME8, ISBANKORDER,RECIPEID, ");
                    sqlinsertSFT_LoT.Append("OUTPUTQTY,REMAININGTIME,LOTGROUP,PARTSISSUEDSTATUS,KEYVALUE,LOCKVALUE,PASSVALUE,PKUNIT)");
                    sqlinsertSFT_LoT.Append(" values ( ");
                    sqlinsertSFT_LoT.Append("'" + QR[0] + "',0,'" + QR[0] + "','" + ITEMID_TC047 + "'," + LOTSIZE_B02 + ",0,1,'PCS',");
                    sqlinsertSFT_LoT.Append("1,'0020','B02','B01',1,1,");
                    sqlinsertSFT_LoT.Append("NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,");
                    sqlinsertSFT_LoT.Append("NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,");
                    sqlinsertSFT_LoT.Append("NULL,NULL,NULL,NULL,NULL,NULL,NULL,''");
                    sqlinsertSFT_LoT.Append(")");
                    data.sqlExecuteNonQuery(sqlinsertSFT_LoT.ToString(), false);

                    //INSERT INTO LOT TABLE STATUS 50
                    StringBuilder sqlinsertSFT_LOT_50 = new StringBuilder();
                    sqlinsertSFT_LOT_50.Append("insert into LOT ");
                    sqlinsertSFT_LOT_50.Append(@"(ID, TYPE, MOID, ITEMID, LOTSIZE, STATUS, ISSUPPLY, ISPLANNED, ");
                    sqlinsertSFT_LOT_50.Append("UNIT, PKQTYPER, MO_SEQUENCE, HEAD_OP_SEQ, SUBMITFLAG,");
                    sqlinsertSFT_LOT_50.Append("ERP_OPSEQ, ERP_OPID, ERP_WSID, LOT004, LOT005, LOT007, LOT011,");
                    sqlinsertSFT_LOT_50.Append("RELEASEDATETIME,DUEDATETIME,PRIORITY,ROUTESEQ,STEPSEQ,ALTID,");
                    sqlinsertSFT_LOT_50.Append("OPERATIONSEQ,EQUIPMENTID,OPERATEDTIME,REMAINTIME,MFGFLAG,");
                    sqlinsertSFT_LOT_50.Append("QTIME1,QTIME2,QTIME3,QTIME4,QTIME5,QTIME6,QTIME7,QTIME8,ISBANKORDER,RECIPEID,");
                    sqlinsertSFT_LOT_50.Append("OUTPUTQTY,REMAININGTIME,LOTGROUP,PARTSISSUEDSTATUS,KEYVALUE,LOCKVALUE,PASSVALUE,QTYPER,PKUNIT)");
                    sqlinsertSFT_LOT_50.Append(" values ( ");
                    sqlinsertSFT_LOT_50.Append("'" + QR[0] + "',0,'" + QR[0] + "','" + ITEMID_TC047 + "',0,50,1,1,");
                    sqlinsertSFT_LOT_50.Append("'PCS',0,0,0,0,'0010','B01','B01',1,1,0,'N',");
                    sqlinsertSFT_LOT_50.Append("NULL,NULL,NULL,NULL,NULL,NULL,");
                    sqlinsertSFT_LOT_50.Append("NULL,NULL,NULL,NULL,NULL,");
                    sqlinsertSFT_LOT_50.Append("NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,");
                    sqlinsertSFT_LOT_50.Append("NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,''");
                    sqlinsertSFT_LOT_50.Append(")");
                    data.sqlExecuteNonQuery(sqlinsertSFT_LOT_50.ToString(), false);
                }
                else
                {
                    StringBuilder updateLOTB02 = new StringBuilder();
                    updateLOTB02.Append("update LOT set TYPE = 0, LOTSIZE =  LOTSIZE +" + output + "  where ID = '" + QR[0] + "' and ERP_OPSEQ = '0020' and ERP_OPID = 'B02' and STATUS !='50'");
                    data.sqlExecuteNonQuery(updateLOTB02.ToString(), false);
                }


                //insert into SFT_WS_RUN--Checkin

                StringBuilder sqlinsertSFT_WS_RUN_IN = new StringBuilder();
                sqlinsertSFT_WS_RUN_IN.Append(@"insert into SFT_WS_RUN ");
                sqlinsertSFT_WS_RUN_IN.Append("(WSID,OPID,ID,SEQUENCE,EXECUTETIME,EXECUTETYPE,EXECUTEQTY,USERID,");                                                 //1
                sqlinsertSFT_WS_RUN_IN.Append("QTYPERUNIT,UNIT,QTYPER,PLUSINDEX,ERP_OPSEQ,ERP_OPID,ERP_WSID,WR002,");                                               //2
                sqlinsertSFT_WS_RUN_IN.Append("WR003,WR004,WR005,WR007,WR008,WR009,WR021,");                                                                        //3
                sqlinsertSFT_WS_RUN_IN.Append(" WR026,CREATE_DATE,WR031,WR032,");                                                                                   //4
                sqlinsertSFT_WS_RUN_IN.Append("EQID,EXECUTENAME,UNITCOUNT,PKUNIT,WR006,WR012,WR013,WR016,WR033,WR035,WR001)");                                      //5
                sqlinsertSFT_WS_RUN_IN.Append(" values(");
                sqlinsertSFT_WS_RUN_IN.Append("'B01','B01---B01','" + QR[0] + "'," + SEQUENCE_SFT_WS_RUN + ",'" + datetime + "','checkIn'," + Total + ",'BQC01',"); //1
                sqlinsertSFT_WS_RUN_IN.Append("0,'',1,0,'0010','B01','B01','',");                                                                                   //2
                sqlinsertSFT_WS_RUN_IN.Append("''," + Total + "," + Total + ",'0020','B02','B01',NULL,");                                                           //3
                sqlinsertSFT_WS_RUN_IN.Append("NULL,'" + datetime + "',NULL,NULL,");                                                                                //4
                sqlinsertSFT_WS_RUN_IN.Append("'','','','',0,'','',0,NULL,'',-1");                                                                                  //5
                sqlinsertSFT_WS_RUN_IN.Append(")");
                data.sqlExecuteNonQuery(sqlinsertSFT_WS_RUN_IN.ToString(), false);                                                                                  //


                //insert into SFT_WS_RUN--CheckOUT
                StringBuilder sqlinsertSFT_WS_RUN_OUT = new StringBuilder();
                sqlinsertSFT_WS_RUN_OUT.Append(@"insert into SFT_WS_RUN ");
                sqlinsertSFT_WS_RUN_OUT.Append("(WSID,OPID,ID,SEQUENCE,EXECUTETIME,EXECUTETYPE,EXECUTEQTY,USERID,");                                                       //1
                sqlinsertSFT_WS_RUN_OUT.Append("QTYPERUNIT,QTYPER,PLUSINDEX,ERP_OPSEQ,ERP_OPID,ERP_WSID,WR002,");                                                          //2
                sqlinsertSFT_WS_RUN_OUT.Append("WR003,WR004,WR005,WR007,WR008,WR009,WR021,");                                                                              //3
                sqlinsertSFT_WS_RUN_OUT.Append(" WR026,CREATE_DATE,WR030,WR031,WR032,WR033,");                                                                             //4
                sqlinsertSFT_WS_RUN_OUT.Append("EQID,EXECUTENAME,UNITCOUNT,PKUNIT,UNIT,WR006,WR012,WR013,WR001,WR035,WR016)");                                             //5
                sqlinsertSFT_WS_RUN_OUT.Append(" values(");
                sqlinsertSFT_WS_RUN_OUT.Append("'B01','B01---B01','" + QR[0] + "'," + SEQUENCE_SFT_WS_RUN_OUT + ",'" + datetime + "','checkOut'," + output + ",'BQC01',"); //1
                sqlinsertSFT_WS_RUN_OUT.Append("0,1,0,'0010','B01','B01','" + TOID + "',");                                                                                //2
                sqlinsertSFT_WS_RUN_OUT.Append("'0001'," + output + "," + output + ",'0020','B02','B01','BQC01',");                                                        //3
                sqlinsertSFT_WS_RUN_OUT.Append("'" + datetime + "','" + datetime + "',1,0,0,'',");                                                                         //4
                sqlinsertSFT_WS_RUN_OUT.Append("'','','','','PCS',0,'','',-1,'',0");                                                                                       //5
                sqlinsertSFT_WS_RUN_OUT.Append(")");
                data.sqlExecuteNonQuery(sqlinsertSFT_WS_RUN_OUT.ToString(), false);



                //insert into SFT_TRANSORDER <có  duplicate key in object 'dbo.SFT_TRANSORDER'.>
                StringBuilder sqlinsertSFT_TRANSORDER = new StringBuilder();
                sqlinsertSFT_TRANSORDER.Append(@"insert into SFT_TRANSORDER ");
                sqlinsertSFT_TRANSORDER.Append("(CREATER,CREATE_DATE,FLAG,TRANSTYPE,TRANSNO,TRANSDATE,OUTTYPE,OUTDEPID,");
                sqlinsertSFT_TRANSORDER.Append("OUTDEPNAME,INTYPE,INDEPID,INDEPNAME,FACTORYID,CONFIRMCODE,DOCUMENTDATE,");
                sqlinsertSFT_TRANSORDER.Append("INVOICECOUNT,TAXATIONTYPE,DISCOUNTDEVIDE,DECLARATIONDATE,SALESTAXRATE,");
                sqlinsertSFT_TRANSORDER.Append("COMPANYID,KEYID,STOCKINTYPE,TO001,TO007,TO008,TO011,TO012,COINSTYPE,CONFIRMER,TO013,");
                sqlinsertSFT_TRANSORDER.Append("COMMENT,VENDORNO,INVOICEDATE,INVOICENO,MANUFACTURERORDERNO,TAXCODE,CREATOR,TO002,TO003,TO004,TO005,TO006,TO009,TO010)");
                sqlinsertSFT_TRANSORDER.Append(" values(");
                sqlinsertSFT_TRANSORDER.Append("'BQC01','" + datetime + "',0,'D201','" + TRANSNO + "','" + date + "','1','B01',");
                sqlinsertSFT_TRANSORDER.Append("'M+H生产线ONGM+H','1','B01','M+H生产线ONGM+H','TL','Y','" + date + "',");
                sqlinsertSFT_TRANSORDER.Append("'1','1','1','" + month + "','0.2',");
                sqlinsertSFT_TRANSORDER.Append("'TECHLINK','" + QR[0] + "','0','1','D201','" + TO008 + "',0,0,'VND','BQC01',1,");
                sqlinsertSFT_TRANSORDER.Append("'','','','','','','','','','','','','',''");
                sqlinsertSFT_TRANSORDER.Append(")");
                data.sqlExecuteNonQuery(sqlinsertSFT_TRANSORDER.ToString(), false);


                //insert into SFT_TRANSORDER_LINE

                int PRODUCTIONSEQ_SFT_TRANSORDER_LINE = int.Parse(data.sqlExecuteScalarString("select max(PRODUCTIONSEQ) from SFT_TRANSORDER_LINE where KEYID = '" + QR[0] + "'"));
                if (PRODUCTIONSEQ_SFT_TRANSORDER_LINE == -1)
                {
                    PRODUCTIONSEQ_SFT_TRANSORDER_LINE = 0;
                }
                PRODUCTIONSEQ_SFT_TRANSORDER_LINE++;
                StringBuilder sqlinsertSFT_TRANSORDER_LINE = new StringBuilder();
                sqlinsertSFT_TRANSORDER_LINE.Append(@"insert into SFT_TRANSORDER_LINE ");
                sqlinsertSFT_TRANSORDER_LINE.Append("(CREATE_DATE,TRANSORDERTYPE,TRANSNO,SN,MOTYPE,MONO,OUTOPSEQ,");     //1
                sqlinsertSFT_TRANSORDER_LINE.Append("OUTOP,INOPSEQ,INOP,UNIT,PATTERN,SCRAPQTY,LABORHOUR,MACHINEHOUR,");  //2
                sqlinsertSFT_TRANSORDER_LINE.Append("OUTDEP,EMERGENCY,TRANSQTY,INDEP,ITEMID,ITEMNAME,");                 //3
                sqlinsertSFT_TRANSORDER_LINE.Append("TC015,TC017,TC018,TC019,KEYID,PRODUCTIONSEQ,TL002,TL003,TL004,");   //4
                sqlinsertSFT_TRANSORDER_LINE.Append("TL005,TL006,SFTUPDATE,TC055,TL007,TL008,TL010,TL011,TL012,TL015,"); //5
                sqlinsertSFT_TRANSORDER_LINE.Append("TL016,SPC,TWINUNIT,KEY_TRANSORDER,FACTORYID,INWSTYPE,OUTWSTYPE,");  //6
                sqlinsertSFT_TRANSORDER_LINE.Append("TL017,TL018,TL023,TL024,TL025,TL029,TL027,");                       //7
                sqlinsertSFT_TRANSORDER_LINE.Append("OUTORDERTYPE,OUTORDERNO,OUTORDERSEQ,LOTNO,ITEMDESCRIPTION,INSTORAGESPACE,TC012,TC024,TC040,NOTE, TL001,TC039,TC057,TL009,TL014,TL026)");
                sqlinsertSFT_TRANSORDER_LINE.Append(" values(");
                sqlinsertSFT_TRANSORDER_LINE.Append("'" + datetime + "','D201','" + TRANSNO + "','0001','" + ML[0] + "','" + ML[1] + "','0010',"); //1
                sqlinsertSFT_TRANSORDER_LINE.Append("'B01','0020','B02','PCS','1'," + NG + ",0,0,");                                               //2
                sqlinsertSFT_TRANSORDER_LINE.Append("'B01','N'," + Total + ",'B01','" + ITEMID_TC047 + "','" + ITEMNAME_TC048 + "',");             //3
                sqlinsertSFT_TRANSORDER_LINE.Append("0,0,0,'0','" + QR[0] + "'," + PRODUCTIONSEQ_SFT_TRANSORDER_LINE + "," + output + ",0,0,");    //4
                sqlinsertSFT_TRANSORDER_LINE.Append("0,'0',0,'0',0,0,'" + date + "','D201','" + TO008 + "'," + SEQUENCE_SFT_WS_RUN_OUT + ",");     //5
                sqlinsertSFT_TRANSORDER_LINE.Append("0,'N','Y',1,'TL','1','1',");                                                                  //6
                sqlinsertSFT_TRANSORDER_LINE.Append("'0',1,0,0,0,'N',0,");                                                                         //7
                sqlinsertSFT_TRANSORDER_LINE.Append("'','','','','" + ITEMDESCRIPTION + "','','','','','','','','','','',''");
                sqlinsertSFT_TRANSORDER_LINE.Append(")");
                data.sqlExecuteNonQuery(sqlinsertSFT_TRANSORDER_LINE.ToString(), false);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, " InsertdataToSFT(string barcode, string output, string NG)", ex.Message);
            }
        }
コード例 #18
0
ファイル: DefectClass.cs プロジェクト: tranducan/MESDb2ERP
        public bool InsertDefect2SFT_OP_EXCEPT(string _ID, int _SEQUENCE, int _EXCEPTQTY, string _OPID, string _USERID,
                                               string _EXCEPTTYPE, string _EXCEPTGROUP, string _EXCEPTREASON, string _ERP_OPSEQ, string _ERP_OPID, int _PKQTY, int _PKQTYPER)
        {
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append(" insert into SFT_OP_EXCEPT ");
                sql.Append(@"(
ID,
SEQUENCE,
EXCEPTQTY,
OPID,
EQID,
USERID,
ROUTESEQUENCE,
STEPSEQUENCE,
ALTSTEPSEQUENCE,
OPSEQUENCE,
EXCEPTTYPE,
EXCEPTGROUP,
EXCEPTREASON,
OPERID,
WSID,
TRANSORDERID,
ERP_OPSEQ,
ERP_OPID,
ERP_WSID,
PKQTY,
PKQTYPER,
PKUNIT,
UNIID,
OE001,
OE002,
OE003,
OE004,
OE005,
OE006 
 )");
                sql.Append(" values ( ");
                sql.Append("'" + _ID + "',");
                sql.Append("" + _SEQUENCE + ",");
                sql.Append("" + _EXCEPTQTY + ",");
                sql.Append("'" + _OPID + "',");
                sql.Append("'" + "" + "',");
                sql.Append("'" + _USERID + "',");
                sql.Append("NULL,NULL,NULL,NULL,");
                sql.Append("'" + _EXCEPTTYPE + "',");
                sql.Append("'" + _EXCEPTGROUP + "',");
                sql.Append("'" + _EXCEPTREASON + "',");
                sql.Append("'" + _USERID + "',");
                sql.Append("NULL,NULL,");
                sql.Append("'" + _ERP_OPSEQ + "',");
                sql.Append("'" + _ERP_OPID + "',");
                sql.Append("'" + _ERP_OPID + "',");
                sql.Append("" + _PKQTY + ",");
                sql.Append("" + _PKQTYPER + ",");
                sql.Append("'" + "" + "',");
                sql.Append("NULL,");
                sql.Append("'" + "" + "',");
                sql.Append("NULL,NULL,NULL,NULL,NULL");
                sql.Append(" )");

                string sql2 = sql.ToString();

                sqlSFT sQLCommon = new sqlSFT();
                sQLCommon.sqlExecuteNonQuery(sql.ToString(), false);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, " InsertDefect2SFT_OP_EXCEPT()", ex.Message);
                return(false);
            }
            return(true);
        }
コード例 #19
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);
            }
        }