private void buttonPreview_Click(object sender, EventArgs e) { var worksheet = this.reoGridControlMain.Worksheets[0]; StandardFormPreviewExcel formPreview = new StandardFormPreviewExcel("盘点单预览"); if (formPreview.SetPatternTable(@"Excel\StockInfoCheckTicket.xlsx") == false) { this.Close(); return; } WMSEntities wmsEntities = new WMSEntities(); if (worksheet.SelectionRange.Rows != 1) { MessageBox.Show("请选择一项进行预览", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int stockInfoCheckID; try { stockInfoCheckID = int.Parse(worksheet[worksheet.SelectionRange.Row, 0].ToString()); } catch { MessageBox.Show("请选择一项导出", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } StockInfoCheckTicket stockInfoCheck1 = null; try { wmsEntities = new WMSEntities(); stockInfoCheck1 = (from s in wmsEntities.StockInfoCheckTicket where s.ID == stockInfoCheckID select s).FirstOrDefault(); } catch { MessageBox.Show("加载盘点单数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); return; } if (stockInfoCheck1 == null) { MessageBox.Show("要查看的项目已不存在,请确认后操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } StockInfoCheckTicketView StockInfoCheckTicketView = (from stv in wmsEntities.StockInfoCheckTicketView where stv.ID == stockInfoCheckID select stv).FirstOrDefault(); StockInfoCheckTicketItemView [] StockInfoCheckTicketItemView = (from p in wmsEntities.StockInfoCheckTicketItemView where p.StockInfoCheckTicketID == StockInfoCheckTicketView.ID select p).ToArray(); if (StockInfoCheckTicketView == null) { MessageBox.Show("盘点单不存在,请重新查询!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (StockInfoCheckTicketView != null) { formPreview.AddData("StockInfoCheckTicket", StockInfoCheckTicketView); } formPreview.AddData("StockInfoCheckTicketItem", StockInfoCheckTicketItemView); formPreview.Show(); }
private void button_additeam_Click(object sender, EventArgs e) { int[] ids = Utilities.GetSelectedIDs(this.reoGridControlMain); if (ids.Length != 1) { MessageBox.Show("请选择一项"); return; } else if ((ids.Length == 1)) { int stockiofocheckid = ids[0]; wmsEntities = new WMSEntities(); var personid = (from kn in wmsEntities.StockInfoCheckTicketView where kn.ID == stockiofocheckid select kn.PersonID).FirstOrDefault(); this.personid = Convert.ToInt32(personid); var a1 = new FormStockInfoCheckTicketComponentModify(this.projectID, this.warehouseID, this.userID, this.personid, stockiofocheckid); StockInfoCheckTicket stockInfoCheck1 = null; try { wmsEntities = new WMSEntities(); stockInfoCheck1 = (from s in wmsEntities.StockInfoCheckTicket where s.ID == stockiofocheckid select s).FirstOrDefault(); } catch { MessageBox.Show("加载盘点单数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); return; } if (stockInfoCheck1 == null) { MessageBox.Show("要查看的项目已不存在,请确认后操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } a1.SetAddFinishedCallback((CheckID) => { this.checkid = CheckID; //更改盘点信息 StockInfoCheckTicket stockInfoCheck = null; try { wmsEntities = new DataAccess.WMSEntities(); stockInfoCheck = (from s in wmsEntities.StockInfoCheckTicket where s.ID == this.checkid select s).FirstOrDefault(); } catch { MessageBox.Show("加载盘点单数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); return; } if (stockInfoCheck == null) { MessageBox.Show("要修改的项目已不存在,请确认后操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } stockInfoCheck.LastUpdateUserID = Convert.ToString(userID); stockInfoCheck.LastUpdateTime = DateTime.Now; try { wmsEntities.SaveChanges(); } catch { MessageBox.Show("修改盘点单操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.pagerWidget.Search(false, checkid); }); a1.SetMode(FormMode.CHECK); a1.Show(); } }