/// <summary> /// 进货单保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { Dong.BLL.InGoods bInGoods = new Dong.BLL.InGoods(); Dong.Model.InGoods mInGoods = new Dong.Model.InGoods(); Dong.BLL.GoodsInfo bGoodsInfo = new Dong.BLL.GoodsInfo(); Dong.Model.GoodsInfo mGoodsInfo = new Dong.Model.GoodsInfo(); for (int i = 0; i < dGV.Rows.Count; i++) { //添加进货信息 mGoodsInfo = bGoodsInfo.GetModel(dGV.Rows[i].Cells[1].Value.ToString()); mInGoods.PCode = lblCode.Text; mInGoods.GoodsCode = dGV.Rows[i].Cells[1].Value.ToString(); mInGoods.Price = double.Parse(dGV.Rows[i].Cells[3].Value.ToString()); mInGoods.Counts = int.Parse(dGV.Rows[i].Cells[4].Value.ToString()); mInGoods.IDate = DateTime.Now.Date; mInGoods.Oper = txtOper.Text; mInGoods.Supplier = mGoodsInfo.Supplier; mInGoods.Remark = ""; bInGoods.Add(mInGoods); //修改商品信息 //进货价格 double oldPrice1 = (double)mGoodsInfo.Price1; mGoodsInfo.Price1 = double.Parse(dGV.Rows[i].Cells[3].Value.ToString()); //数量 mGoodsInfo.Counts = mGoodsInfo.Counts + int.Parse(dGV.Rows[i].Cells[4].Value.ToString()); //成本价 int totalCount = (int)mGoodsInfo.Counts + int.Parse(dGV.Rows[i].Cells[4].Value.ToString()); double totalPrice = (oldPrice1 * (int)mGoodsInfo.Counts) + (double.Parse(dGV.Rows[i].Cells[3].Value.ToString()) * int.Parse(dGV.Rows[i].Cells[4].Value.ToString())); double cbPrice = totalPrice / totalCount; mGoodsInfo.Price2 = cbPrice; bGoodsInfo.Update(mGoodsInfo); } frmInput frm = (frmInput)this.Owner; frm.refreshData(); this.Close(); }
private void btnInput_Click(object sender, EventArgs e) { frmInput frm = new frmInput(); openWindow(frm, frm.Name); }