コード例 #1
0
 static int countItem = 10; //typeof(Class_ExportFG_WareHouse).GetProperties().Count();// HAVE CHANGE IF REAL DATA
 static public bool IsCorrectFormat(string txtInput)
 {
     string[] ListCurrentItem = System.Text.RegularExpressions.Regex.Replace(txtInput, " ", "").Split(';');
     if (txtInput.Trim().StartsWith("s") != true)
     {
         ClassMessageBoxUI.Show("QR code not start with \"s\" ", false);
         return(false);
     }
     if (txtInput.Trim().EndsWith("e") != true)
     {
         ClassMessageBoxUI.Show("QR code not end with \"e\" ", false);
         return(false);
     }
     if (ListCurrentItem[ListCurrentItem.Count() - 1].Trim() != "*e")
     {
         ClassMessageBoxUI.Show("You can't use this QR code. Please contact your admin!", false);
         return(false);
     }
     if (ListCurrentItem.Count() < countItem)
     {
         ClassMessageBoxUI.Show(string.Format("QR input not enough item spec > {0}, current {1}", countItem, ListCurrentItem.Count()), false);
         return(false);
     }
     return(true);
 }
        public bool UpdateDataDBForFinishedGoods(DataTable dtERPPQC, out string ERPDoc)
        {
            try
            {
                ERPDoc = "";
                //Class.valiballecommon.GetStorage().DocNo
                ERPDataUpdate eRPDataUpdate = new ERPDataUpdate();
                string        TB002         = eRPDataUpdate.getTB002(Class.valiballecommon.GetStorage().DocNo); //fix
                //string TB002 = eRPDataUpdate.getTF002(Class.valiballecommon.GetStorage().DocNo);//fix disable 22/12/2020

                ConvertDataTable convertDataTable = new ConvertDataTable();
                ConvertDataERP   convertDataERP   = new ConvertDataERP();
                DataTable        dtSFCTC          = convertDataERP.GetDataTableSFCTC(dtERPPQC, TB002, "Y");
                DataTable        dtSFCTB          = convertDataERP.GetDataTableSFCTB(dtSFCTC, dtERPPQC, "", "Y");// NO SFT
                DataTable        dtMOCTG          = convertDataERP.GetDataTableMOCTG(dtERPPQC, TB002);
                DataTable        dtMOCTF          = convertDataERP.GetDataTableMOCTF(dtMOCTG, TB002);
                if (dtSFCTC.Rows.Count > 0 && dtMOCTG.Rows.Count > 0 && dtMOCTF.Rows.Count > 0)
                {
                    Database.SFC.SFCTC sFCTC = new Database.SFC.SFCTC();
                    var InsertSFCTC          = sFCTC.InsertData(dtSFCTC);
                    if (InsertSFCTC == false)
                    {
                        MessageBox.Show("Insert SFCTC fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                    Database.SFC.SFCTB sFCTB = new Database.SFC.SFCTB();
                    var InsertSFCTB          = sFCTB.InsertData(dtSFCTB);
                    if (InsertSFCTB == false)
                    {
                        MessageBox.Show("Insert SFCTB fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                    Database.SFC.SFCTA sFCTA = new Database.SFC.SFCTA();
                    var UpdateSFCTA          = sFCTA.UpdateSFCTAForFinishedGoods(dtERPPQC);           // UPDATE SO LUONG
                    if (UpdateSFCTA == false)
                    {
                        MessageBox.Show("Insert SFCTA fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }

                    Database.MOC.MOCTG mOCTG = new Database.MOC.MOCTG();
                    var insertMoctg          = mOCTG.InsertData(dtMOCTG);
                    if (insertMoctg == false)
                    {
                        ClassMessageBoxUI.Show("Insert MOCTG fail ", false);
                        return(false);
                    }

                    Database.MOC.MOCTF mOCTF = new Database.MOC.MOCTF();
                    var insertMOCTF          = mOCTF.InsertData(dtMOCTF);
                    if (insertMOCTF == false)
                    {
                        ClassMessageBoxUI.Show("Insert MOCTF fail ", false);
                        return(false);
                    }
                    Database.MOC.MOCTA mOCTA = new Database.MOC.MOCTA();
                    var updateMOCTA          = mOCTA.UpdateMOCTAForFinishedGoods(dtERPPQC);
                    if (updateMOCTA == false)
                    {
                        ClassMessageBoxUI.Show("update MOCTA fail ", false);
                        return(false);
                    }
                    UpdateWarehouseForFinishedGoods updateWarehouseForFinishedGoods = new UpdateWarehouseForFinishedGoods();
                    var UpdateWarehouse = updateWarehouseForFinishedGoods.UpdateWarehouse(dtERPPQC, TB002);
                    if (UpdateWarehouse == false)
                    {
                        ClassMessageBoxUI.Show("update stock warehouse fail ", false);
                    }
                }
                ERPDoc = TB002;
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateData2DBForFinishedGoods(FinishedGoodsItems fgItems)", ex.Message);
                ERPDoc = "";
                return(false);
            }
            return(true);
        }