private void button1_Click(object sender, EventArgs e) { //FormSupplyRemind.RemindStockinfo(); FormSupplyRemind.RemindStockinfoClick(); //this.button2.Visible = false; this.Run = true; this.Run1 = true; }
private void FormMain_SizeChanged(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { FormSupplyRemind.HideForm(); } else if (this.WindowState == FormWindowState.Maximized && this.button2.Visible == false) { //FormSupplyRemind.RemindStockinfo(); FormSupplyRemind.ShowForm(); } }
private void comboBoxWarehouse_SelectedIndexChanged(object sender, EventArgs e) { this.warehouse = ((ComboBoxItem)this.comboBoxWarehouse.SelectedItem).Value as Warehouse; GlobalData.WarehouseID = this.warehouse.ID; this.panelRight.Controls.Clear(); if (this.Run == true) { FormSupplyRemind.RemindStockinfo(); } this.Run = true; this.treeViewLeft.SelectedNode = null; }
private void comboBoxProject_SelectedIndexChanged(object sender, EventArgs e) { this.project = ((ComboBoxItem)this.comboBoxProject.SelectedItem).Value as Project; GlobalData.ProjectID = this.project.ID; this.panelRight.Controls.Clear(); if (this.Run1 == true) { FormSupplyRemind.RemindStockinfo(); } this.treeViewLeft.SelectedNode = null; this.Run1 = true; }
public static void ShowForm() { if (instance == null) { instance = new FormSupplyRemind(); } if (instance.IsDisposed) { return; } instance.timer.Start(); instance.Show(); instance.Opacity = 100; }
public static void HideForm() { if (instance == null) { instance = new FormSupplyRemind(); } if (instance.IsDisposed) { return; } instance.timer.Stop(); instance.Hide(); instance.Opacity = 0; //if (instance.HidedCallback!= null) //{ // instance.HidedCallback(); //} }
public static void RemindStockinfo() { if (instance == null) { instance = new FormSupplyRemind(); } if (instance.IsDisposed) { return; } instance.Show(); //instance.Hide(); instance.timer.Start(); if (instance.HidedCallback != null) { instance.HidedCallback(); } instance.stringBuilder = new StringBuilder(); new Thread(new ThreadStart(() => { try { WMSEntities wmsEntities = new WMSEntities(); string sql = ""; sql = "select TOP 50 SupplyView.SupplierName,SupplyView.ComponentName,SupplyView.No,(select (sum(StockInfoView.ShipmentAreaAmount)+sum(StockInfoView.OverflowAreaAmount)) from StockInfoView where SupplyView.No =StockInfoView.SupplyNo) stock_Sum,SupplyView.SafetyStock from SupplyView where (select (sum(StockInfoView.ShipmentAreaAmount)+sum(StockInfoView.OverflowAreaAmount)) from StockInfoView where SupplyView.No =StockInfoView.SupplyNo)<SupplyView.SafetyStock and IsHistory =0"; sql = sql + "and ProjectID=" + GlobalData.ProjectID; sql = sql + "and WarehouseID=" + GlobalData.WarehouseID; wmsEntities.Database.Connection.Open(); DataTable DataTabledt1 = new DataTable();// 实例化数据表 SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, (SqlConnection)wmsEntities.Database.Connection); sqlDataAdapter.Fill(DataTabledt1); wmsEntities.Database.Connection.Close(); int count = DataTabledt1.Rows.Count; for (int i = 0; i < count; i++) { string SupplierName = DataTabledt1.Rows[i][0].ToString(); string ComponentName = DataTabledt1.Rows[i][1].ToString(); string No = DataTabledt1.Rows[i][2].ToString(); string stock_Sum = DataTabledt1.Rows[i][3].ToString(); string SaftyStock = DataTabledt1.Rows[i][4].ToString(); instance.stringBuilder.Append(SupplierName + " " + ComponentName + " " + No + " " + "库存量" + " " + stock_Sum + " " + "已小于安全库存" + " " + SaftyStock + "\r\n" + "\r\n"); } //日期查询 string sql1 = ""; sql1 = @"select TOP 50 StockInfoView.SupplierName,StockInfoView.ComponentName,StockInfoView.SupplyNo,StockInfoView.InventoryDate , (select SupplyView.ValidPeriod from SupplyView where StockInfoView.SupplyID = SupplyView.ID )ValidPeriod,(select SupplyView.IsHistory from SupplyView where StockInfoView.SupplyID = SupplyView.ID )IsHIstory, GETDATE() Date_Now,(select dateadd(day, (select SupplyView.ValidPeriod from SupplyView where StockInfoView.SupplyID = SupplyView.ID), StockInfoView.InventoryDate))EndDate ,datediff(day, GETDATE(), (select dateadd(day, (select SupplyView.ValidPeriod from SupplyView where StockInfoView.SupplyID = SupplyView.ID), StockInfoView.InventoryDate))) dayss from StockInfoView where(select SupplyView.IsHistory from SupplyView where StockInfoView.SupplyID= SupplyView.ID)= 0 and datediff(day, GETDATE(), (select dateadd(day, (select SupplyView.ValidPeriod from SupplyView where StockInfoView.SupplyID= SupplyView.ID), StockInfoView.InventoryDate)))<= 30"; sql1 = sql1 + "and ProjectID=" + GlobalData.ProjectID; sql1 = sql1 + "and WarehouseID=" + GlobalData.WarehouseID; DataTable DataTabledt2 = new DataTable();// 实例化数据表 SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter(sql1, (SqlConnection)wmsEntities.Database.Connection); sqlDataAdapter2.Fill(DataTabledt2); int count2 = DataTabledt2.Rows.Count; wmsEntities.Database.Connection.Close(); for (int j = 0; j < count2; j++) { string SupplierName = DataTabledt2.Rows[j][0].ToString(); string ComponentName = DataTabledt2.Rows[j][1].ToString(); string SupplyNo = DataTabledt2.Rows[j][2].ToString(); string InventoryDate = DataTabledt2.Rows[j][3].ToString(); string days = DataTabledt2.Rows[j][8].ToString(); if (Convert.ToInt32(days) <= 0) { instance.stringBuilder.Append(SupplierName + " " + ComponentName + " " + SupplyNo + " " + "存货日期" + " " + InventoryDate + " " + "已过期" + "\r\n" + "\r\n"); } else if (Convert.ToInt32(days) > 0) { instance.stringBuilder.Append(SupplierName + " " + ComponentName + " " + SupplyNo + " " + "存货日期" + " " + InventoryDate + " " + "有效期还剩" + days + "天" + "\r\n" + "\r\n"); } } } catch { instance.stringBuilder = new StringBuilder(); instance.stringBuilder.Append("刷新失败,请检查网络连接"); if (instance.IsDisposed) { return; } instance.Invoke(new Action(() => { while (true) { if (instance.IsHandleCreated) { break; } Thread.Sleep(10); } instance.Show(); instance.textBox1.Text = "刷新失败,请检查网络连接"; instance.textBox1.ForeColor = Color.Red; instance.Opacity = 100; })); if (instance.ShowCallback != null) { instance.ShowCallback(); } return; } while (true) { if (instance.IsHandleCreated) { break; } Thread.Sleep(10); } instance.CheckFinished = true; if (instance.stringBuilder.ToString() != "") { if (instance.IsDisposed) { return; } instance.Invoke(new Action(() => { instance.Show(); instance.Opacity = 100; })); if (instance.ShowCallback != null) { instance.ShowCallback(); } } else { instance.Opacity = 0; instance.Hide(); if (instance.HidedCallback != null) { instance.HidedCallback(); } return; } if (instance.IsDisposed) { return; } instance.Invoke(new Action(() => { if (instance.IsDisposed) { return; } else { instance.textBox1.Text = instance.stringBuilder.ToString(); //if (instance.textBox1.Text == "刷新失败,请检查网络连接") //{ // instance.textBox1.ForeColor = Color.Red; //} //else if (instance.textBox1.Text == "") //{ // instance.Visible = false; // if (instance.HidedCallback != null) // { // instance.HidedCallback(); // } //} //else //{ instance.textBox1.ForeColor = Color.Black; //} } })); })).Start(); }
private void FormMain_Load(object sender, EventArgs e) { if (this.supplierid == -1) { FormSupplyRemind.SetFormHidedCallback(() => { this.button2.Visible = true; }); FormSupplyRemind.SetFormShowCallback(() => { this.button2.Visible = false; }); FormSupplyRemind.RemindStockinfo(); } else if (this.supplierid != -1) { this.button2.Visible = false; } //刷新左边树形框 this.RefreshTreeView(); //刷新顶部 this.labelUsername.Text = this.user.Username; this.labelAuth.Text = this.user.AuthorityName + " :"; //窗体大小根据显示屏改变 int DeskWidth = Screen.PrimaryScreen.WorkingArea.Width; int DeskHeight = Screen.PrimaryScreen.WorkingArea.Height; this.Width = Convert.ToInt32(DeskWidth * 0.8); this.Height = Convert.ToInt32(DeskHeight * 0.8); new Thread(() => { //下拉栏显示仓库 WMSEntities wms = new WMSEntities(); var allWarehouses = (from s in wms.Warehouse select s).ToArray(); var allProjects = (from s in wms.Project select s).ToArray(); if (this.IsDisposed) { return; } this.Invoke(new Action(() => { this.comboBoxWarehouse.Items.AddRange((from w in allWarehouses select new ComboBoxItem(w.Name, w)).ToArray()); for (int i = 0; i < this.comboBoxWarehouse.Items.Count; i++) { if (((Warehouse)(((ComboBoxItem)this.comboBoxWarehouse.Items[i]).Value)).ID == this.warehouse.ID) { this.comboBoxWarehouse.SelectedIndex = i; break; } } this.comboBoxProject.Items.AddRange((from p in allProjects select new ComboBoxItem(p.Name, p)).ToArray()); for (int i = 0; i < this.comboBoxWarehouse.Items.Count; i++) { if (((Project)(((ComboBoxItem)this.comboBoxProject.Items[i]).Value)).ID == this.project.ID) { this.comboBoxProject.SelectedIndex = i; break; } } })); }).Start(); }