/// <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> /// 删除采购明细单 /// </summary> /// <param name="stockInfo">采购明细单类</param> /// <returns></returns> public int delStockInfo(StockInfoData stockInfo) { SqlConnection conn = new SqlConnection(connStr); conn.Open(); SqlCommand cmd = new SqlCommand("delete from stockInfo where id = @id", conn); cmd.Parameters.AddWithValue("@id", stockInfo.ID); int i = cmd.ExecuteNonQuery(); conn.Close(); return(i); }
public StockInfoData showSelect(PurveyInfoData p) { this.pid = p; this.ShowDialog(); if (ok == false) { throw new MessageException(""); } StockInfoData sid = new StockInfoData(); sid.MID = ((MerchandiseInfoData)this.txtM.Tag).ID; sid.Quantity = Convert.ToInt32(this.txtQuantity.Text); sid.Price = Convert.ToDouble(this.txtPrice.Text); return(sid); }
/// <summary> /// 更新采购明细单 /// </summary> /// <param name="stockInfo">采购明细单类</param> /// <returns></returns> public int updateStockInfo(StockInfoData stockInfo) { SqlConnection conn = new SqlConnection(connStr); conn.Open(); SqlCommand cmd = new SqlCommand("update stockInfo set sID=@sid,mID = @mID,Price = @Price,Quantity=@Quantity where id = @id", conn); cmd.Parameters.AddWithValue("@sID", stockInfo.SID); cmd.Parameters.AddWithValue("@mID", stockInfo.MID); cmd.Parameters.AddWithValue("@id", stockInfo.ID); cmd.Parameters.AddWithValue("@Price", stockInfo.Price); cmd.Parameters.AddWithValue("@Quantity", stockInfo.Quantity); int i = cmd.ExecuteNonQuery(); conn.Close(); return(i); }
private void btnYes_Click(object sender, EventArgs e) { try { if (this.lvSInfo.Items.Count == 0) { throw new MessageException("该订单没有商品信息!"); } StockData sd = new StockData(); sd.PInfoID = ((PurveyInfoData)this.txtPInfo.Tag).ID; sd.StockDate = Convert.ToDateTime(this.dtp.Value.ToString("d")); sd.StockNo = this.txtNo.Text; sd.UserID = Set.User.ID; List <StockInfoData> ls = new List <StockInfoData>(); foreach (ListViewItem lvi in this.lvSInfo.Items) { StockInfoData sid = new StockInfoData(); sid.MID = ((MerchandiseInfoData)lvi.Tag).ID; sid.Quantity = Convert.ToInt32(lvi.SubItems[1].Text); sid.Price = Convert.ToDouble(lvi.SubItems[2].Text); ls.Add(sid); } SotckCortrol.addStock(sd, ls); StockNoCortrol.No += 1; DialogResult dr = MessageBox.Show("定单已生成,正在等待审核!\n是否继续添加定单?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { clear(); } else { this.Close(); } } catch (MessageException ex) { if (ex.Message != "") { MessageBox.Show(ex.Message); } } catch (SqlException ex) { MessageBox.Show("订单添加失败!\n错误信息\n" + 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; } }
/// <summary> /// 查询采购明细单 /// </summary> /// <param name="stockInfo">采购明细单类</param> /// <returns></returns> public List <StockInfoData> selStockInfo(StockData sd) { List <StockInfoData> list = new List <StockInfoData>(); SqlConnection conn = new SqlConnection(connStr); SqlDataAdapter sda = new SqlDataAdapter("select * from stockInfo where SID=" + sd.ID.ToString(), conn); DataSet ds = new DataSet(); sda.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { StockInfoData stock = new StockInfoData(); stock.ID = (int)dr[0]; stock.SID = (int)dr[1]; stock.MID = (int)dr[2]; stock.Price = Convert.ToDouble(dr[3]); stock.Quantity = (int)dr[4]; list.Add(stock); } return(list); }
private void button1_Click(object sender, EventArgs e) { try { if (this.txtPInfo.Tag == null) { throw new MessageException("请先选择供应商!"); } frmSelectSInfo fss = new frmSelectSInfo(); StockInfoData sid = fss.showSelect((PurveyInfoData)this.txtPInfo.Tag); addStoctInfo(sid, 1); } catch (MessageException ex) { if (ex.Message != "") { MessageBox.Show(ex.Message); } } }
/// <summary> /// 插入采购明细单 /// </summary> /// <param name="stockInfo">采购明细单类</param> /// <returns></returns> public int insertStockInfo(StockInfoData stockInfo) { // private int _iD; //private int _sID; //private int _mID; SqlConnection conn = new SqlConnection(connStr); conn.Open(); SqlCommand cmd = new SqlCommand("insert into stockInfo values(@sID,@mID,@Price,@Quantity)", conn); cmd.Parameters.AddWithValue("@sID", stockInfo.SID); cmd.Parameters.AddWithValue("@mID", stockInfo.MID); cmd.Parameters.AddWithValue("@Price", stockInfo.Price); cmd.Parameters.AddWithValue("@Quantity", stockInfo.Quantity); cmd.ExecuteNonQuery(); cmd.CommandText = "select @@IDENTITY"; int i = Convert.ToInt32(cmd.ExecuteScalar()); conn.Close(); return(i); }
public StockInfoData showSelect(PurveyInfoData p, MerchandiseInfoData mid, string quantity, string price) { this.pid = p; this.btnYes.Text = " 修改"; this.txtM.Text = mid.Name; this.txtM.Tag = mid; this.txtPrice.Text = price; this.txtQuantity.Text = quantity; this.ShowDialog(); if (ok == false) { throw new MessageException(""); } StockInfoData sid = new StockInfoData(); sid.MID = ((MerchandiseInfoData)this.txtM.Tag).ID; sid.Quantity = Convert.ToInt32(this.txtQuantity.Text); sid.Price = Convert.ToDouble(this.txtPrice.Text); return(sid); }
private void button3_Click(object sender, EventArgs e) { try { ListViewItem lvi = this.lvSInfo.SelectedItems[0]; if (lvi == null) { throw new MessageException("请选择要修改的项目!"); } frmSelectSInfo fss = new frmSelectSInfo(); StockInfoData sid = fss.showSelect((PurveyInfoData)this.txtPInfo.Tag, (MerchandiseInfoData)lvi.Tag, lvi.SubItems[1].Text, lvi.SubItems[2].Text); addStoctInfo(sid, 2); } catch (MessageException ex) { if (ex.Message != "") { MessageBox.Show(ex.Message); } } }