private void 修ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.lvMInfo.SelectedItems.Count == 0) { return; } ListViewItem lvi = this.lvMInfo.SelectedItems[0]; try { frmInput fi = new frmInput("请输入库存数量!", lvi.SubItems[1].Text); string str = fi.ShowInput(); int i = Convert.ToInt32(str); MerchandiseInfoData mid = (MerchandiseInfoData)lvi.Tag; mid.Storage = i; MInfoCortrol.updMInfo(mid); lvi.SubItems[1].Text = i.ToString(); } catch (MessageException ex) { if (ex.Message != "") { MessageBox.Show(ex.Message); } } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (this.lvMType.SelectedItems.Count == 0) { throw new MessageException("请选择要删除的项目!"); } DialogResult dr = MessageBox.Show("您确定要删除该项目吗?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr != DialogResult.No) { MInfoCortrol.delMInfo((MerchandiseInfoData)this.lvMType.SelectedItems[0].Tag); this.lvMType.Items.RemoveAt(this.lvMType.SelectedIndices[0]); } } catch (MessageException ex) { MessageBox.Show(ex.Message); } catch (SqlException) { MessageBox.Show("该项目正在被使用,无法删除!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnAmend_Click(object sender, EventArgs e) { try { if (this.lvMType.SelectedItems.Count == 0) { throw new MessageException("请选择要修改的项目!"); } checkText(); MerchandiseInfoData mid = getMInfo(); mid.ID = ((MerchandiseInfoData)this.lvMType.SelectedItems[0].Tag).ID; MInfoCortrol.updMInfo(mid); ListViewItem lvi = new ListViewItem(mid.Name); lvi.Tag = mid; ListViewItem.ListViewSubItem lvs = new ListViewItem.ListViewSubItem(); MerchandiseTypeData ptd = MTypeCortrol.getMTypeOfID(mid.TypeID); lvs.Text = ptd.Name; lvs.Tag = ptd; lvi.SubItems.Add(lvs); lvi.SubItems.Add(mid.Quantity.ToString()); this.lvMType.Items[this.lvMType.SelectedIndices[0]] = lvi; clear(); } catch (MessageException ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 刷新订单信息 /// </summary> /// <param name="sd">订单信息</param> private void addSInfo(StockInfoData sid) { ListViewItem lvi = new ListViewItem(MInfoCortrol.getMInfoOfID(sid.MID).Name); lvi.Tag = sid; lvi.SubItems.Add(sid.Quantity.ToString()); lvi.SubItems.Add(sid.Price.ToString()); lvi.SubItems.Add(Convert.ToString(sid.Quantity * sid.Price)); this.lvSInfo.Items.Add(lvi); }
/// <summary> /// Ìî³äÊý¾Ýµ½ListView /// </summary> private void fillListView() { this.lvMType.Items.Clear(); foreach (PurveyData p in PurveyCortrol.ls) { if (p.PInfoID == this.pid.ID) { addMIinfo(MInfoCortrol.getMInfoOfID(p.MInfoID)); } } }
private void buttobtnAccessionn2_Click(object sender, EventArgs e) { try { checkText(); MerchandiseInfoData mid = new MerchandiseInfoData(); mid.Name = this.txtName.Text; mid.TypeID = ((MerchandiseTypeData)this.txtGenre.Tag).ID; mid.Quantity = Convert.ToInt32(this.txtQuantity.Text); mid.ID = MInfoCortrol.addMnfo(mid); addMIinfo(mid); clear(); } catch (MessageException ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 增加或修改一条商品信息 /// </summary> /// <param name="sid">商品</param> /// <param name="cortrol">1增加,2修改</param> private void addStoctInfo(StockInfoData sid, int cortrol) { MerchandiseInfoData mid = ((MerchandiseInfoData)MInfoCortrol.getMInfoOfID(sid.MID)); ListViewItem lvi = new ListViewItem(mid.Name); lvi.Tag = mid; lvi.SubItems.Add(sid.Quantity.ToString()); lvi.SubItems.Add(sid.Price.ToString()); lvi.SubItems.Add(Convert.ToString(sid.Quantity * (double)sid.Price)); if (cortrol == 1) { this.lvSInfo.Items.Add(lvi); } else if (cortrol == 2) { this.lvSInfo.Items[this.lvSInfo.SelectedIndices[0]] = lvi; } }
public void refurbish() { this.lvHint.Items.Clear(); foreach (PurveyData pd in PurveyCortrol.ls) { MerchandiseInfoData mid = MInfoCortrol.getMInfoOfID(pd.MInfoID); PurveyInfoData pid = PInfoCortrol.getPInfoOfID(pd.PInfoID); if (mid.Quantity * pid.Days > mid.Storage) { ListViewItem lvi = new ListViewItem(mid.Name); lvi.Tag = pd; lvi.SubItems.Add(mid.Storage.ToString()); lvi.SubItems.Add(mid.Quantity.ToString()); lvi.SubItems.Add(pid.Name); lvi.SubItems.Add(pid.Days.ToString()); int i = -((mid.Storage - (mid.Quantity * pid.Days)) / mid.Quantity); lvi.SubItems.Add(i.ToString()); this.lvHint.Items.Add(lvi); } } }
private void lvHint_DoubleClick(object sender, EventArgs e) { if (this.lvHint.SelectedItems.Count == 0) { return; } ListViewItem lvi = this.lvHint.SelectedItems[0]; PurveyData pd = (PurveyData)lvi.Tag; MerchandiseInfoData mid = MInfoCortrol.getMInfoOfID(pd.MInfoID); foreach (TreeNode tn in this.mTypeTreeView.tvMType.Nodes) { selectNotes(tn, mid.TypeID); } foreach (ListViewItem lv in this.lvMInfo.Items) { if (lv.Tag == mid) { lv.Selected = true; } } }
private static void ps(Graphics g, string name, StockData sd, List <StockInfoData> ls) { Pen pen = new Pen(Brushes.Black); Font f = new Font("宋体", 11); Font fu = new Font("宋体", 11, FontStyle.Underline); g.DrawString(name + "采购单", new Font("宋体", 25), Brushes.Black, new PointF(280, 60)); g.DrawString("定单号:", f, Brushes.Black, new PointF(70, 110)); g.DrawString(sd.StockNo, fu, Brushes.Black, new PointF(125, 110)); g.DrawString("供应商:", f, Brushes.Black, new PointF(70, 140)); g.DrawString(PInfoCortrol.getPInfoOfID(sd.PInfoID).Name, fu, Brushes.Black, new PointF(125, 140)); g.DrawString("下单日期:", f, Brushes.Black, new PointF(590, 140)); g.DrawString(sd.DownDate.ToString("d"), fu, Brushes.Black, new PointF(660, 140)); g.DrawString("定单明细:", f, Brushes.Black, new PointF(70, 190)); int x = 150; int y = 190; int i = 1; for (i = 1; i < 14; i++) { g.DrawLine(pen, new Point(x, y + i * 25), new Point(x + 540, y + i * 25)); } i--; g.DrawLine(pen, new Point(x, y + 25), new Point(x, y + i * 25)); g.DrawLine(pen, new Point(x + 200, y + 25), new Point(x + 200, y + i * 25)); i--; g.DrawLine(pen, new Point(x + 300, y + 25), new Point(x + 300, y + i * 25)); g.DrawLine(pen, new Point(x + 400, y + 25), new Point(x + 400, y + i * 25)); i++; g.DrawLine(pen, new Point(x + 540, y + 25), new Point(x + 540, y + i * 25)); g.DrawString("商品名称", f, Brushes.Black, new PointF(x + 70, y + 30)); g.DrawString("数量", f, Brushes.Black, new PointF(x + 232, y + 30)); g.DrawString("单价", f, Brushes.Black, new PointF(x + 335, y + 30)); g.DrawString("总额", f, Brushes.Black, new PointF(x + 450, y + 30)); g.DrawString("总 计", f, Brushes.Black, new PointF(x + 70, y + 306)); g.DrawString("采购员:", f, Brushes.Black, new PointF(350, 530)); g.DrawString("审 核:", f, Brushes.Black, new PointF(510, 530)); y = 245; i = 1; foreach (StockInfoData sid in ls) { g.DrawString(MInfoCortrol.getMInfoOfID(sid.MID).Name, f, Brushes.Black, new PointF(170, y)); g.DrawString(sid.Quantity.ToString(), f, Brushes.Black, new PointF(375, y)); g.DrawString(sid.Price.ToString(), f, Brushes.Black, new PointF(485, y)); g.DrawString(Convert.ToString(sid.Quantity * sid.Price) + " 元", f, Brushes.Black, new PointF(595, y)); y += 25; i++; if (i > 10) { break; } } }