Ejemplo n.º 1
0
        public DataTable GetDataTableLOTbyERP(DataRow dtERPPQC, int status)
        {
            DataTable dt = new DataTable();

            try
            {
                string PO = dtERPPQC["ProductOrder"].ToString();
                dt = Database.SFT.SFT_LOT.GetDataTableLot(PO);
                if (dt.Rows.Count == 1)
                {
                    dt.Rows[0]["LOTSIZE"] = dtERPPQC["Quantity"];
                    if (status == 99)
                    {
                        dt.Rows[0]["STATUS"]    = status;
                        dt.Rows[0]["ERP_OPSEQ"] = "";
                        dt.Rows[0]["ERP_OPID"]  = "";
                        dt.Rows[0]["ERP_WSID"]  = "";
                    }
                    else if (status == 130)
                    {
                        dt.Rows[0]["STATUS"]    = status;
                        dt.Rows[0]["ERP_OPSEQ"] = "0020";
                        dt.Rows[0]["ERP_OPID"]  = "B02";
                        dt.Rows[0]["ERP_WSID"]  = "B01";
                    }
                    dt.Rows[0]["ISSUPPLY"]             = 1;
                    dt.Rows[0]["ISPLANNED"]            = 1;
                    dt.Rows[0]["LOT004"]               = 1;
                    dt.Rows[0]["LOT005"]               = 1;
                    dt.Rows[0]["LOT005"]               = 1;
                    dt.Rows[0]["PKQTY"]                = double.Parse(dt.Rows[0]["PKQTYPER"].ToString()) * double.Parse(dtERPPQC["Quantity"].ToString());
                    dt.Rows[0]["QTIME1"]               = DBNull.Value;
                    dt.Rows[0]["QTIME2"]               = DBNull.Value;
                    dt.Rows[0]["QTIME3"]               = DBNull.Value;
                    dt.Rows[0]["QTIME4"]               = DBNull.Value;
                    dt.Rows[0]["QTIME5"]               = DBNull.Value;
                    dt.Rows[0]["QTIME6"]               = DBNull.Value;
                    dt.Rows[0]["QTIME7"]               = DBNull.Value;
                    dt.Rows[0]["QTIME8"]               = DBNull.Value;
                    dt.Rows[0]["LASTMAINTAINDATETIME"] = DBNull.Value;
                    dt.Rows[0]["DUEDATETIME"]          = DBNull.Value;
                    dt.Rows[0]["RELEASEDATETIME"]      = DBNull.Value;
                }
            }

            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "DataTable GetDataTableLOT(DataTable ERPPQC,DataTable TRansOrderLine)", ex.Message);
                dt = new DataTable();
            }
            return(dt);
        }
Ejemplo n.º 2
0
 public void WritebittoPLC(bool value, int db, int start, int size)
 {
     try
     {
         byte[] buffer = new byte[1];
         Sharp7.S7.SetBitAt(buffer, 0, 0, value);
         Client.DBWrite(db, start, size, buffer);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "Write bit to PLC fail", ex.Message);
     }
 }
Ejemplo n.º 3
0
 private void btn_search_Click(object sender, EventArgs e)
 {
     try
     {
         Database.ERPSOFT.t_ExportFGoods t_ExportFGoods = new Database.ERPSOFT.t_ExportFGoods();
         dtExportSummary = t_ExportFGoods.GetDataTableExportSummary(dtpk_from.Value, dtpk_to.Value, (bool)rd_exportDate.Checked);
         dtgv_ExportSummary.DataSource = dtExportSummary;
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "Can't get data import summary", ex.Message);
     }
 }
Ejemplo n.º 4
0
 public void WriteDinttoPLC(int value, int db, int start, int size)
 {
     try
     {
         byte[] buffer = new byte[2];
         Sharp7.S7.SetWordAt(buffer, 0, ushort.Parse(value.ToString()));
         Client.WriteArea(S7Area.DB, db, start, 2, S7WordLength.Byte, buffer);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "Write Dint to PLC fail", ex.Message);
     }
 }
 public void InsertProductInforToDBbymodel(string model)
 {
     try
     {
         DataTable dtGetINMB    = Database.INV.INVMB.GetProductInforbyModel(model);
         DataTable dtdata       = ConvertDataTable(dtGetINMB);
         var       insertResult = InsertData(dtdata);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertProductInforToDB()", ex.Message);
     }
 }
        private void M_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
                string ItemClick = e.ClickedItem.ToString();
                if (ItemClick == "Defect Export")
                {
                    Class.ToolSupport toolSupport = new Class.ToolSupport();
                    var    dataRow   = dtgv_data.Rows[RowIndexClick].DataBoundItem as MQCItemSummary;
                    string pathsave  = "";
                    string pathMonth = Environment.CurrentDirectory + @"\Resources\Month.xls";

                    System.Windows.Forms.SaveFileDialog saveFileDialog = new SaveFileDialog();

                    saveFileDialog.Title      = "Browse Excel Files";
                    saveFileDialog.DefaultExt = "Excel";
                    saveFileDialog.Filter     = "Excel files (*.xlsx)|*.xlsx";

                    saveFileDialog.CheckPathExists = true;

                    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        pathsave = saveFileDialog.FileName;

                        saveFileDialog.RestoreDirectory = true;

                        toolSupport.ExportToTemplateTop5Defect(pathMonth, pathsave, dataRow);
                        var resultMessage = MessageBox.Show("Production Plan export to excel sucessful ! \n\r Do you want to open this file ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (resultMessage == DialogResult.Yes)
                        {
                            FileInfo fi = new FileInfo(pathsave);
                            if (fi.Exists)
                            {
                                System.Diagnostics.Process.Start(pathsave);
                            }
                            else
                            {
                                MessageBox.Show("File doestn't exist !", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                }
                else if (ItemClick == "Rework Export")
                {
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, " M_ItemClicked(object sender, ToolStripItemClickedEventArgs e)", ex.Message);
            }
        }
Ejemplo n.º 7
0
 public static string GetDescribeDocNo(string DocNo)
 {
     try
     {
         string   m_query_CMSMQ = @"select distinct a.MQ002 from CMSMQ a where a.MQ001 ='" + DocNo.ToString() + "'";
         SqlTLVN2 sqlTLVN2      = new SqlTLVN2();
         return(sqlTLVN2.sqlExecuteScalarString(m_query_CMSMQ));
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "string GetDescribeDocNo()", ex.Message);
         return(null);
     }
 }
Ejemplo n.º 8
0
        public int Diconnect()
        {
            int Result = -1;

            try
            {
                Result = Client.Disconnect();
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Diconnect PLC fail", ex.Message);
            }
            return(Result);
        }
 private void Btn_GenerateLocation_Click(object sender, EventArgs e)
 {
     try
     {
         PritingLabel pritingLabel = new PritingLabel();
         string       QRInfor      = txt_warehouse.Text + ";" + txt_location.Text + ";" + txt_Rack.Text;
         var          name         = ListInforWhs.Where(d => d.WH == txt_warehouse.Text.Trim()).Select(d => d.Name).ToList()[0];
         pritingLabel.PrintQRCode(QRInfor, name);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "Btn_Generate_Click(object sender, EventArgs e)", ex.Message);
     }
 }
Ejemplo n.º 10
0
        public bool ExportListSeasonalEmployee(string pathSave, Dictionary <string, Model.MonthInOut> DicSeasonalEmp)
        {
            Excel.Application xlApp;
            Excel.Workbook    xlWorkBook;
            Excel.Worksheet   xlWorkSheet; //sheet 2
                                           //Excel.Worksheet xlWorkSheet1; //sheet 1
            object misValue = System.Reflection.Missing.Value;

            try
            {
                xlApp            = new Excel.Application();
                xlWorkBook       = xlApp.Workbooks.Open(PathTemplateForm5Common, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlWorkSheet      = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); //add data sheet1
                xlWorkSheet.Name = DicSeasonalEmp.Values.ToList()[0].dept;
                for (int i = 0; i < DicSeasonalEmp.Count; i++)
                {
                    var EmpFinger = DicSeasonalEmp.Keys.ToList()[i];
                    xlWorkSheet.Cells[2 * i + 7, "A"] = i + 1;
                    xlWorkSheet.Cells[2 * i + 7, "B"] = DicSeasonalEmp[EmpFinger].EmpCode;
                    xlWorkSheet.Cells[2 * i + 7, "C"] = DicSeasonalEmp[EmpFinger].Name;
                    for (int k = 0; k < 31; k++)
                    {
                        if (DicSeasonalEmp[EmpFinger].InOutEvaluation[k] != null)
                        {
                            if (DicSeasonalEmp[EmpFinger].Shift[k].Contains("Day"))
                            {
                                xlWorkSheet.Cells[2 * i + 7, 7 + k] = DicSeasonalEmp[EmpFinger].WorkingTime[k];
                            }
                            else if (DicSeasonalEmp[EmpFinger].Shift[k].Contains("Night"))
                            {
                                xlWorkSheet.Cells[2 * i + 7 + 1, 7 + k] = DicSeasonalEmp[EmpFinger].WorkingTime[k];
                            }
                        }
                    }
                    //     CountPlusRow = CountPlusRow + 2;
                }
                xlWorkBook.SaveAs(pathSave, Excel.XlFileFormat.xlWorkbookDefault, misValue, misValue, misValue,
                                  misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                xlWorkBook.Close();
                xlApp.Quit();
                reOject(xlWorkSheet);
                reOject(xlApp);
                return(true);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, " ExportListSeasonalEmployee(string pathSave, Dictionary<string, Model.MonthInOut> DicSeasonalEmp)", ex.Message);
            }
            return(false);
        }
        public List <ItemMaterial> ListMaterial(string MaBP)
        {
            List <ItemMaterial> itemMaterials = new List <ItemMaterial>();
            DateTime            date          = DateTime.Now.AddDays(0).Date;

            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                // stringBuilder.Append()

                stringBuilder.Append(@"select distinct TC004,TC005,TC007,TC047,TB003 from SFCTC a
inner join SFCTB on TC001 = TB001 and TC002 = TB002
 where 1=1 ");

                stringBuilder.Append("and CONVERT(date, TB003) >=  '" + date.ToString("yyyyMMdd") + "'");

                sqlERPCON sql = new sqlERPCON();
                DataTable dt  = new DataTable();
                sql.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt);
                var InforProduction = (from DataRow dr in dt.Rows
                                       select new ItemMaterial()
                {
                    deptCode = dr["TC007"].ToString(),
                    IDCode = dr["TC004"].ToString(),
                    IDName = dr["TC005"].ToString(),
                    ID = dr["TC004"].ToString() + "-" + dr["TC005"].ToString(),
                    Product = dr["TC047"].ToString(),
                    DateRun = (dr["TB003"].ToString() != "") ? DateTime.Parse(dr["TB003"].ToString().Insert(4, "-").Insert(7, "-")) : DateTime.MinValue
                }).ToList();
                //      itemMaterials = InforProduction;
                bool ISNVL = false;
                List <MaterialItems> materialAdapts = new List <MaterialItems>();
                foreach (var item in InforProduction)
                {
                    Material material   = new Material();
                    var      IsCheckNVL = material.IsMaterialOK(item.IDCode, item.IDName, out ISNVL, out materialAdapts);

                    if (ISNVL == false)
                    {
                        item.MaterialAdapts = materialAdapts;
                        itemMaterials.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "List<ItemMaterial> ListMaterial (string MaBP)", ex.Message);
            }
            return(itemMaterials);
        }
Ejemplo n.º 12
0
        public static bool IscheckQantityAndWeight(string product, string productCode, double Quantity, double Weight)
        {
            try
            {
                DataTable     dt            = new DataTable();
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(@"select ISNULL(TA015,0) as TA015,ISNULL(TA017,0) as TA017,ISNULL(TA018,0) as TA018,ISNULL(TA045,0) as TA045,ISNULL(TA046,0) as TA046,ISNULL(TA047,0) as TA047
from MOCTA where 1 =1 ");
                stringBuilder.Append(" and TA001 ='" + productCode.Split('-')[0] + "' ");
                stringBuilder.Append(" and TA002 ='" + productCode.Split('-')[1] + "' ");
                SqlTLVN2 sqlTLVN2 = new SqlTLVN2();
                sqlTLVN2.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt);
                if (dt.Rows.Count == 1)
                {
                    double TA015 = double.Parse(dt.Rows[0]["TA015"].ToString());
                    double TA017 = double.Parse(dt.Rows[0]["TA017"].ToString());
                    double TA018 = double.Parse(dt.Rows[0]["TA018"].ToString());
                    double TA045 = double.Parse(dt.Rows[0]["TA045"].ToString());
                    double TA046 = double.Parse(dt.Rows[0]["TA046"].ToString());
                    double TA047 = double.Parse(dt.Rows[0]["TA047"].ToString());

                    if (TA015 < TA017 + TA018 + Quantity)
                    {
                        return(false);
                    }
                    else if (TA045 < TA046 + TA047 + Weight)
                    {
                        string value = INV.INVMB.IsWeightValue(product);
                        if (value == "KG" || value == "kg")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "IscheckQantityAndWeight(string productCode, double Quantity, double Weight)", ex.Message);
            }
            return(false);
        }
Ejemplo n.º 13
0
 void bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     try
     {
         FoundShortageMaterial();
         if (dtgv_material.Rows.Count > 0)
         {
             this.WindowState = FormWindowState.Maximized;
         }
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "LoadDataERPMQCToShow()", ex.Message);
     }
 }
Ejemplo n.º 14
0
 /// <summary>
 ///  this function for add new "-" production order
 /// </summary>
 /// <param name="text"></param>
 /// <returns></returns>
 static string ReturnProductOrder(string text)
 {
     try
     {
         if (text.ToCharArray().Count() > 4)
         {
             return(text.Substring(0, 4) + "-" + text.Substring(4));
         }
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "ReturnProductOrder: ", ex.Message);
     }
     return(null);
 }
Ejemplo n.º 15
0
 public static void UpdateQRcodeByQR(string QRcode)
 {
     try
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.Append("update t_QRImport set Status ='1' ");
         stringBuilder.Append(" WHERE IDQRCODE = '" + QRcode.Trim() + "'");
         sqlCON sqlTLVN2 = new sqlCON();
         sqlTLVN2.sqlExecuteNonQuery(stringBuilder.ToString(), false);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateQRcode", ex.Message);
     }
 }
Ejemplo n.º 16
0
 public void Disconnect()
 {
     try
     {
         if (plcDriver == null || this.ConnectionState == ConnectionStates.Offline)
         {
             return;
         }
         plcDriver.Disconnect();
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "Connect(string ipAddress) ", ex.Message);
     }
 }
Ejemplo n.º 17
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);
     }
 }
Ejemplo n.º 18
0
        public int isConnectionPLC()
        {
            int Result = -1;

            try
            {
                Result = Client.ConnectTo(_IP, _Rack, _Slot);
                return(Result);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Connection PLC Error", ex.Message);
            }
            return(Result);
        }
        public bool PrintQRCodeWarehouse(WMS.Model.WarehouseInfor infor)
        {
            try
            {
                if (!ConnectPrinter())
                {
                    return(false);
                }

                int multiplier = 1;
                // 203 DPI : 1mm is about 7.99 dots
                // 300 DPI : 1mm is about 11.81 dots
                // 600 DPI : 1mm is about 23.62 dots
                int resolution = BXLLApi.GetPrinterDPI();
                int dotsPer1mm = (int)Math.Round((float)resolution / 25.4f);
                if (resolution >= 600)
                {
                    multiplier = 3;
                }

                SendPrinterSettingCommand();


                BXLLApi.PrintTrueFontW(2 * dotsPer1mm, 3 * dotsPer1mm, "Arial", 24, 0, true, true, false, "Warehouse: " + infor.Warehouse, false);

                BXLLApi.PrintBlock(1 * dotsPer1mm, 6 * dotsPer1mm, 45 * dotsPer1mm, 7 * dotsPer1mm, (int)SLCS_BLOCK_OPTION.LINE_OVER_WRITING, 0);
                BXLLApi.PrintDeviceFont(6 * dotsPer1mm, 10 * dotsPer1mm, (int)SLCS_DEVICE_FONT.ENG_24X38, multiplier, multiplier, (int)SLCS_ROTATION.ROTATE_0, false, "Material: " + infor.Material);
                BXLLApi.PrintDeviceFont(6 * dotsPer1mm, 14 * dotsPer1mm, (int)SLCS_DEVICE_FONT.ENG_24X38, multiplier, multiplier, (int)SLCS_ROTATION.ROTATE_0, false, "Lot: " + infor.Lot);
                BXLLApi.PrintDeviceFont(6 * dotsPer1mm, 18 * dotsPer1mm, (int)SLCS_DEVICE_FONT.ENG_24X38, multiplier, multiplier, (int)SLCS_ROTATION.ROTATE_0, false, "Quantity: " + infor.quantity.ToString("N3") + " " + infor.Unit);
                BXLLApi.PrintDeviceFont(6 * dotsPer1mm, 22 * dotsPer1mm, (int)SLCS_DEVICE_FONT.ENG_24X38, multiplier, multiplier, (int)SLCS_ROTATION.ROTATE_0, false, "Expiry Date: " + infor.expiryDate.ToString("dd/MM/yyyy"));

                string QRCode_data = infor.Warehouse + ";" + infor.Material + ";" + infor.Lot + ";" + infor.quantity + ";" + infor.ImportDate.ToString("ddMMyyyy") + ";" + infor.expiryDate.ToString("ddMMyyyy");
                BXLLApi.PrintQRCode(47 * dotsPer1mm, 25 * dotsPer1mm, (int)SLCS_QRCODE_MODEL.QRMODEL_2, (int)SLCS_QRCODE_ECC_LEVEL.QRECCLEVEL_H, (int)SLCS_QRCODE_SIZE.QRSIZE_9, (int)SLCS_ROTATION.ROTATE_0, QRCode_data);


                //	Print Command
                BXLLApi.Prints(1, 1);

                // Disconnect printer
                BXLLApi.DisconnectPrinter();
                return(true);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "print label fail", ex.Message);
                return(false);
            }
        }
Ejemplo n.º 20
0
        public bool InsertRowMQVariables(Model.MQCVariable mQCVariable, string data, string line, string item)
        {
            try
            {
                string    datetimeserno = DateTime.Now.ToString("yyyyMMdd_HHmmss");
                string    serno         = mQCVariable.QRMES;
                QRMQC_MES qRMQC_MES     = QRSpilittoClass.QRstring2MQCFormat(mQCVariable.QRMES);
                QRIDMES   qRIDMES       = QRSpilittoClass.QRstring2IDFormat(mQCVariable.QRID);
                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 Remark    = "";
                if (item == "OUTPUT")
                {
                    Remark = "OP";
                }
                else if (item.Contains("NG"))
                {
                    Remark = "NG";
                }
                else if (item.Contains("RW"))
                {
                    Remark = "RW";
                }
                else if (item.Contains("Reset"))
                {
                    Remark = "Reset";
                }
                // string model = GetModelFromLot(lot,setting);
                string model = qRMQC_MES.Product;// lay model tren server, neu ko lay dc thi lay o local

                sqlQuerry += "insert into t_mqc_realtime (serno, lot, model, site, factory, line, process,item,inspectdate,inspecttime, data, judge,status,remark,inspector,TL01 ) values( '";
                sqlQuerry += serno + "', '" + qRMQC_MES.PO + "', '" + model + "', '" + site + "', '" + factory + "', '" + line +
                             "', '" + process + "', '" + item + "', '" + date_ + "', '" + time_ + "', '" + data + "', '" + "" + "', '" + status + "', '" + Remark + "' , '" + qRIDMES.ID + "', '" + qRIDMES.FullName + "' )";
                MysqlMES mysqlMES = new MysqlMES();
                return(mysqlMES.sqlExecuteNonQuery(sqlQuerry, false));
            }
            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);
            }
        }
Ejemplo n.º 21
0
        public DataTable GetDataProductionOrder2(DateTime todate)
        {
            try
            {
                // DateTime dtnow = DateTime.Now;
                //DateTime datefrom = new DateTime(dtnow.Year, 1, 1);
                DateTime dateto = todate;
                dtShipping = new DataTable();
                StringBuilder sql = new StringBuilder();
                sql.Append(@"select
coptcs.TC001 as Code_Type, 
coptcs.TC002 as Code_No,
cmsmes.ME002 as Department_code,
copmas.MA002 as Clients_Name,
coptcs.TC012 as Clients_Order_Code,
coptds.TD004 as Product_Code,
coptds.TD005 as Product_Name,
coptds.TD010 as Unit,
coptcs.TC005 as Department,
coptds.TD013 as Client_Request_Date,
coptds.TD008 as Order_Quantity,
coptds.TD009 as Shipped_Quantity,
coptds.TD016 as StatusOFCode,
invmbs.MB064 as Stock_Qty,
coptds.TD003 as STT
 from COPTC coptcs
left join COPTD  coptds on coptcs.TC002 = coptds.TD002  and coptcs.TC001 = coptds.TD001 -- cong doan tao don
inner join COPMA copmas on copmas.MA001 = coptcs.TC004
left join INVMB invmbs on invmbs.MB001 = coptds.TD004
left join CMSME cmsmes on cmsmes.ME001 = coptcs.TC005
where 1=1  
and  coptcs.TC027 = 'Y' and coptds.TD016  ='N' and coptds.TD009 < coptds.TD008
 ");


                //  sql.Append(" and CONVERT(date,coptds.TD013)  >= '" + datefrom + "' ");
                sql.Append(" and CONVERT(date,coptds.TD013) <= '" + dateto.ToString("yyyyMMdd") + "' ");

                sql.Append("order by coptds.TD013");
                sqlERPCON con = new sqlERPCON();
                con.sqlDataAdapterFillDatatable(sql.ToString(), ref dtShipping);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "GetDataProductionOrder() : ", ex.Message);
            }
            return(dtShipping);
        }
Ejemplo n.º 22
0
        public bool UpdateINVMC(Model.INVItems iNVItems, DataTable dtCommonERP)
        {
            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(" update INVMC ");
                stringBuilder.Append(" set MODIFIER = '" + Class.valiballecommon.GetStorage().UserName + "', ");
                stringBuilder.Append("  MODI_DATE = '" + DateTime.Now.ToString("yyyyMMdd") + "', ");
                stringBuilder.Append("  FLAG = FLAG+1 ,  ");
                stringBuilder.Append("  MODI_TIME = '" + DateTime.Now.ToString("HH:mm:ss") + "' ,");
                stringBuilder.Append("  MODI_AP = '" + "SFT" + "' ,");
                stringBuilder.Append("  MODI_PRID = '" + "MOCI05" + "' ,");
                if (iNVItems.TypeInportExport == "1")                //nhap kho
                {
                    stringBuilder.Append("  MC007 = MC007 + " + iNVItems.Quantity + " ,");
                    stringBuilder.Append("  MC014 = MC014 + " + iNVItems.PackageQty + " ,");
                    stringBuilder.Append("  MC012 = '" + iNVItems.Create_Date.ToString("yyyyMMdd") + "' ");
                }
                else if (iNVItems.TypeInportExport == "-1")               //xuat kho
                {
                    stringBuilder.Append("  MC007 = MC007 - " + iNVItems.Quantity + " ,");
                    stringBuilder.Append("  MC014 = MC014 - " + iNVItems.PackageQty + " ,");
                    stringBuilder.Append("  MC013 = '" + iNVItems.Create_Date.ToString("yyyyMMdd") + "' ");
                }

                stringBuilder.Append(" where MC001 ='" + iNVItems.Product + "' ");
                stringBuilder.Append(" and MC002 ='" + iNVItems.Warehouse + "' ");



                SqlTLVN2 sqlTLVN2 = new SqlTLVN2();
                var      result   = sqlTLVN2.sqlExecuteNonQuery(stringBuilder.ToString(), false);
                if (result == false)
                {
                    SystemLog.Output(SystemLog.MSG_TYPE.War, "UpdateSFCTAForFinishedGoods(FinishedGoodsItems fgItems)", "");
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateSFCTAForFinishedGoods(FinishedGoodsItems fgItems, string TA003)", ex.Message);
            }
            return(false);
        }
 private void SettingLanguage_Load(object sender, EventArgs e)
 {
     try
     {
         string    sqlQuerry = "select FunctionGroup,FunctionName,TiengViet,English,Chinese from t_language   ";
         sqlCON    sqlcon    = new sqlCON();
         DataTable dt        = new DataTable();
         sqlcon.sqlDataAdapterFillDatatable(sqlQuerry, ref dt);
         dtgv_SettingLanguage.DataSource = null;
         dtgv_SettingLanguage.DataSource = dt;
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "SettingLanguage_Load", ex.Message);
     }
 }
Ejemplo n.º 24
0
 public bool InsertUpdateLot(DataTable dtTRansOrderLine)
 {
     try
     {
         for (int i = 0; i < dtTRansOrderLine.Rows.Count; i++)
         {
             InsertOrUpdate(dtTRansOrderLine.Rows[i]);
         }
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertUpdateLot(DataTable dtTRansOrderLine)", ex.Message);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 25
0
 static sql_CheckCondition.QueryResult InsertFunction(DataRow ERPPQC, int i, string TF002, bool IsCheckQuantity_Weight, string nameFile)
 {
     try
     {
         //conn.Open();
         string fullText = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\NewQRcode\FileQuerySQL\" + nameFile.Trim());
         string script   = null;
         script = fullText.Replace("@PO_VALUE", ERPPQC["ProductOrder"].ToString().Trim().Replace("-", ""))
                  .Replace("@LOT_VALUE", ERPPQC["LotNo"].ToString().Trim())
                  .Replace("@USER_VALUE", Class.valiballecommon.GetStorage().UserName)
                  .Replace("@WAREHOUSE_VALUE", ERPPQC["Warehouse"].ToString().Trim())
                  .Replace("@LOCATION_VALUE", ERPPQC["Location"].ToString())
                  .Replace("@QUANTITY_VALUE", ERPPQC["Quantity"].ToString())
                  .Replace("@TF001_VALUE", Class.valiballecommon.GetStorage().DocNo)
                  .Replace("@TF002_VALUE", TF002)
                  .Replace("@STT_VALUE", (i + 1).ToString("0000"))
                  .Replace("@Confirm_VALUE", ReturnYN(IsCheckQuantity_Weight));
         SqlTLVN2 sqlTLVN2 = new SqlTLVN2();
         string   status   = sqlTLVN2.sqlExecuteScalarString(script.ToString());
         if (status == "End script with sucessful")
         {
             if (sql_QueryFromFileSQL.SelectQRCodeBaseStatus(ERPPQC["TransactionID"].ToString().Trim(), false).Count > 0)
             {
                 UpdateQRcodeByQR(ERPPQC["TransactionID"].ToString().Trim());
             }
             else
             {
                 InsertQRcode(ERPPQC["TransactionID"].ToString());
             }
             return(sql_CheckCondition.QueryResult.OK);
         }
         else
         {
             return(sql_CheckCondition.QueryResult.Exception);
         }
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertFunction", "NameFile: " + nameFile + "\n" + ex.Message);
         return(sql_CheckCondition.QueryResult.Exception);
     }
     finally
     {
         conn.Close();
     }
     //   return sql_CheckCondition.QueryResult.Exception;
 }
Ejemplo n.º 26
0
        public bool UpdateCOPTDDelivery(DataTable dtCOPTH)
        {
            try
            {
                for (int i = 0; i < dtCOPTH.Rows.Count; i++)
                {
                    // double SLDongGoi = Database.INV.INVMD.ConvertToWeightKg(dtCOPTH.Rows[i]["TH004"].ToString(), double.Parse(dtCOPTH.Rows[i]["TH008"].ToString()));
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append(" update COPTD ");
                    stringBuilder.Append(" set MODIFIER = '" + Class.valiballecommon.GetStorage().UserName + "', ");
                    stringBuilder.Append("  MODI_DATE = '" + DateTime.Now.ToString("yyyyMMdd") + "', ");
                    stringBuilder.Append("  FLAG = FLAG+1 ,  ");
                    stringBuilder.Append("  MODI_TIME = '" + DateTime.Now.ToString("HH:mm:ss") + "' ,");
                    stringBuilder.Append("  MODI_AP = '" + "SFT" + "' ,");
                    stringBuilder.Append("  MODI_PRID = '" + "COPI06" + "' ,");
                    stringBuilder.Append("  TD009 = TD009 +" + dtCOPTH.Rows[i]["TH008"] + " ,");
                    stringBuilder.Append("  TD033 = TD033 +" + dtCOPTH.Rows[i]["TH039"] + ", ");
                    stringBuilder.Append("  TD011 = " + dtCOPTH.Rows[i]["TH012"] + ", ");
                    stringBuilder.Append("  TD012 = TD012 + " + dtCOPTH.Rows[i]["TH013"] + ", ");
                    stringBuilder.Append("  TD068 = TD068 + " + dtCOPTH.Rows[i]["TH061"] + " ");//TH061

                    stringBuilder.Append(" where TD001 ='" + dtCOPTH.Rows[i]["TH014"] + "' ");
                    stringBuilder.Append(" and TD002 ='" + dtCOPTH.Rows[i]["TH015"] + "' ");
                    stringBuilder.Append(" and TD003 ='" + dtCOPTH.Rows[i]["TH016"] + "' ");


                    SqlTLVN2 sqlTLVN2 = new SqlTLVN2();
                    var      result   = sqlTLVN2.sqlExecuteNonQuery(stringBuilder.ToString(), false);

                    if (result == false)
                    {
                        SystemLog.Output(SystemLog.MSG_TYPE.War, "UpdateSFCTAForFinishedGoods(FinishedGoodsItems fgItems)", "");
                        return(false);
                    }
                    else
                    {
                        isCheckDeliverySucucess(dtCOPTH.Rows[i]["TH014"].ToString().Trim(), dtCOPTH.Rows[i]["TH015"].ToString().Trim(), dtCOPTH.Rows[i]["TH016"].ToString().Trim());
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateSFCTAForFinishedGoods(FinishedGoodsItems fgItems, string TA003)", ex.Message);
            }
            return(false);
        }
Ejemplo n.º 27
0
        public bool UpdateINVMM(Model.INVItems iNVItems, DataTable dtCommonERP)
        {
            try
            {
                double        SLDongGoi     = Database.INV.INVMD.ConvertToWeightKg(iNVItems.Product, iNVItems.Quantity);
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(" update INVMM ");
                stringBuilder.Append(" set MODIFIER = '" + Class.valiballecommon.GetStorage().UserName + "', ");
                stringBuilder.Append("  MODI_DATE = '" + DateTime.Now.ToString("yyyyMMdd") + "', ");
                stringBuilder.Append("  FLAG = FLAG+1 ,  ");
                stringBuilder.Append("  MODI_TIME = '" + DateTime.Now.ToString("HH:mm:ss") + "' ,");
                stringBuilder.Append("  MODI_AP = '" + "SFT" + "' ,");
                stringBuilder.Append("  MODI_PRID = '" + "MOCI05" + "' ,");
                if (iNVItems.TypeInportExport == "1")
                {
                    stringBuilder.Append("  MM005 = MM005 + " + iNVItems.Quantity + " ,");
                    stringBuilder.Append("  MM006 = MM006 + " + SLDongGoi + " ,");
                }
                else if (iNVItems.TypeInportExport == "-1")
                {
                    stringBuilder.Append("  MM005 = MM005 - " + iNVItems.Quantity + " ,");
                    stringBuilder.Append("  MM006 = MM006 - " + SLDongGoi + " ,");
                }
                stringBuilder.Append("  MM008= '" + iNVItems.Create_Date.ToString("yyyyMMdd") + "' ");
                stringBuilder.Append(" where MM001 ='" + iNVItems.Product + "' ");
                stringBuilder.Append(" and MM002 ='" + iNVItems.Warehouse + "' ");
                stringBuilder.Append(" and MM003 ='" + iNVItems.Location + "' ");
                stringBuilder.Append(" and MM004 ='" + iNVItems.Lot + "' ");

                SqlTLVN2 sqlTLVN2 = new SqlTLVN2();
                var      result   = sqlTLVN2.sqlExecuteNonQuery(stringBuilder.ToString(), false);
                if (result == false)
                {
                    SystemLog.Output(SystemLog.MSG_TYPE.War, "UpdateSFCTAForFinishedGoods(FinishedGoodsItems fgItems)", "");
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateSFCTAForFinishedGoods(FinishedGoodsItems fgItems, string TA003)", ex.Message);
            }
            return(false);
        }
        public List <Model.InoutData> GetInoutDatasFromEmpFinger(string EmpFinger, DateTime from, DateTime to)
        {
            List <Model.InoutData> inoutDatas = new List <Model.InoutData>();

            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(@"select CardNo,FDateTime,MachNo,CAST(FDateTime as date ) as DateFinger, convert(char(5), FDateTime, 108) as TimeFinger,
case 
when  convert(char(5), FDateTime, 108) >='19:00' and convert(char(5), FDateTime, 108) <'20:00' then 'In-Night'
when  convert(char(5), FDateTime, 108) >='07:00' and convert(char(5), FDateTime, 108) <'08:10' then 'In-Day'
when  convert(char(5), FDateTime, 108) >='05:00' and convert(char(5), FDateTime, 108) <='06:00' then 'Out-Night8'
when  convert(char(5), FDateTime, 108) >='08:10' and convert(char(5), FDateTime, 108) <='09:00' then 'Out-Night12'
when  convert(char(5), FDateTime, 108) >='17:00' and convert(char(5), FDateTime, 108) <='18:00' then 'Out-Day8'
when  convert(char(5), FDateTime, 108) >='20:00' and convert(char(5), FDateTime, 108) <='21:00' then 'Out-Day12'
else 'Undefined'
end as InOut
from Kq_Source
where 1=1 and  Dept like '%999%' ");
                stringBuilder.Append(" and CardNo ='" + EmpFinger + "' ");
                stringBuilder.Append(" and CAST(FDateTime as date ) >='" + from.ToString("yyyyMMdd") + "' ");
                stringBuilder.Append(" and CAST(FDateTime as date ) <='" + to.ToString("yyyyMMdd") + "' ");
                stringBuilder.Append(" order by CAST(FDateTime as datetime )  ");

                DataTable dt    = new DataTable();
                SqlHR     sqlHR = new SqlHR();
                sqlHR.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    inoutDatas.Add(new Model.InoutData
                    {
                        CardNo    = dt.Rows[i]["CardNo"].ToString(),
                        FDateTime = (DateTime)dt.Rows[i]["FDateTime"],
                        MachNo    = dt.Rows[i]["MachNo"].ToString(),
                        Date      = dt.Rows[i]["DateFinger"].ToString(),
                        Time      = dt.Rows[i]["TimeFinger"].ToString(),
                        InOut     = dt.Rows[i]["InOut"].ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "GetInoutDatasFromEmpFinger ( string EmpFinger, DateTime from, DateTime to)", ex.Message);
            }
            return(inoutDatas);
        }
Ejemplo n.º 29
0
 public static void InsertQRcode(string QR_Code)
 {
     try
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.Append("insert into t_QRImport (IDQRCODE,Status,Update_Date) values('");
         stringBuilder.Append(QR_Code.Trim() + "',");
         stringBuilder.Append("'" + 1 + "',");
         stringBuilder.Append("'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')");
         sqlCON sqlTLVN2 = new sqlCON();
         sqlTLVN2.sqlExecuteNonQuery(stringBuilder.ToString(), false);
     }
     catch (Exception ex)
     {
         SystemLog.Output(SystemLog.MSG_TYPE.Err, "InsertQRcode", ex.Message);
     }
 }
        public static bool GetWeightDemandPlan_NoStageManagement(string PO, Double SLDongGoi)
        {
            try
            {
                conn.Open();
                string    P             = PO.Split('-')[0].Trim();
                string    O             = PO.Split('-')[1].Trim();
                string    m_query_temp  = @"select TA007, ISNULL(TA045,0) as TA045, ISNULL(TA046,0) as TA046,ISNULL(TA047,0) as TA047 
from MOCTA  where TA001 = @P and TA002 = @O"; //
                string    m_query_MOCTA = m_query_temp.Replace("@P", "'" + P + "'").Replace("@O", "'" + O + "'");
                DataTable dt            = new DataTable();
                SqlTLVN2  sqlTLVN2      = new SqlTLVN2();
                sqlTLVN2.sqlDataAdapterFillDatatable(m_query_MOCTA.ToString(), ref dt);
                if (dt.Rows.Count == 1)
                {
                    if (dt.Rows[0]["TA007"].ToString().ToUpper() != "KG")
                    {
                        double TA038 = double.Parse(dt.Rows[0]["TA045"].ToString());
                        double TA039 = double.Parse(dt.Rows[0]["TA046"].ToString());
                        double TA040 = double.Parse(dt.Rows[0]["TA047"].ToString());

                        if (TA039 + TA040 + SLDongGoi > TA038)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "GetWeightDemandPlan_NoStageManagement", ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(false);
        }