using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraSplashScreen; using WMS.Business; using WMS.Business.Base; using WMS.Business.Stock; using WMS.Common; using WMS.Frm.Base; using WMS.Model.Stock; namespace Scada { public partial class FrmScada : FormBase { public FrmScada() { InitializeComponent(); } DataTable tbRows = new DataTable(); private void LocShow_Click(object sender, EventArgs e) { ShapeControl.CustomControl1 c = (ShapeControl.CustomControl1)sender; string decId = c.AccessibleName; string roId = c.Text; FrmLoc frm = new FrmLoc(decId, roId); frm.ShowDialog(); } //void AddText(string errTex,string r) //{ // if (r.Trim().Length > 0) // { // if (t_error.Text.Trim().Length > 0) // { // if (t_error.Text.Contains(errTex)) // { // // t_error.Text.Remove(t_error.Text.IndexOf(errTex), errTex.Length-1); // t_error.Text.Remove(t_error.Text.IndexOf(errTex), errTex.Length - 1); // } // } // return; // } // if (!t_error.Text.Contains(errTex)) // { // // t_error.Text.Remove(t_error.Text.IndexOf(errTex), errTex.Length-1); // t_error.AppendText(errTex); // } // //else // //{ // // t_error.AppendText(errTex); // //} //} #region 输送机 object a = new object(); void BindCData() { lock (a) { try { DataTable tb = IBussFactory.Instance().GetDecDataTable(); if (tb != null) { if (tb.Rows.Count > 0) { for (int i=0;i0) { locId = tb.Rows[i]["loc2"].ToString(); cuId = tb.Rows[i]["PICKINGID"].ToString(); taskId = "(OUT) " + taskId; } else if (tb.Rows[i]["loc"].ToString().Trim().Length > 0) { taskId = "(IN) " + taskId; locId = tb.Rows[i]["loc"].ToString(); cuId = tb.Rows[i]["UPGOODS_ID"].ToString(); } } } } } catch (Exception ex) { } } } #endregion #region 堆垛机 List deList = new List(); void BindDec() { lock ("a") { DataTable tb = IBussFactory.Instance().GetDecStsData(); if (tb != null) { if (tb.Rows.Count > 0) { foreach (DataRow row in tb.Rows) { string decName = row["devid"].ToString(); string online = row["online"].ToString(); string onlineNow = row["onlinenow"].ToString(); string errText = row["error"].ToString(); foreach (ShapeControl.CustomControl1 ctl in deList) { if (ctl.Text == decName) { if (errText.Trim() == "0") { ctl.BackColor = Color.MediumTurquoise; } else { ctl.BackColor = Color.Red; break; } if (online == "1" && onlineNow == "1") { ctl.BackColor = Color.MediumTurquoise; } else { ctl.BackColor = Color.Violet; } break; } } } } } } } #endregion private void timer1_Tick(object sender, EventArgs e) { SplashScreenManager.ShowDefaultWaitForm("请稍等", "正在加载数据..."); BindCData(); BindDec(); SplashScreenManager.CloseDefaultSplashScreen(); } private void Form1_Load(object sender, EventArgs e) { //DataColumn cmn = new DataColumn(); //cmn.ColumnName=""; //Graphics g =panelControl1.CreateGraphics();//.Graphics; // Draw the text to describe the selection. Note that since // the text is left-justified, only the Y (vertical) position // is calculated. // int dispY = ((SquareY - 1) * SquareQY) + SquareQY + 4; //if (this.Cancel) //{ // DispText = "Cancel"; //} //else //{ // DispText = SelQX.ToString() + " by " + SelQY.ToString() + " Table"; //} // g.DrawString(DispText, DispFont, BlackBrush, 3, dispY + 2); // Draw each of the squares and fill with the default color. } private void Time_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { throw new NotImplementedException(); } private void Selectdata_Click(object sender, EventArgs e) { } private void dc1_Click(object sender, EventArgs e) { ShapeControl.CustomControl1 ctl = (ShapeControl.CustomControl1)sender; string deic = ctl.Text; FrmDec frm = new FrmDec(deic); frm.ShowDialog(); } private void tb_dec_Click(object sender, EventArgs e) { } private void InEnable_CheckedChanged(object sender, EventArgs e) { } private void OutEnable_CheckedChanged(object sender, EventArgs e) { } private void ctrlButtons4_Click(object sender, EventArgs e) { } private void ch_Box_CheckedChanged(object sender, EventArgs e) { } private void ctrlButtons1_Click(object sender, EventArgs e) { } private void panel2_Paint(object sender, PaintEventArgs e) { } private void ch_Box_Click(object sender, EventArgs e) { } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { } void bindview(string decid) { DataTable dsView = IBussFactory.Instance().GetCtLocData(decid); //浅货位 int y = 50; int x = 200; for (int row = 1; row <= 2; row++) { for (int lay = 8; lay >= 1; lay--) { x = 200; for (int cln = 1; cln <= 24; cln++) { if (row == 1) { Label labRow1 = new Label(); labRow1.Text = "一排浅"; labRow1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); labRow1.ForeColor = System.Drawing.Color.Blue; labRow1.AutoSize = true; labRow1.Location = new System.Drawing.Point(90, 150); lisBt.Add(labRow1); Label labRow2 = new Label(); labRow2.Text = "二排浅"; labRow2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); labRow2.ForeColor = System.Drawing.Color.Blue; labRow2.AutoSize = true; labRow2.Location = new System.Drawing.Point(90, 423); lisBt.Add(labRow2); } //列表头显示 Label label = new Label(); label.Text = cln.ToString("00"); label.AutoSize = true; label.Location = new System.Drawing.Point(x, y - 30); lisBt.Add(label); //左侧层显示 Label label2 = new Label(); label2.Text = lay.ToString("00"); label2.AutoSize = true; label2.Location = new System.Drawing.Point(x - 30, y + 5); lisBt.Add(label2); Button bt = new Button(); bt.FlatStyle = FlatStyle.Flat;//= 0; bt.FlatAppearance.BorderSize = 1; bt.Size = new Size(25, 25); string loc = row.ToString() + "," + cln.ToString() + "," + lay.ToString() + "1"; if (lisBt.Count(r => r.AccessibleDescription == loc) > 0) { bt = lisBt.Find(r => r.AccessibleDescription == loc) as Button; } else { bt.Location = new Point(x, y); bt.AccessibleDescription = loc; bt.Click += Bt_Click; bt.MouseMove += Bt_Click2; lisBt.Add(bt); } DataRow[] rows = dsView.Select("row1='" + row + "' and cln='" + cln + "' and layer1='" + lay + "' and depth='1'"); if (rows != null) { if (rows.Length > 0) { string sts = rows[0]["Status"].ToString(); string location = rows[0]["LOCATION_ID"].ToString(); bt.AccessibleName = location; if (sts == "1") { bt.BackColor = Color.Yellow; } else if (sts == "2") { bt.BackColor = Color.LightSkyBlue; } else if (sts == "0") { bt.BackColor = Color.Green; } } else { bt.BackColor = Color.White; } } x = x + bt.Size.Width + 3; } y = y + 30; } y = y + 60; } //深货位 int yy = 50; int xx = 200; for (int row = 1; row <= 2; row++) { for (int lay = 8; lay >= 1; lay--) { xx = 1000; for (int cln = 1; cln <= 24; cln++) { if (row == 1) { Label labRow1 = new Label(); labRow1.Text = "一排深"; labRow1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); labRow1.ForeColor = System.Drawing.Color.Blue; labRow1.AutoSize = true; labRow1.Location = new System.Drawing.Point(890, 150); lisBt.Add(labRow1); //Label labRow2 = new Label(); //labRow2.Text = "二排"; //labRow2.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); //labRow2.ForeColor = System.Drawing.Color.Blue; //labRow2.AutoSize = true; //labRow2.Location = new System.Drawing.Point(90, 423); //lisBt.Add(labRow2); //列表头显示 Label label = new Label(); label.Text = cln.ToString("00"); label.AutoSize = true; label.Location = new System.Drawing.Point(xx, yy - 30); lisBt.Add(label); } ////左侧层显示 //Label label2 = new Label(); //label2.Text = lay.ToString("00"); //label2.AutoSize = true; //label2.Location = new System.Drawing.Point(xx - 30, yy + 5); //lisBt.Add(label2); if (row == 1) { Button bt = new Button(); bt.FlatStyle = FlatStyle.Flat;//= 0; bt.FlatAppearance.BorderSize = 1; bt.Size = new Size(25, 25); string loc = row.ToString() + "," + cln.ToString() + "," + lay.ToString() + "2"; if (lisBt.Count(r => r.AccessibleDescription == loc) > 0) { bt = lisBt.Find(r => r.AccessibleDescription == loc) as Button; } else { bt.Location = new Point(xx, yy); bt.AccessibleDescription = loc; bt.Click += Bt_Click; bt.MouseMove += Bt_Click2; lisBt.Add(bt); } DataRow[] rows = dsView.Select("row1='" + row + "' and cln='" + cln + "' and layer1='" + lay + "' and depth='2'"); if (rows != null) { if (rows.Length > 0) { string sts = rows[0]["Status"].ToString(); string location = rows[0]["LOCATION_ID"].ToString(); bt.AccessibleName = location; if (sts == "1") { bt.BackColor = Color.Yellow; } else if (sts == "2") { bt.BackColor = Color.LightSkyBlue; } else if (sts == "0") { bt.BackColor = Color.Green; } } else { bt.BackColor = Color.White; } } xx = xx + bt.Size.Width + 3; } } yy = yy + 30; } yy = yy + 60; } if (panel2.Controls.Count == 0) panel2.Controls.AddRange(lisBt.ToArray()); } void BinMisStock(string locId) { DataTable tb = IBussFactory.Instance().GetMisDataOut(locId, "", ""); if (tb != null) { List MIStock = ConvertHelper.ConvertToList(tb); if (MIStock != null) bgsStock.DataSource = MIStock; } } private void Bt_Click(object sender, EventArgs e) { Button bt = (Button)sender; if(bt!=null) { string loction = bt.AccessibleName; BinMisStock(loction); } } private void Bt_Click2(object sender, EventArgs e) { Button bt = (Button)sender; if (bt != null) { string loction = bt.AccessibleName; ToolTip toolTip1 = new ToolTip(); toolTip1.AutoPopDelay = 5000; toolTip1.InitialDelay = 500; toolTip1.ReshowDelay = 100; toolTip1.ShowAlways = true; toolTip1.SetToolTip(bt, loction); } } List lisBt = new List(); private void simpleButton1_Click(object sender, EventArgs e) { int maxct = 0; string decid = ""; //if (comboBox1.Text == "全部") //{ //} //else { decid = comboBox1.Text; bindview(decid); } //DataSet dsView = IBussFactory.Instance().GetLocStsView(decid, maxct); //if (dsView != null) //{ // gridView1.Columns.Clear(); // foreach (DataRow cln in dsView.Tables[0].Rows) // { // DevExpress.XtraGrid.Columns.GridColumn gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn(); // gridColumn1.AppearanceCell.Font = new System.Drawing.Font("Tahoma", 8F); // gridColumn1.AppearanceCell.Options.UseFont = true; // gridColumn1.Caption = "库位"; // gridColumn1.MinWidth = 30; // gridColumn1.Name = cln["layer"].ToString(); // gridColumn1.FieldName = "LOCATION_ID"; // gridColumn1.Visible = false; // gridColumn1.Width = 30; // DevExpress.XtraGrid.Columns.GridColumn gridColumn2 = new DevExpress.XtraGrid.Columns.GridColumn(); // gridColumn2.AppearanceCell.Font = new System.Drawing.Font("Tahoma", 8F); // gridColumn2.AppearanceCell.Options.UseFont = true; // gridColumn2.Caption = "库位"; // gridColumn2.MinWidth = 30; // gridColumn2.Name = cln["layer"].ToString()+"sts"; // gridColumn2.FieldName = "STS"; // gridColumn2.Visible = false; // gridView1.Columns.Add(gridColumn1); // gridView1.Columns.Add(gridColumn2); // } // if (dsView.Tables[1] != null) // { // gridControl1.DataSource = dsView.Tables[1]; // } //} } private void FrmScada_Load(object sender, EventArgs e) { bindview("1"); } } }