private void addPInfo_Click(object sender, EventArgs e) { try { if (this.lvMInfo.SelectedItems.Count == 0) return; frmSelectPInfo fspi = new frmSelectPInfo(); PurveyInfoData pid = (PurveyInfoData)fspi.ShowSelect(); foreach (ListViewItem lvi in this.lvPurvey.Items) { if ((PurveyInfoData)lvi.Tag == pid) { lvi.Selected = true; return; } } frmInput fi = new frmInput("请输入供应价格"); string str = fi.ShowInput(); double price = Convert.ToDouble(str); PurveyData pd = new PurveyData(); pd.PInfoID = pid.ID; pd.MInfoID = ((MerchandiseInfoData)this.lvMInfo.SelectedItems[0].Tag).ID; pd.Price = price; int i = PurveyCortrol.addPurevey(pd); pd.ID = i; addPurevey(pid, pd); } catch (MessageException ex) { if (ex.Message != "") MessageBox.Show(ex.Message); } }
private void btnPInfoID_Click(object sender, EventArgs e) { try { if (this.lvSInfo.Items.Count > 0) { throw new MessageException("已经添加了商品,请先清除商品或点重置按钮!"); } frmSelectPInfo fspi = new frmSelectPInfo(); PurveyInfoData pid = (PurveyInfoData)fspi.ShowSelect(); this.txtPInfo.Text = pid.Name; this.txtPInfo.Tag = pid; } catch (MessageException ex) { if (ex.Message != "") { MessageBox.Show(ex.Message); } } }