private void btnJobs_Click(object sender, EventArgs e) { var data = MainDb.GetDataTable("SELECT * FROM StorageOrders"); if (data != null) { grid.DataSource = data; } }
private void btnShowSingleMoves_Click(object sender, EventArgs e) { var data = MainDb.GetDataTable("SELECT * FROM UnitMoves"); if (data != null) { grid.DataSource = data; } }
private void LoadOrderList() { try { string where = ""; if (true) // !chkIncludeDone.Checked) { where = " WHERE NOT status IN ('done', 'cancel', 'timeout') "; } var table = MainDb.GetDataTable( "SELECT [ID], [Status], " + " CASE StorageOrders.Target WHEN 1 THEN 'in' ELSE 'out' END as dir, " + " [Label], trolley, '' as Unit, LoadingStation, '' as station, exit_reason " + " FROM StorageOrders " + where); if (table != null && table.Rows != null && table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { var col = row.Field <int>("trolley"); row["Unit"] = Unit.UnitName(col); var io = row.Field <int>("LoadingStation"); row["station"] = Unit.UnitName(io); } } ordergrid.DataSource = table; // grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); ordergrid.Columns["ID"].Width = 75; ordergrid.Columns["Label"].Width = 75; ordergrid.Columns["Unit"].Width = 75; ordergrid.Columns["Status"].Width = 75; ordergrid.Columns["trolley"].Visible = false; ordergrid.Columns["LoadingStation"].Visible = false; int row_idx = 0; foreach (DataGridViewRow row in ordergrid.Rows) { int col = (int)ordergrid[4, row_idx].Value; if (col == 21) { ordergrid[5, row_idx].Style.BackColor = Color.LightBlue; } if (col == 22) { ordergrid[5, row_idx].Style.BackColor = Color.LightGreen; } if (col == 23) { ordergrid[5, row_idx].Style.BackColor = Color.Yellow; } if (ordergrid[1, row_idx].Value != null && ordergrid[1, row_idx].Value.ToString() == "error") { ordergrid[1, row_idx].Style.BackColor = Color.Red; } row_idx++; } } catch { } }
private void btnFreeSpace_Click(object sender, EventArgs e) { string more_where = ""; int rolls = 0; for (int i = 11; i <= 13; i++) { if (!BauerLib.Registry.UseIOTable(i)) { continue; } if (Unit.GetUnit(i).LoadingStation_WithRoll || Unit.GetUnit(i).LoadingStation_WithRollOnShuttle) { rolls++; } } for (int i = 21; i <= 23; i++) { if (!BauerLib.Registry.UseTrolley(i)) { continue; } if (Unit.GetUnit(i).Cylinder_ID != 0) { rolls++; } } if (BauerLib.Registry.RightSideOnly) { more_where += " AND ( (Bridge<=5) OR (Bridge>5 AND Trolley=1) ) "; } if (!BauerLib.Registry.RightSideRow11) { more_where += " AND (Trolley<>11) "; } var sql = @" select Info, CAST( CAST(DiameterMax / 25.4 + 0.5 as int) as varchar(255)) + '""' + ' / ' + CAST( DiameterMax as varchar(255)) + 'mm' as [max diameter], case when spacesleft - mvr < 0 THEN 0 ELSE spacesleft - mvr END as [spaces left], TotalSpaces as [total spaces] from ( SELECT Info, DiameterMax, " + rolls.ToString() + @" as mvr, COUNT(*) as spacesleft , (SELECT COUNT(*) FROM Rack as RR WHERE RR.DiameterMax = Rack.DiameterMax AND HookType = 1" + more_where + @") as TotalSpaces FROM Rack WHERE ((HookType = 1) AND (State = 0) AND (Cylinder_ID = 0) AND (Order_ID = 0 OR Order_ID IS NULL) AND (Reservation IS NULL OR Reservation = '')) " + more_where + @"GROUP BY Info, DiameterMax ) T ORDER BY Info, [max diameter]"; var data = MainDb.GetDataTable(sql); if (data != null) { grid.DataSource = data; } grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); }
public void LoadGridData() { try { string where = ""; if (!chkIncludeDone.Checked) { where = " WHERE NOT status IN ('done', 'cancel', 'timeout') "; } var table = MainDb.GetDataTable( "SELECT [ID], [Unit_ID] , '' as Unit, [Info], [Source], [Target], [Status], [MoveType], [WaitMove_ID] " + "FROM UnitMoves " + where + " ORDER BY ID"); if (table != null && table.Rows != null && table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { var col = row.Field <int>("Unit_ID"); row["Unit"] = Unit.UnitName(col); } } grid.DataSource = table; //grid.Columns["ID"].Width = 75; //grid.Columns["Unit"].Width = 75; //grid.Columns["Status"].Width = 75; //grid.Columns["MoveType"].Width = 75; //grid.Columns["WaitMove_ID"].Width = 75; grid.Columns["Unit_ID"].Visible = false; grid.Columns["WaitMove_ID"].HeaderText = "wait for"; int row_idx = 0; foreach (DataGridViewRow row in grid.Rows) { int col = (int)grid[1, row_idx].Value; if (col == 31) { grid[2, row_idx].Style.BackColor = Color.PaleGoldenrod; } if (col == 32) { grid[2, row_idx].Style.BackColor = Color.PaleGoldenrod; } if (col == 21) { grid[2, row_idx].Style.BackColor = Color.LightBlue; } if (col == 22) { grid[2, row_idx].Style.BackColor = Color.LightGreen; } if (col == 23) { grid[2, row_idx].Style.BackColor = Color.Yellow; } row_idx++; } } catch { } try { string where = ""; if (!chkIncludeDone.Checked) { where = " WHERE NOT status IN ('done', 'cancel', 'timeout') "; } var table = MainDb.GetDataTable( "SELECT [ID], [Status], " + "CASE StorageOrders.Target WHEN 1 THEN 'in' ELSE 'out' END as dir, " + " [Label], trolley, '' as Unit, LoadingStation, '' as station, [SourceHook] as Source, [TargetHook] as Target " + "FROM StorageOrders " + where); if (table != null && table.Rows != null && table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { var col = row.Field <int>("trolley"); row["Unit"] = Unit.UnitName(col); var io = row.Field <int>("LoadingStation"); row["station"] = Unit.UnitName(io); } } ordergrid.DataSource = table; // grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); ordergrid.Columns["ID"].Width = 75; ordergrid.Columns["Label"].Width = 75; ordergrid.Columns["Unit"].Width = 75; ordergrid.Columns["Status"].Width = 75; ordergrid.Columns["trolley"].Visible = false; ordergrid.Columns["LoadingStation"].Visible = false; int row_idx = 0; foreach (DataGridViewRow row in ordergrid.Rows) { int col = (int)ordergrid[4, row_idx].Value; if (col == 21) { ordergrid[5, row_idx].Style.BackColor = Color.LightBlue; } if (col == 22) { ordergrid[5, row_idx].Style.BackColor = Color.LightGreen; } if (col == 23) { ordergrid[5, row_idx].Style.BackColor = Color.Yellow; } if (ordergrid[1, row_idx].Value != null && ordergrid[1, row_idx].Value.ToString() == "error") { ordergrid[1, row_idx].Style.BackColor = Color.Red; } row_idx++; } } catch { } }