private void frmInputBill_Load(object sender, EventArgs e) { dGV.AutoGenerateColumns = false; Dong.BLL.InGoods bInGoods = new Dong.BLL.InGoods(); dt = bInGoods.getDetial(this.Tag.ToString()).Tables[0]; BindGrid(); if (dt.Rows.Count > 0) { lblCode.Text = dt.Rows[0]["Pcode"].ToString(); txtOper.Text = dt.Rows[0]["Oper"].ToString(); lblTime.Text = dt.Rows[0]["IDate"].ToString(); } //计算总体数量和价格 double cash = 0; int counts = 0; for (int i = 0; i < dGV.Rows.Count; i++) { double sumPrice = double.Parse(dGV.Rows[i].Cells[5].Value.ToString()); int c = int.Parse(dGV.Rows[i].Cells[4].Value.ToString()); cash = cash + sumPrice; counts = counts + c; } lblCount.Text = counts.ToString(); lblJG.Text = string.Format("{0:F2}", cash); }
private void fillGVList(string key, int pageSize, int page) { strSql = key; intPage = page; Dong.BLL.InGoods bll = new Dong.BLL.InGoods(); DataSet ds = new DataSet(); ds = bll.GetListPage(key, pageSize, page); gvList.DataSource = ds.Tables[0]; if (ds.Tables[0].Rows.Count > 0) { intPages(); } }
/// <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 intPages() { Dong.BLL.InGoods bll = new Dong.BLL.InGoods(); int counts = bll.GetRecordCount(strSql); lblCounts.Text = counts.ToString(); if (counts % intPageSize == 0) { pageCounts = counts / intPageSize; } else { pageCounts = (counts / intPageSize) + 1; } cbPage.Items.Clear(); for (int i = 1; i <= pageCounts; i++) { cbPage.Items.Add(i.ToString()); } cbPage.SelectedIndex = intPage - 1; }