public KC_MachineDetail(AutoCutMachine Machine) { InitializeComponent(); DataContext = new DataContext(); this.Machine = Machine; IntializeMachinesTrackingData(); }
public MachineDetailForm(KC_DisMachine KC_DisMachine, AutoCutMachine machine) { InitializeComponent(); DataContext = new DataContext(); KC_ImplementBase = new KC_ImplementBase(DataContext); this.KC_DisMachine = KC_DisMachine; Machine = machine; this.Text = $"MACHINE: {machine.MachineName}"; DS_AutoCutMachine.DataSource = Machine; }
public List <KnifeCaptureTracking> Get_KnifeCaptureTrackings(AutoCutMachine AutoCutMachine) { try { return(DataContext.KnifeCaptureTracking .Where(i => i.MachineId == AutoCutMachine.Id) .ToList()); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public List <KnifeCaptureTracking> Get_KnifeCaptureTrackingsOnWeek(AutoCutMachine AutoCutMachine, DateTime DateofWeek) { try { var knifeCaptures = Get_KnifeCaptureTrackings(AutoCutMachine); if (knifeCaptures == null) { return(null); } string current_date = DateofWeek.ToString("dd/MM/yyyy"); DateTime FirstDateOfWeek = SysExtends.FirstDayOfWeek(DateofWeek); var result = new List <KnifeCaptureTracking>(); foreach (var item in knifeCaptures) { int sub_days = item.UpdateTime.DayOfYear - FirstDateOfWeek.DayOfYear; if (item.UpdateTime.Year == FirstDateOfWeek.Year) { sub_days = item.UpdateTime.DayOfYear - FirstDateOfWeek.DayOfYear; if (item.UpdateTime.DayOfWeek >= FirstDateOfWeek.DayOfWeek && sub_days >= 0 && sub_days <= 7) { result.Add(item); } } else { if (item.UpdateTime.Year - FirstDateOfWeek.Year == 1) { sub_days = Math.Abs(sub_days); DateTime endofyear = new DateTime(FirstDateOfWeek.Year, FirstDateOfWeek.Month, 31); if (item.UpdateTime.DayOfWeek >= FirstDateOfWeek.DayOfWeek && sub_days >= 0 && sub_days <= 7) { result.Add(item); } } } } return(result); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public List <KnifeCaptureTracking> Get_KnifeCaptureTrackings(AutoCutMachine AutoCutMachine, DateTime Now) { try { string current_date = Now.ToString("dd/MM/yyyy"); return(DataContext.KnifeCaptureTracking .Where(i => i.MachineId == AutoCutMachine.Id && i.TimeStr.Contains(current_date)) .ToList()); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public KC_PostRecord Get_LastPostRecord(AutoCutMachine AutoCutMachine) { try { return(DataContext.KC_DisMachine .Include("KC_PostRecord") .Where(i => i.AutoCutMachineId == AutoCutMachine.Id) .OrderByDescending(i => i.Id) .FirstOrDefault().KC_PostRecord); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public bool Update_AutoCutMachine(AutoCutMachine AutoCutMachine) { try { var machine = Get_AutoCutMachine(AutoCutMachine.Id); machine.ResetCounterDate = AutoCutMachine.ResetCounterDate; machine.TotalCounterDay = AutoCutMachine.TotalCounterDay; DataContext.Entry(machine).State = System.Data.Entity.EntityState.Modified; DataContext.SaveChanges(); return(true); } catch (Exception e) { Console.WriteLine(e.ToString()); return(false); } }
public void RefreshData(KC_DisMachine DisMachine) { KC_DisMachine = DisMachine; DataContext = new DataContext(); KC_ImplementBase = new KC_ImplementBase(DataContext); Machine = new AutoCutMachine(); Machine = KC_ImplementBase.Get_AutoCutMachine((int)KC_DisMachine.AutoCutMachineId); if (machineDetailForm == null) { machineDetailForm = new MachineDetailForm(DisMachine, Machine); } else { machineDetailForm.RefreshDetail(DisMachine); } UpdateMachineInfo(); }
public static void ExportToExcel_KC_Machine(AutoCutMachine Machine, ExcelWorksheet CurrentSheet, DateTime ExportDateOfWeek) { var knife_captures = KC_ImplementBase.Get_KnifeCaptureTrackingsOnWeek(Machine, ExportDateOfWeek); if (knife_captures == null) { return; } string[] Header = new string[] { "Tổng/STT", "Thời gian", "Loại dao", "Đầu dao", "Tên dao", "Hiện tại" }; int beginColumn = 1; int beginRow = 1; //create excel header for (int i = beginColumn; i <= Header.Length; i++) { CurrentSheet.Cells[beginRow, i].Value = Header[i - 1]; CurrentSheet.Cells[beginRow, i].Style.Font.Bold = true; CurrentSheet.Cells[beginRow, i].Style.Border.BorderAround(ExcelBorderStyle.Medium); } ExcelRange HeaderRow = CurrentSheet.Cells[beginRow, beginColumn, beginRow, beginColumn + 4]; HeaderRow.Style.Fill.PatternType = ExcelFillStyle.Solid; HeaderRow.Style.Fill.BackgroundColor.SetColor(Color.Yellow); HeaderRow.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; HeaderRow.Style.VerticalAlignment = ExcelVerticalAlignment.Center; HeaderRow.Style.Border.BorderAround(ExcelBorderStyle.Medium); int Total = 0; foreach (var item in knife_captures) { Total++; ExcelRange CurrentRow = CurrentSheet.Cells[beginRow + Total, beginColumn, beginRow + Total, beginColumn + 4]; CurrentRow.Style.Fill.PatternType = ExcelFillStyle.Solid; if (item.KnifeType == 0) { CurrentRow.Style.Fill.BackgroundColor.SetColor(Color.Silver); } if (item.KnifeType == 1) { CurrentRow.Style.Fill.BackgroundColor.SetColor(Color.LightBlue); } int CurrentRowIndex = beginRow + Total; ExcelRange TotalCell = CurrentSheet.Cells[CurrentRowIndex, beginColumn + 0]; ExcelRange TimeCell = CurrentSheet.Cells[CurrentRowIndex, beginColumn + 1]; ExcelRange TypeCell = CurrentSheet.Cells[CurrentRowIndex, beginColumn + 2]; ExcelRange PosCell = CurrentSheet.Cells[CurrentRowIndex, beginColumn + 3]; ExcelRange KnifeNameCell = CurrentSheet.Cells[CurrentRowIndex, beginColumn + 4]; ExcelRange LocalCell = CurrentSheet.Cells[CurrentRowIndex, beginColumn + 5]; TotalCell.Style.Border.BorderAround(ExcelBorderStyle.Dashed); TimeCell.Style.Border.BorderAround(ExcelBorderStyle.Dashed); TypeCell.Style.Border.BorderAround(ExcelBorderStyle.Dashed); PosCell.Style.Border.BorderAround(ExcelBorderStyle.Dashed); KnifeNameCell.Style.Border.BorderAround(ExcelBorderStyle.Dashed); LocalCell.Style.Border.BorderAround(ExcelBorderStyle.Dashed); if (item.KnifeHeadPos == 0) { PosCell.Style.Fill.PatternType = ExcelFillStyle.Solid; PosCell.Style.Fill.BackgroundColor.SetColor(Color.LightGreen); } if (item.KnifeHeadPos == 1) { PosCell.Style.Fill.PatternType = ExcelFillStyle.Solid; PosCell.Style.Fill.BackgroundColor.SetColor(Color.LightYellow); } var knife = ComponentBase.Get_Knife(item.LocalKnifeId); string knife_name = knife != null ? knife.ComponentCode : string.Empty; TotalCell.Value = Total; TimeCell.Value = item.UpdateTime.ToString("ddd, dd/MM/yy, hh:ss tt"); TypeCell.Value = item.KType; PosCell.Value = item.KPosition; KnifeNameCell.Value = knife_name; LocalCell.Value = item.LocalValue; } ExcelRange CurrentTable = CurrentSheet.Cells[beginRow, beginColumn, beginRow + Total, beginColumn + 5]; CurrentTable.Style.Border.BorderAround(ExcelBorderStyle.Medium); CurrentSheet.Cells.Style.WrapText = true; CurrentSheet.Column(beginColumn).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; CurrentSheet.Column(beginColumn + 5).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; CurrentSheet.Column(beginColumn + 1).Width = 30; CurrentSheet.Column(beginColumn + 2).Width = 20; CurrentSheet.Column(beginColumn + 3).Width = 20; CurrentSheet.Column(beginColumn + 4).Width = 20; }