public FormDrugOtherInfor() { InitializeComponent(); this.dataGridView1.AutoGenerateColumns = false; this.dataGridView1.RowPostPaint += delegate(object o, DataGridViewRowPostPaintEventArgs ex) { DataGridViewOperator.SetRowNumber((DataGridView)o, ex); }; brm = new Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1); }
public FormPurchaseHistoryBySupplyer() { InitializeComponent(); this.dataGridView1.AutoGenerateColumns = false; this.dataGridView1.RowPostPaint += delegate(object o, DataGridViewRowPostPaintEventArgs ex) { DataGridViewOperator.SetRowNumber((DataGridView)o, ex); }; dtpf.Value = DateTime.Now.AddMonths(-3).Date; dtpt.Value = DateTime.Now.Date; this.toolStrip1.Items.Insert(5, new ToolStripControlHost(dtpf)); this.toolStrip1.Items.Insert(7, new ToolStripControlHost(dtpt)); cms = new Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1); cms.InsertMenuItem("查询选中供货商", SupplyStatic); cms.InsertMenuItem("采购品种汇总", DrugStatic); cms.InsertMenuItem("全部显示", ShowAll); cms.InsertMenuItem("统计该药品购销情况", SupplyAndSale); cms.InsertMenuItem("abc", GetAbc); }
public Form_PurchaseOrderImpt() { InitializeComponent(); #region 绑定类型 var ordertypes = EnumToListHelper.ConverEnumToList(typeof(PurchaseDrugTypes)).Where(r => r.Name != "食品").ToList(); this.toolStripComboBox1.ComboBox.DisplayMember = "Name"; this.toolStripComboBox1.ComboBox.ValueMember = "Id"; this.toolStripComboBox1.ComboBox.DataSource = ordertypes; #endregion #region DataGridView初始化 this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dataGridView1.RowPostPaint += (s, e) => DataGridViewOperator.SetRowNumber(this.dataGridView1, e); this.dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dataGridView2.RowPostPaint += (s, e) => DataGridViewOperator.SetRowNumber(this.dataGridView2, e); #endregion #region 右键菜单 BugsBox.Pharmacy.UI.Common.BaseRightMenu brm = new BugsBox.Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1); #endregion #region 清理表格数据 Action ClearData = () => { this.ListDetails.Clear(); this.dataGridView1.DataSource = null; this.ListDetailsWaitingImpt.Clear(); this.dataGridView2.DataSource = null; }; #endregion #region 打开EXCEL文件 this.toolStripButton1.Click += (s, e) => { OpenFileDialog ofd = new OpenFileDialog { Filter = "XLS文件|*.xls|XLSX文件|*.xlsx", }; var re = ofd.ShowDialog(); if (re != System.Windows.Forms.DialogResult.OK) { return; } FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read); NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(fs); int sheetCount = book.NumberOfSheets; NPOI.SS.UserModel.ISheet sheet = book.GetSheetAt(0); #region 简单验证一下excel表格 if (sheet == null) { MessageBox.Show("模板文件出错,请检查!"); return; } NPOI.SS.UserModel.IRow row = sheet.GetRow(0); if (row == null) { MessageBox.Show("模板文件出错,请检查!"); return; } int firstCellNum = row.FirstCellNum; int lastCellNum = row.LastCellNum; if (firstCellNum == lastCellNum) { MessageBox.Show("模板文件出错,请检查!"); return; } #endregion ClearData(); for (int i = 1; i < sheet.LastRowNum + 1; i++) { var sheetrow = sheet.GetRow(i); Business.Models.PurchaseOrderImpt m = new Business.Models.PurchaseOrderImpt(); m.ProductGeneralName = sheet.GetRow(i).Cells[0].StringCellValue; m.DosageName = sheet.GetRow(i).Cells[1].StringCellValue; m.SpecificName = sheet.GetRow(i).Cells[2].StringCellValue; m.MeasurementName = sheet.GetRow(i).Cells[3].StringCellValue; m.FactoryName = sheet.GetRow(i).Cells[4].StringCellValue; m.Origin = sheet.GetRow(i).Cells[5].StringCellValue; m.Amount = decimal.Parse(sheet.GetRow(i).Cells[6].NumericCellValue.ToString()); m.UnitPrice = decimal.Parse(sheet.GetRow(i).Cells[7].NumericCellValue.ToString()); m.TaxRate = decimal.Parse(sheet.GetRow(i).Cells[8].NumericCellValue.ToString()); this.ListDetails.Add(m); } this.dataGridView1.DataSource = this.ListDetails; this.dataGridView1.Columns["DruginfoId"].Visible = false; }; #endregion #region 生成模板文件 this.toolStripButton4.Click += (s, e) => { DownlodExcel(); MessageBox.Show("导出成功!"); }; #endregion #region 务器端验证 this.toolStripButton2.Click += (s, e) => { if (this.dataGridView1.Rows.Count <= 0) { return; } var result = this.PharmacyDatabaseService.CheckForPurchaseOrderDetails(this.ListDetails, out msg).ToList(); if (result.Any(r => r.DrugInfoId == Guid.Empty)) { MessageBox.Show("有一个或多个记录没有验证成功,请检查品名,剂型,规格等基本信息!您可以修改后再尝试验证!"); } this.ListDetails = result.Where(r => r.DrugInfoId == Guid.Empty).ToList(); this.dataGridView1.DataSource = ListDetails; this.ListDetailsWaitingImpt = result.Where(r => r.DrugInfoId != Guid.Empty).ToList(); this.dataGridView2.DataSource = this.ListDetailsWaitingImpt; this.dataGridView2.Columns["DrugInfoId"].Visible = false; this.dataGridView2.Refresh(); }; #endregion #region 导入按钮click this.toolStripButton3.Click += (s, e) => { if (this.ListDetailsWaitingImpt.Count <= 0) { return; } if (this.OnPurchaseOrderImpt != null) { PurchaseOrderImptEventArgs args = new PurchaseOrderImptEventArgs { ImptList = this.ListDetailsWaitingImpt }; this.OnPurchaseOrderImpt(args); } }; #endregion }
public FormWareHouseZonePosition() { InitializeComponent(); #region 右键打印单条货位条码 RightMenu = new Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1); RightMenu.InsertMenuItem("打印该货位的条码", delegate() { var re = MessageBox.Show("需要打印该行货位条码码?", "提示", MessageBoxButtons.OKCancel); if (re == System.Windows.Forms.DialogResult.Cancel) { return; } if (!System.IO.File.Exists("resources\\名称.lbx")) { MessageBox.Show("条码打印模板文件不存在,请增加一个!"); return; } bpac.DocumentClass doc = new DocumentClass(); doc.Open("resources\\名称.lbx"); Business.Models.WareHouseZonePositionModel m = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.WareHouseZonePositionModel; doc.GetObject("Title").Text = m.WareHouseZoneName + " " + m.Name; doc.SetBarcodeData(0, m.BarCode); doc.StartPrint("", PrintOptionConstants.bpoDefault); doc.PrintOut(1, PrintOptionConstants.bpoDefault); doc.EndPrint(); doc.Close(); }); #endregion this.EleModel = SearialiserHelper <Ele_Lab> .DeSerializeFileToObj("EleSetup.bin"); if (this.EleModel.IsEnabled) { if (elelab.unart_manage.com_manage.FirstOrDefault() == null) { int[] ss = new int[] { int.Parse(this.EleModel.PortName.Substring(3)) }; elelab.unart_manage.init_com_sys(ss); } } this.button2.Visible = this.EleModel.IsEnabled; this.dataGridView1.RowPostPaint += delegate(object o, DataGridViewRowPostPaintEventArgs ex) { DataGridViewOperator.SetRowNumber((DataGridView)o, ex); }; this.dataGridView1.ReadOnly = true; this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; #region 插入仓库数据到combo和事件 this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; this.comboBox2.DropDownStyle = ComboBoxStyle.DropDownList; var w = this.PharmacyDatabaseService.AllWarehouses(out msg).Where(r => r.Deleted == false).OrderBy(r => r.Name).ToList(); w.Insert(0, new Models.Warehouse { Name = "全部", Id = Guid.Empty, }); this.comboBox1.ValueMember = "Id"; this.comboBox1.DisplayMember = "Name"; this.comboBox1.DataSource = w; this.comboBox1.SelectedIndex = 0; var wz = this.PharmacyDatabaseService.AllWarehouseZones(out msg).Where(r => r.Deleted == false).OrderBy(r => r.Name).ToList(); var wzt = new List <Models.WarehouseZone>(); wzt.Add( new Models.WarehouseZone { Name = "全部", Id = Guid.Empty, }); this.comboBox2.ValueMember = "Id"; this.comboBox2.DisplayMember = "Name"; this.comboBox2.DataSource = wzt; this.comboBox2.SelectedIndex = 0; this.comboBox1.SelectedIndexChanged += (sender, e) => { var wzs = wz.Where(r => r.WarehouseId == (Guid)this.comboBox1.SelectedValue).OrderBy(r => r.Name).ToList(); wzs.Insert(0, new Models.WarehouseZone { Name = "全部", Id = Guid.Empty, }); this.comboBox2.ValueMember = "Id"; this.comboBox2.DisplayMember = "Name"; this.comboBox2.DataSource = wzs; this.comboBox2.SelectedIndex = 0; }; #endregion //批量创建 this.toolStripButton2.Click += (sender, e) => { FormWareHouseZonePosition_Editor frm = new FormWareHouseZonePosition_Editor(w, wz); frm.Show(this); }; #region 修改ACTION Action <object, EventArgs> EditPostionAction = (sender, e) => { if (this.dataGridView1.CurrentRow == null) { return; } var c = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.WareHouseZonePositionModel; using (FormWareHouseZonePositionEdit frm = new FormWareHouseZonePositionEdit(w, wz, c)) { var re = frm.ShowDialog(); if (re == System.Windows.Forms.DialogResult.OK) { this.toolStripButton1_Click(null, null); } } }; #endregion //修改 this.toolStripButton3.Click += (sender, e) => EditPostionAction(sender, e); //Datagridview双击修该货位 this.dataGridView1.CellDoubleClick += (sender, e) => { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } EditPostionAction(null, null); }; }
public FormPurchaseHistoryBySupplyer() { InitializeComponent(); this.dataGridView1.AutoGenerateColumns = false; this.dataGridView1.RowPostPaint += delegate(object o, DataGridViewRowPostPaintEventArgs ex) { DataGridViewOperator.SetRowNumber((DataGridView)o, ex); }; dtpf.Value = DateTime.Now.AddMonths(-3).Date; dtpt.Value = DateTime.Now.Date; this.toolStrip1.Items.Insert(5, new ToolStripControlHost(dtpf)); this.toolStrip1.Items.Insert(7, new ToolStripControlHost(dtpt)); cms = new Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1); cms.InsertMenuItem("查询选中供货商", SupplyStatic); cms.InsertMenuItem("查看选中供货商资料", delegate() { var u = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.SupplyUnitHistoryDrugList; Models.SupplyUnit su = this.PharmacyDatabaseService.GetSupplyUnit(out msg, u.SupplyUnitId); UserControls.ucSupplyUnit us = new UserControls.ucSupplyUnit(su, false); Form f = new Form(); f.Text = su.Name; f.AutoSize = true; f.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; Panel p = new Panel(); p.AutoSize = true; p.Controls.Add(us); f.Controls.Add(p); f.ShowDialog(); }); cms.InsertMenuItem("查看选中品种资料", delegate() { var u = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.SupplyUnitHistoryDrugList; Models.DrugInfo di = this.PharmacyDatabaseService.GetDrugInfo(out msg, u.DrugInfoId); if (di == null) { return; } UI.UserControls.ucGoodsInfo ucControl = new UserControls.ucGoodsInfo(di); Form f = new Form(); f.WindowState = FormWindowState.Normal; f.StartPosition = FormStartPosition.CenterScreen; f.Text = di.ProductGeneralName; f.AutoSize = true; f.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; Panel p = new Panel(); p.AutoSize = true; p.Controls.Add(ucControl); f.Controls.Add(p); Forms.Common.SetControls.SetControlReadonly(f, true); f.ShowDialog(); }); cms.InsertMenuItem("按选中品种批号查询", delegate() { if (this.ListS.Count > 0) { var c = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.SupplyUnitHistoryDrugList; if (BtchFrm == null || BtchFrm.IsDisposed) { BtchFrm = new Form_FormPurchaseHistoryBySupplyer_Batch(c.batchNumber); } BtchFrm.StartPosition = FormStartPosition.CenterScreen; BtchFrm.TopMost = true; BtchFrm.Show(this); BtchFrm.GetBatch += (sender, ex) => { if (ex.IsPrecise) { var qre = this.ListS.Where(r => r.batchNumber == ex.Batch); this.dataGridView1.DataSource = qre.ToList(); } else { var qre = this.ListS.Where(r => r.batchNumber.Contains(ex.Batch)); this.dataGridView1.DataSource = qre.ToList(); } }; } }); cms.InsertMenuItem("采购品种汇总", DrugStatic); cms.InsertMenuItem("全部显示", ShowAll); cms.InsertMenuItem("统计该药品购销情况", SupplyAndSale); tsmi = new ToolStripMenuItem("打开采购单"); cms.InsertStripMenuItems(tsmi, InsertDropDownMenuEvt); tsmi = new ToolStripMenuItem("打开验收单"); cms.InsertStripMenuItems_Checking(tsmi, this.InsertDropDownMenuEvt_Checking); }
public FormOrderReturnDetailIndex() { InitializeComponent(); BugsBox.Pharmacy.UI.Common.BaseRightMenu brm = new BugsBox.Pharmacy.UI.Common.BaseRightMenu(this.dataGridView1); brm.InsertMenuItem("导出查询结果", delegate() { MyExcelUtls.DataGridview2Sheet(this.dataGridView1, "销售品种退货记录"); }); brm.InsertMenuItem("查看销退详情", delegate() { if (this.dataGridView1.CurrentRow == null) { return; } var m = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.SalesOrderReturnDetailModel; var orderReturn = PharmacyDatabaseService.GetSalesOrderReturn(out msg, m.SalesOrderReturnId); using (FormSalesOrderReturn frm = new FormSalesOrderReturn(orderReturn)) { frm.ShowDialog(); } }); brm.InsertMenuItem("查看销售单", delegate() { if (this.dataGridView1.CurrentRow == null) { return; } var m = this.dataGridView1.CurrentRow.DataBoundItem as Business.Models.SalesOrderReturnDetailModel; SalesOrder so = this.PharmacyDatabaseService.GetSalesOrder(out msg, m.SalesOrderId); using (FormSalesOrderEdit frm = new FormSalesOrderEdit(so, true)) { frm.ShowDialog(); } }); Business.Models.SalesOrderReturnDetailQueryModel q = null; //初始化查询条件 Action InitQuery = () => { this.dateTimePicker1.Value = DateTime.Now.Date.AddDays(-3); this.dateTimePicker2.Value = DateTime.Now.Date; q = new Business.Models.SalesOrderReturnDetailQueryModel { DTF = this.dateTimePicker1.Value, DTT = this.dateTimePicker2.Value.AddDays(1) }; this.salesOrderReturnDetailQueryModelBindingSource.Clear(); this.salesOrderReturnDetailQueryModelBindingSource.Add(q); }; InitQuery(); #region 初始化表格控件 this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.ReadOnly = true; this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dataGridView1.RowPostPaint += (s, e) => DataGridViewOperator.SetRowNumber(this.dataGridView1, e); this.dataGridView1.AllowUserToOrderColumns = true; #endregion #region 钮事件 this.toolStripButton1.Click += (s, e) => { this.Validate(); q.DTT = this.dateTimePicker2.Value.AddDays(1); q.DTF = this.dateTimePicker1.Value; var re = this.PharmacyDatabaseService.GetSalesOrderReturnDetailModels(q, out msg).ToList(); re.Add(new Business.Models.SalesOrderReturnDetailModel { ProductGeneralName = "合计", ReturnAmount = re.Sum(r => r.ReturnAmount), Price = re.Sum(r => decimal.Round(r.ReturnAmount * r.UnitPrice, 4)) }); this.dataGridView1.DataSource = re; this.dataGridView1.Columns["DrugInfoId"].Visible = false; this.dataGridView1.Columns["CreateTime"].Visible = false; this.dataGridView1.Columns["ReturnEmName"].Visible = false; this.dataGridView1.Columns["Id"].Visible = false; this.dataGridView1.Columns["SalesOrderId"].Visible = false; this.dataGridView1.Columns["SalesOrderReturnId"].Visible = false; Business.Models.SalesOrderReturnDetailModel m = new Business.Models.SalesOrderReturnDetailModel(); PropertyInfo[] pis = m.GetType().GetProperties(); foreach (PropertyInfo pi in pis) { int a = (pi.GetCustomAttributes(typeof(DataMemberAttribute), false)[0] as DataMemberAttribute).Order; if (a < 0) { continue; } this.dataGridView1.Columns[pi.Name].DisplayIndex = a; } }; this.toolStripButton2.Click += (s, e) => { InitQuery(); }; this.toolStripButton3.Click += (s, e) => { MyExcelUtls.DataGridview2Sheet(this.dataGridView1, "销售品种退货记录"); }; #endregion }
public BasicInfoRightMenu(System.Windows.Forms.DataGridView Datagridview) { this.Datagridview = Datagridview; brm = new BugsBox.Pharmacy.UI.Common.BaseRightMenu(this.Datagridview); }