Пример #1
0
        public string GetTC002()
        {
            string    _TC002           = "";
            string    dateFormat       = DateTime.Now.ToString("yyMM");
            string    countFormatReset = "0001";
            int       countUp          = 0;
            sqlERPCON data             = new sqlERPCON();
            string    strData          = data.sqlExecuteScalarString("select max(TB002) from SFCTB where TB001 = 'D201'  ");

            if (strData != null && strData.Trim().Count() == 8)
            {
                string DateDatabase = strData.Trim().Substring(0, 4);
                string strCount     = strData.Trim().Substring(4);
                if (dateFormat == DateDatabase)
                {
                    countUp = int.Parse(strCount) + 1;
                    string countFormatup = countUp.ToString("0000");
                    _TC002 = dateFormat + countFormatup;
                }
                else
                {
                    _TC002 = dateFormat + countFormatReset;
                }
            }

            return(_TC002);
        }
Пример #2
0
        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);
            }
        }