Пример #1
0
        public List <StockOfSemi> stockOfSemis(string SemiProduct, double rate)
        {
            List <StockOfSemi> Semis = new List <StockOfSemi>();

            try
            {
                DataTable     dt  = new DataTable();
                StringBuilder sql = new StringBuilder();
                sql.Append("select MC001,MC002,MC007 from INVMC where  (MC002 = 'A03' or MC002 = 'A09') ");
                sql.Append(" and MC001 = '" + SemiProduct + "'");
                sqlERPCON sqlCON = new sqlERPCON();
                sqlCON.sqlDataAdapterFillDatatable(sql.ToString(), ref dt);
                Semis = (from DataRow dr in dt.Rows
                         select new StockOfSemi()
                {
                    Semi = dr["MC001"].ToString().Trim(),

                    Stock = (dr["MC007"].ToString() != "" && rate != 0) ? Math.Round((double.Parse(dr["MC007"].ToString()) / rate), 0): 0,
                    Warehourse = dr["MC002"].ToString().Trim()
                }).ToList();
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "stockOfSemis(string SemiProduct, double rate)", ex.Message);
            }
            return(Semis);
        }
Пример #2
0
        public void sqlDatatablePermision(string buttonText, Button btn_common)
        {
            DataTable dt = new DataTable();

            try
            {
                SqlCommand     cmd     = new SqlCommand();
                SqlDataAdapter adapter = new SqlDataAdapter();
                {
                    cmd.CommandText       = "select  button , status from m_permission where permission =  '" + Class.valiballecommon.GetStorage().Permission + "'";
                    cmd.Connection        = conn;
                    adapter.SelectCommand = cmd;
                    adapter.Fill(dt);
                }
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i][0].ToString() == buttonText)
                        {
                            if (dt.Rows[i][1].ToString() == "True")
                            {
                                btn_common.Enabled = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "Database Responce", ex.Message);
            }
        }
Пример #3
0
        public bool ExportExcelToReport(ref DataGridView gridView, string pathSave, string version)
        {
            try
            {
                GetDataBackLogToExport();
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, " It's function : GetDataBackLogToExport() : Fail", ex.Message);
                return(false);
            }

            if (listBackLog != null && listBackLog.Count > 0)
            {
                try
                {
                    ExportExcelTool exportExcel = new ExportExcelTool();

                    string strUser = Class.valiballecommon.GetStorage().UserName;

                    gridView.DataSource = listBackLog;

                    return(exportExcel.ExportToTemplate(path, gridView, DateTime.Now.ToString("yyyy-MM-dd"), strUser, version, DateTime.Now.ToString("yyyy")));
                }
                catch (Exception ex)
                {
                    Logfile.Output(StatusLog.Error, "Export excel error !", ex.Message);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        public List <BOMItems> bOMItems(string NameProduct)
        {
            List <BOMItems> bOMItems = new List <BOMItems>();

            try
            {
                DataTable     dt  = new DataTable();
                StringBuilder sql = new StringBuilder();
                sql.Append("select MD001,MD003,MD006,MD012 from BOMMD where  1=1 and MD003 like '%B-%' ");
                sql.Append(" and MD001 = '" + NameProduct + "'");
                sqlERPCON sqlCON = new sqlERPCON();
                sqlCON.sqlDataAdapterFillDatatable(sql.ToString(), ref dt);
                bOMItems = (from DataRow dr in dt.Rows
                            select new BOMItems()
                {
                    finishedGoods = dr["MD001"].ToString().Trim(),
                    SemiFinishedgoods = dr["MD003"].ToString().Trim(),
                    Rate = (dr["MD006"].ToString() != "") ?double.Parse(dr["MD006"].ToString().Trim()): 0,
                    Expired = (dr["MD012"].ToString() != "") ? DateTime.Parse(dr["MD012"].ToString().Trim().Insert(4, "-").Insert(7, "-")): DateTime.MaxValue
                }).ToList();
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "bOMItems (string NameProduct)", ex.Message);
            }

            return(bOMItems);
        }
Пример #5
0
        public List <EmailNeedSend> GetEmailNeedSends(string reportName)
        {
            List <EmailNeedSend> listEmailsend = new List <EmailNeedSend>();

            try
            {
                DataTable     dt          = new DataTable();
                StringBuilder sqllistmail = new StringBuilder();
                sqllistmail.Append("select emailaddress, deptcode, status, usingfunction from m_email where status = 'YES' and usingfunction = '" + reportName + "'");
                sqlCON tf = new sqlCON();
                tf.sqlDataAdapterFillDatatable(sqllistmail.ToString(), ref dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    EmailNeedSend item = new EmailNeedSend();
                    item.EmailReceive   = dt.Rows[i]["emailaddress"].ToString();
                    item.DepartmentCode = dt.Rows[i]["deptcode"].ToString();
                    item.Status         = dt.Rows[i]["status"].ToString();
                    item.Function       = dt.Rows[i]["usingfunction"].ToString();

                    listEmailsend.Add(item);
                }
                dt = null;
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "Load list email send fail ", ex.Message);
            }

            return(listEmailsend);
        }
        public List <string> GetListStringHeaderReworkTop25()
        {
            List <string> headerRW25 = new List <string>();

            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(@" select top(16) sum(cast(data as int)) as Tong, item, itemname from m_ERPMQC_REALTIME
inner join m_process on processcode = REPLACE(item,'RW','NG')
where remark ='RW'
group by item,itemname
order by Tong DESC ");
                DataTable dt     = new DataTable();
                sqlCON    sqlCON = new sqlCON();
                sqlCON.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    headerRW25.Add(dt.Rows[i]["itemname"].ToString());
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "List<string> GetListStringHeaderReworkTop25()", ex.Message);
            }
            return(headerRW25);
        }
        public bool ExportReportProductionFromTo(DateTime from, DateTime To)
        {
            try
            {
                DefectRateReport defectRateReport = new DefectRateReport();

                List <DefectRateData> defectRateDatas = new List <DefectRateData>();
                defectRateDatas = defectRateReport.GetListDefectRateReportFromTo("B01", "0010", from, To);

                if (defectRateDatas.Count == 0)
                {
                    return(false);
                }
                SelectTopDefectItems selectTopDefect = new SelectTopDefectItems();
                List <string>        listHeaderRW25  = selectTopDefect.GetListStringHeaderReworkTop25();
                ExportExcelTool      exportExcel     = new ExportExcelTool();
                exportExcel.ExportToTemplateMQCDefectDaily(pathDaily, Pathsave, listHeaderRW25, defectRateDatas, from, To);
                return(true);
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "ExportReportProductionDaiLy()", ex.Message);
                return(false);
            }
        }
Пример #8
0
        public bool sqlExecuteNonQuery(string sql, bool result_message_show)
        {
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);

                int response = cmd.ExecuteNonQuery();
                if (response >= 1)
                {
                    if (result_message_show)
                    {
                        Logfile.Output(StatusLog.Warning, "Successful!", "Database Responce");
                    }
                    conn.Close();
                    return(true);
                }
                else
                {
                    Logfile.Output(StatusLog.Error, "Database Responce");

                    conn.Close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "Not successful!" + " Database Responce", ex.Message);

                conn.Close();
                return(false);
            }
        }
Пример #9
0
 public void getComboBoxData(string sql, ref ComboBox cmb, ref ComboBox cmb2)
 {
     try
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand();
         cmd.Connection  = conn;
         cmd.CommandText = sql;
         SqlDataAdapter adapter = new SqlDataAdapter();
         adapter.SelectCommand = cmd;
         DataSet ds = new DataSet();
         adapter.Fill(ds);
         adapter.Dispose();
         cmd.Dispose();
         cmb.Items.Clear();
         cmb2.Items.Clear();
         foreach (DataRow row in ds.Tables[0].Rows)
         {
             if (cmb.Items != null && cmb.Items.Contains(row[0].ToString()) == false)
             {
                 cmb.Items.Add(row[0].ToString());
             }
             if (cmb2.Items != null && cmb2.Items.Contains(row[1].ToString()) == false)
             {
                 cmb2.Items.Add(row[1].ToString());
             }
         }
     }
     catch (Exception ex)
     {
         Logfile.Output(StatusLog.Error, "Database Responce", ex.Message);
     }
     conn.Close();
 }
Пример #10
0
        public List <DefectRateData> GetListDefectRateReportFromTo(string Dept, string codeProcess, DateTime from, DateTime to)
        {
            List <DefectRateData> defectRates = new List <DefectRateData>();

            try
            {
                LoadDataSummary       loadData     = new LoadDataSummary();
                List <MQCItemSummary> ListmQCItems = loadData.GetMQCItemSummariesFromTo(from, to, Dept, "MQC");
                foreach (var mQCItems in ListmQCItems)
                {
                    DefectRateData defectRate = new DefectRateData();
                    defectRate.Lot            = mQCItems.Lot;
                    defectRate.Line           = mQCItems.Line;
                    defectRate.Product        = mQCItems.product;
                    defectRate.DateTime_from  = mQCItems.Time_from;
                    defectRate.DateTime_to    = mQCItems.Time_To;
                    defectRate.TotalQuantity  = mQCItems.QuantityTotal;
                    defectRate.ReworkQuantity = mQCItems.ReworkQty;
                    defectRate.ReworkRate     = mQCItems.ReworkRate;

                    defectRate.DefectQuantity = mQCItems.NGQty;
                    defectRate.OutputQuantity = mQCItems.OutputQty;
                    defectRate.DefectRate     = (defectRate.TotalQuantity != 0) ? (defectRate.DefectQuantity / defectRate.TotalQuantity) : 0;
                    LoadDefectMapping     loadDefectTop13 = new LoadDefectMapping();
                    List <NGItemsMapping> listTop13       = loadDefectTop13.listNGMappingGetReportTop13(Dept, "MQC");
                    List <DefectItem>     listDefectTop13 = new List <DefectItem>();
                    for (int i = 0; i < listTop13.Count; i++)
                    {
                        var getlist = mQCItems.defectItems.Where(d => d.DefectSFT == listTop13[i].NGCode_SFT).ToList();

                        DefectItem defect = new DefectItem();
                        if (getlist != null && getlist.Count > 0)
                        {
                            defect          = getlist[0];
                            defect.Quantity = getlist.Select(s => s.Quantity).Sum();
                        }
                        defect.Note = listTop13[i].Note;
                        listDefectTop13.Add(defect);
                    }
                    var listDefectTop13Groupby = listDefectTop13.OrderBy(d => d.Note).ToList();
                    defectRate.defectItems = listDefectTop13Groupby;
                    defectRate.ReworkItems = mQCItems.ReworkItems;
                    defectRate.TargetMQC   = new TargetMQC();
                    LoadTargetProduction loadTarget = new LoadTargetProduction();
                    TimeSpan             timeSpan   = to - from;
                    defectRate.TargetMQC = loadTarget.GetArraystarget(defectRate.Product, from, from.AddDays(Math.Round(timeSpan.TotalDays - 1, 0)));

                    defectRates.Add(defectRate);
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "GetDefectRateReport(DateTime from, DateTime to, string Dept, string codeProcess)", ex.Message);
            }
            return(defectRates);
        }
Пример #11
0
        private void Button2_Click(object sender, EventArgs e)
        {
            UploadDataToDatabase.BackLogReport.BacklogReport backlog = new BackLogReport.BacklogReport();
            string filename = @"C:\ERP_Temp\Back-log" + "" + "-" + DateTime.Now.ToString("yyyyMMdd hhmmss") + ".xlsx";

            if (backlog.ExportExcelToReport(ref dgv_export, PathFoler, version))
            {
                //  MessageBox.Show("Upload  data just Finished  ! ");
                Logfile.Output(StatusLog.Normal, "Export Excel File Complete ! ");
                isExportExcel = true;
            }
        }
        public static void getExcelFile(string pathExcel)
        {
            //Create COM Objects. Create a COM object for everything that is referenced
            Excel.Application xlApp       = new Excel.Application();
            Excel.Workbook    xlWorkbook  = xlApp.Workbooks.Open(pathExcel);
            Excel._Worksheet  xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range       xlRange     = xlWorksheet.UsedRange;

            int rowCount = xlRange.Rows.Count;
            int colCount = xlRange.Columns.Count;

            //iterate over the rows and columns and print to the console as it appears in the file
            //excel is not zero based!!
            for (int i = 1; i <= rowCount; i++)
            {
                for (int j = 1; j <= colCount; j++)
                {
                    //new line
                    if (j == 1)
                    {
                        Console.Write("\r\n");
                    }

                    //write the value to the console
                    if (xlRange.Cells[i, j] != null && xlRange.Cells[i, j].Value2 != null)
                    {
                        Logfile.Output(StatusLog.Normal, xlRange.Cells[i, j].Value2.ToString() + "\t");
                    }
                }
            }

            //cleanup
            GC.Collect();
            GC.WaitForPendingFinalizers();

            //rule of thumb for releasing com objects:
            //  never use two dots, all COM objects must be referenced and released individually
            //  ex: [somthing].[something].[something] is bad

            //release com objects to fully kill excel process from running in the background
            Marshal.ReleaseComObject(xlRange);
            Marshal.ReleaseComObject(xlWorksheet);

            //close and release
            xlWorkbook.Close();
            Marshal.ReleaseComObject(xlWorkbook);

            //quit and release
            xlApp.Quit();
            Marshal.ReleaseComObject(xlApp);
        }
Пример #13
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            UploadDataToDatabase.BackLogReport.BacklogReport backlog = new BackLogReport.BacklogReport();
            string FileName = "BackLog Report";

            if (backlog.ExportExcelToReport(ref dgv_export, PathFoler, version))
            {
                Logfile.Output(StatusLog.Normal, "Export Excel File Complete ! ");
            }
            else
            {
                Logfile.Output(StatusLog.Normal, "Export Excel File fail ! ");
            }
        }
Пример #14
0
        public bool iSHaveFileDone(ref string StartTime, ref string StartDate, ref string endTime, ref string endDate, ref string lot, ref string fileread)
        {
            if (Directory.Exists(PathFolder))
            {
                string[] fileInfos = Directory.GetFiles(PathFolder, "*.csv");
                if (fileInfos != null && fileInfos.Count() > 0)
                {
                    fileread = fileInfos[0];
                    string[] ReadAllLine = File.ReadAllLines(fileInfos[0]);
                    string[] lineData    = ReadAllLine[1].Split(',');
                    StartDate = lineData[0]; StartTime = lineData[1]; endDate = lineData[2]; endTime = lineData[3]; lot = lineData[4];
                    Logfile.Output(StatusLog.Normal, "Have files " + lineData[0]);
                    return(true);
                }
            }

            return(false);
        }
Пример #15
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)
     {
         Logfile.Output(StatusLog.Error, "Database Responce", ex.Message);
     }
 }
        public DataTable GetUpCodeDept()
        {
            DataTable dt = new DataTable();

            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(" select * from ZlDept where TreeLevel = 1 and Code not like '%999%' ");
                //  stringBuilder.Append(" select * from ZlDept where TreeLevel = 1 and Code not like '%888%' and Code not like '%666%' ");
                SqlHRFinger sqlHR = new SqlHRFinger();
                sqlHR.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt);
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "DataTable  GetUpCodeDept()", ex.Message);
            }
            return(dt);
        }
        public List <EmployeeAttendance> GetEmployeeAttendancesNightShift(DateTime date, int SessionID)
        {
            List <EmployeeAttendance> employeeAttendances = new List <EmployeeAttendance>();

            try
            {
                DataTable     dt            = new DataTable();
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(@"
 select distinct  e.Code,e.Name, e.Dept, z.Name as DeptName, z.Manager from ZlEmployee e
 left join ZlDept z on e.Dept = z.Code
  left join Kq_Source s on e.ID = s.EmpID
 left join Kq_PaiBan p on e.ID = p.EmpID 
 where  (e.Dept not like '%999%' and e.Dept not like '%888%') and e.State = '0'  and 
e.ID  in (select distinct EmpID from Kq_Source where 1=1 ");
                stringBuilder.Append(" and ((cast(FDateTime as date)  = cast( '" + date.ToString("yyyyMMdd") + "' as date ) ");
                stringBuilder.Append(" and convert(char(5), FDateTime, 108) >='12:00:01'  and convert(char(5), FDateTime, 108) < '23:59:00')   ");
                stringBuilder.Append(" or (cast(FDateTime as date)  = cast( '" + date.AddDays(1).ToString("yyyyMMdd") + "' as date ) ");
                stringBuilder.Append("  and convert(char(5), FDateTime, 108) >='00:01:00'  and convert(char(5), FDateTime, 108) < '12:00:00')) ");
                stringBuilder.Append(" and EmpID is not null ) ");

                stringBuilder.Append(" and p.B" + date.Day + "  in ('03','07') and p.SessionID = '" + SessionID + "' ");
                SqlHRFinger sqlHR = new SqlHRFinger();
                sqlHR.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    employeeAttendances.Add(new EmployeeAttendance
                    {
                        Date     = date.ToString("dd.MM.yyyy"),
                        EmpCode  = dt.Rows[i]["Code"].ToString(),
                        EmpName  = dt.Rows[i]["Name"].ToString(),
                        DeptCode = dt.Rows[i]["Dept"].ToString(),
                        Dept     = dt.Rows[i]["DeptName"].ToString(),
                        Manager  = dt.Rows[i]["Manager"].ToString(),
                        Shift    = "Night"
                    });
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "GetEmployeeAttendances(DateTime date)", ex.Message);
            }
            return(employeeAttendances);
        }
Пример #18
0
 private void ReportSchechule_FormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         dtScheduleSendMail = new DataTable();
         StringBuilder sql = new StringBuilder();
         sql.Append("select reportname, reporttype,Minutes ,hours, day, date, month,isBodyHTML,subject, attach, comments from t_report_schedule where 1=1 ");
         sqlCON tf = new sqlCON();
         tf.sqlDataAdapterFillDatatable(sql.ToString(), ref dtScheduleSendMail);
         dgv_show.DataSource = dtScheduleSendMail;
         dgv_show.Refresh();
         listReport = new List <ScheduleReportItems>();
         listReport = Listreport(dtScheduleSendMail);
     }
     catch (Exception ex)
     {
         Logfile.Output(StatusLog.Error, "Load data from SQL fail: ", ex.Message);
     }
 }
Пример #19
0
        public SqlConnection conn = DBUtils.GetDBHRConnection(); //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)
            {
                Logfile.Output(StatusLog.Error, "Database Responce: SQLERPTarget", ex.Message);

                return(String.Empty);
            }
        }
Пример #20
0
        public void ExportReportProduction()
        {
            string startTime = ""; string Startdate = ""; string endTime = ""; string endDate = ""; string lot = ""; string fileRead = "";
            var    ishaveFile = iSHaveFileDone(ref startTime, ref Startdate, ref endTime, ref endDate, ref lot, ref fileRead);

            if (ishaveFile)
            {
                try
                {
                    Thread.Sleep(10000);
                    DateTime StartDate = DateTime.Parse(Startdate).Date;
                    DateTime EndDate   = DateTime.Parse(endDate).Date;

                    TimeSpan timeStart = TimeSpan.Parse(startTime);
                    TimeSpan timeEnd   = TimeSpan.Parse(endTime);

                    DefectRateData   defectRateData   = new DefectRateData();
                    DefectRateReport defectRateReport = new DefectRateReport();
                    defectRateData = defectRateReport.GetDefectRateReportByLot(StartDate, timeStart, EndDate, timeEnd, "B01", "0010", lot);
                    if (defectRateData.TotalQuantity > 0)
                    {
                        Log.ExportExcelTool exportExcel = new Log.ExportExcelTool();
                        checkFolderSaveProduction(true);
                        exportExcel.ExportToTemplateMQCDefectTop16(MQCForm, pathSaveProduction + DateTime.Now.ToString("yyyy-MM-dd") + "\\" + "MQC_" + lot + "" + "-" + DateTime.Now.ToString("yyyyMMdd hhmmss") + ".xlsx", defectRateData);
                    }

                    if (File.Exists(fileRead))
                    {
                        File.Move(fileRead, PathDoneMoving + new FileInfo(fileRead).Name);
                    }
                }
                catch (Exception ex)
                {
                    Logfile.Output(StatusLog.Normal, "ExportReportProduction()", ex.Message);
                    if (File.Exists(fileRead))
                    {
                        //   string temp = PathErrorFiles + new FileInfo(fileRead).Name;
                        File.Move(fileRead, PathErrorFiles + new FileInfo(fileRead).Name);
                    }
                }
            }
        }
Пример #21
0
        private List <EmailNeedSend> EmailNeedSends(string reportName)
        {
            List <EmailNeedSend> listEmailsend = new List <EmailNeedSend>();

            try
            {
                dtListEmail = new DataTable();
                StringBuilder sqllistmail = new StringBuilder();
                sqllistmail.Append("select emailaddress, deptcode, status, usingfunction from m_email where status = 'YES' and usingfunction = '" + reportName + "'");
                sqlCON tf = new sqlCON();
                tf.sqlDataAdapterFillDatatable(sqllistmail.ToString(), ref dtListEmail);
                listEmailsend = ListEmailNeedSend(dtListEmail);
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "Load list email send fail ", ex.Message);
            }

            return(listEmailsend);
        }
Пример #22
0
        public SqlConnection conn = DBUtils.GetSFTDBConnection(); //get from user database

        public string sqlExecuteScalarString(string sql)
        {
            String outstring;

            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            try
            {
                outstring = cmd.ExecuteScalar().ToString();
                return(outstring);
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "sqlSFT : sqlExecuteScalarString(string sql)", ex.Message);

                return(String.Empty);
            }
            //    conn.Close();
        }
Пример #23
0
        public bool SendMailReliabilityReportMonthly()
        {
            try
            {
                DateTimeControl.ReturnDateTimeForMonthly(ref dateFrom, ref dateTo);
                RealabilityReport         realabilityReport   = new RealabilityReport();
                List <ReliabilitySummary> ListReliability     = new List <ReliabilitySummary>();
                List <ReliabilitySummary> ListReliabilityDept = new List <ReliabilitySummary>();
                ListReliability = realabilityReport.GetDataForReliability(dateFrom, dateTo, out ListReliabilityDept);
                ExportExcelTool exportExcelTool = new ExportExcelTool();
                string          path            = @"C:\ERP_Temp\Reliability_Report_" + DateTime.Now.ToString("ddMMyy HHmmss") + ".xlsx";
                exportExcelTool.ExportToReliabilityReport(pathTemplate, path, ListReliability, ListReliabilityDept, dateFrom, dateTo);
            }

            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "SendMailReliabilityReportWeekly()", ex.Message);
                return(false);
            }
            return(true);
        }
        public List <EmployeeAttendance> GetEmployeeAttendancesSeasonal(DateTime date)
        {
            List <EmployeeAttendance> employeeAttendances = new List <EmployeeAttendance>();

            try
            {
                DataTable     dt            = new DataTable();
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(@" select distinct  e.Code,e.Name, e.Dept, z.Name as DeptName, z.Manager from ZlEmployee e
 left join ZlDept z on e.Dept = z.Code
 left join Kq_Source s on s.EmpID = e.ID
 where  e.Dept  like '%999%'   and 

 e.ID  in (select EmpID from Kq_Source where 1=1
");
                stringBuilder.Append(" and cast(FDateTime as date)  = cast( '" + date.ToString("yyyyMMdd") + "' as date )");
                stringBuilder.Append("  and convert(char(5), FDateTime, 108) >='00:00:01'  and convert(char(5), FDateTime, 108) < '23:59:00' ) ");
                stringBuilder.Append("  and cast(FDateTime as date)  = cast( '" + date.ToString("yyyyMMdd") + "' as date )");

                SqlHRFinger sqlHR = new SqlHRFinger();
                sqlHR.sqlDataAdapterFillDatatable(stringBuilder.ToString(), ref dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    employeeAttendances.Add(new EmployeeAttendance
                    {
                        Date     = date.ToString("dd.MM.yyyy"),
                        EmpCode  = dt.Rows[i]["Code"].ToString(),
                        EmpName  = dt.Rows[i]["Name"].ToString(),
                        DeptCode = dt.Rows[i]["Dept"].ToString(),
                        Dept     = dt.Rows[i]["DeptName"].ToString(),
                        Manager  = dt.Rows[i]["Manager"].ToString(),
                    });
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "GetEmployeeAttendances(DateTime date)", ex.Message);
            }
            return(employeeAttendances);
        }
Пример #25
0
        public List <SemiFinishedgoods> GetSemibyNameProduct(string NameProduct)
        {
            List <SemiFinishedgoods> semiFinishedgoods = new List <SemiFinishedgoods>();

            try
            {
                // List<SemiFinishedgoods> semiFinishedgoods = new List<SemiFinishedgoods>();
                List <BOMItems>            listBOM     = bOMItems(NameProduct);
                List <StockOfSemi>         stockSemis  = new List <StockOfSemi>();
                List <List <StockOfSemi> > listofSemis = new List <List <StockOfSemi> >();
                if (listBOM != null && listBOM.Count > 0)
                {
                    foreach (var item in listBOM)
                    {
                        if (item.Expired > DateTime.Now)
                        {
                            stockSemis = new List <StockOfSemi>();
                            stockSemis = stockOfSemis(item.SemiFinishedgoods, item.Rate);
                            if (stockSemis != null && stockSemis.Count > 0)
                            {
                                listofSemis.Add(stockSemis);
                            }
                        }
                    }

                    foreach (var item in listofSemis)
                    {
                        SemiFinishedgoods semi1 = new SemiFinishedgoods();
                        semi1.Semi_finishedGoods = item[0].Semi;
                        semi1.Stock = item.Select(d => d.Stock).Sum();
                        semiFinishedgoods.Add(semi1);
                    }
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "GetSemibyNameProduct", ex.Message);
            }
            return(semiFinishedgoods);
        }
Пример #26
0
        private void CreateFolderDeleteFilesExcelold()
        {
            bool exists = System.IO.Directory.Exists(PathFoler);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(PathFoler);
            }
            try
            {
                DirectoryInfo d     = new DirectoryInfo(PathFoler);//Assuming Test is your Folder
                FileInfo[]    Files = d.GetFiles();
                foreach (FileInfo file in Files)
                {
                    File.Delete(file.FullName);
                }
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "DeleteFilesExcel : Fail ", ex.Message);
            }
        }
Пример #27
0
        private void ExportDataBackLogToExcel(string FileName, int hour)
        {
            if (DateTime.Now.Hour == hour /*&& DateTime.Now.Minute   < 30*/)
            {
                if (isExportExcel == false)
                {
                    UploadDataToDatabase.BackLogReport.BacklogReport backlog = new BackLogReport.BacklogReport();

                    if (backlog.ExportExcelToReport(ref dgv_export, PathFoler, version))
                    {
                        //  MessageBox.Show("Upload  data just Finished  ! ");
                        Logfile.Output(StatusLog.Normal, "Export Excel File Complete ! ");
                        isExportExcel = true;
                    }
                    else
                    {
                        isExportExcel = false;
                        Logfile.Output(StatusLog.Normal, "Export Excel File fail ! ");
                    }
                }
            }
        }
        private void Btn_kiemtra_Click(object sender, EventArgs e)
        {
            System.Windows.Input.Cursor oldCursor = Mouse.OverrideCursor;

            try
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                WindowState          = FormWindowState.Minimized;
                FindListNG();
                FindListWrong12hours();
                FindSpecialRule();
                WindowState = FormWindowState.Maximized;
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "check error", ex.Message);
            }
            finally
            {
                Mouse.OverrideCursor = oldCursor;
            }
        }
Пример #29
0
 public bool ExportReportProductionWeekly()
 {
     try
     {
         DefectRateReport defectRateReport = new DefectRateReport();
         DateTime         date_from        = Class.DateTimeControl.StartOfWeek(DayOfWeek.Monday);
         DateTime         date_to          = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + 7);
         DefectRateData   defectRateData   = new DefectRateData();
         defectRateData = defectRateReport.GetDefectRateReportAmountOfTime(date_from, date_to, "B01", "0010");
         if (defectRateData.TotalQuantity == 0)
         {
             return(false);
         }
         Log.ExportExcelTool exportExcel = new Log.ExportExcelTool();
         exportExcel.ExportToTemplateMQCDefectAmountOfTime(date_from, date_to, pathMonth, @"C:\ERP_Temp\MQC_Weekly_Report" + "-" + DateTime.Now.ToString("yyyyMMdd hhmmss") + ".xlsx", defectRateData);
         return(true);
     }
     catch (Exception ex)
     {
         Logfile.Output(StatusLog.Error, "ExportReportProductionDaiLy()", ex.Message);
         return(false);
     }
 }
Пример #30
0
        public bool ExportReportProductionDaiLy(PeriodProduction period)
        {
            try
            {
                DefectRateReport defectRateReport = new DefectRateReport();

                List <DefectRateData> defectRateDatas = new List <DefectRateData>();
                defectRateDatas = defectRateReport.GetListDefectRateReportAmountOfTimeDaily("B01", "0010", period);

                if (defectRateDatas.Count == 0)
                {
                    return(false);
                }
                Log.ExportExcelTool exportExcel = new Log.ExportExcelTool();
                exportExcel.ExportToTemplateMQCDefectDaily(pathDaily, @"C:\ERP_Temp\MQC_Daily_Report" + "-" + DateTime.Now.ToString("yyyyMMdd hhmmss") + ".xlsx", defectRateDatas);
                return(true);
            }
            catch (Exception ex)
            {
                Logfile.Output(StatusLog.Error, "ExportReportProductionDaiLy()", ex.Message);
                return(false);
            }
        }