private void btnSearch_Click(object sender, EventArgs e) { if (txtCode.Text.Trim() == "") { MessageBoxEx.Show("请输入商品编码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Dong.BLL.GoodsInfo bGoods = new Dong.BLL.GoodsInfo(); Dong.Model.GoodsInfo mGoods = new Dong.Model.GoodsInfo(); mGoods = bGoods.GetModel(txtCode.Text.Trim()); if (mGoods != null) { txtCategory.Text = mGoods.CategoryName; txtFactory.Text = mGoods.Factory; txtName.Text = mGoods.GoodsName; txtKC.Text = mGoods.Counts.ToString(); txtSJ.Text = mGoods.Price0.ToString(); txtJJ.Text = mGoods.Price1.ToString(); txtCB.Text = mGoods.Price2.ToString(); txtSuppier.Text = mGoods.SupplierName; txtUnit.Text = mGoods.UnitName; } else { MessageBoxEx.Show("对不起,该商品不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmEditGoods_Load(object sender, EventArgs e) { Dong.BLL.Category catebll = new Dong.BLL.Category(); ddlCategory.DataSource = catebll.GetAllList().Tables[0]; ddlCategory.DisplayMember = "Name"; ddlCategory.ValueMember = "Id"; //绑定单位 Dong.BLL.Unit unitbll = new Dong.BLL.Unit(); ddlUnit.DataSource = unitbll.GetAllList().Tables[0]; ddlUnit.DisplayMember = "Name"; ddlUnit.ValueMember = "Id"; //绑定供应商 Dong.BLL.Supplier supplierbll = new Dong.BLL.Supplier(); ddlSupper.DataSource = supplierbll.GetAllList().Tables[0]; ddlSupper.DisplayMember = "Name"; ddlSupper.ValueMember = "Id"; Dong.BLL.GoodsInfo bll = new Dong.BLL.GoodsInfo(); Dong.Model.GoodsInfo model = new Dong.Model.GoodsInfo(); model = bll.GetModelById(int.Parse(this.Tag.ToString())); if (model != null) { tbCode.Text = model.Code; tbName.Text = model.GoodsName; tbFactory.Text = model.Factory; ddlCategory.SelectedValue = model.Category; ddlUnit.SelectedValue = model.Unit; ddlSupper.SelectedValue = model.Supplier; txtPrice0.Text = model.Price0 == null ? "" : model.Price0.ToString(); txtPrice1.Text = model.Price1 == null ? "" : model.Price1.ToString(); txtPrice2.Text = model.Price2 == null ? "" : model.Price2.ToString(); } }
private void fillGVList(string key, int pageSize, int page) { strSql = key; intPage = page; Dong.BLL.GoodsInfo bll = new Dong.BLL.GoodsInfo(); DataSet ds = new DataSet(); ds = bll.GetListPage(key, pageSize, page); gvList.DataSource = ds.Tables[0]; if (ds.Tables[0].Rows.Count > 0) { intPages(); } }
private void btnDel_Click(object sender, EventArgs e) { //删除会员 string id = gvList.SelectedRows[0].Cells[0].Value.ToString(); if (id != "") { if (MessageBoxEx.Show("确定删除该记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Dong.BLL.GoodsInfo bll = new Dong.BLL.GoodsInfo(); bll.Delete(int.Parse(id)); this.gvList.Rows[0].Selected = true; fillGVList(strSql, intPageSize, intPage); } } else { MessageBoxEx.Show("请选择要删除的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <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.GoodsInfo bVip = new Dong.BLL.GoodsInfo(); int counts = bVip.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; }
protected void Cash() { if (tbZL.Text.Trim() == "") { tbZL.Text = string.Format("{0:F2}", (double.Parse(tbSSJE.Text.Trim()) - double.Parse(tbYS.Text.Trim()))); } else { Dong.BLL.GoodsInfo bGoods = new Dong.BLL.GoodsInfo(); Dong.BLL.SaleInfo bSale = new Dong.BLL.SaleInfo(); Dong.Model.SaleInfo mSale = new Dong.Model.SaleInfo(); frmCash frmP = (frmCash)this.Owner; DataGridView dgv = (DataGridView)frmP.Controls.Find("dGV", true)[0]; for (int i = 0; i < dgv.Rows.Count; i++) { //添加销售记录 double price = double.Parse(dgv.Rows[i].Cells[4].Value.ToString()); mSale.Pid = Dong.Model.GlobalsInfo.bill; mSale.GoodsCode = dgv.Rows[i].Cells[0].Value.ToString(); mSale.Counts = int.Parse(dgv.Rows[i].Cells[3].Value.ToString()); mSale.Price = price; mSale.PriceSum = double.Parse(tbYS.Text); mSale.VipCode = Dong.Model.GlobalsInfo.vipCode; mSale.Oper = Dong.Model.GlobalsInfo.UserName; mSale.IDate = DateTime.Now; bSale.Add(mSale); //减少货物质量 bGoods.UpdateCount(int.Parse(dgv.Rows[i].Cells[3].Value.ToString()), dgv.Rows[i].Cells[0].Value.ToString()); } frmP.ClearForm(); frmP.showPre(); this.Close(); } }
protected void addGoods() { Dong.BLL.GoodsInfo bGoods = new Dong.BLL.GoodsInfo(); Dong.Model.GoodsInfo mGoods = new Dong.Model.GoodsInfo(); mGoods = bGoods.GetModel(tbCode.Text.Trim()); if (mGoods != null) { if (mGoods.Counts > 0) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dGV); row.Cells[0].Value = mGoods.Code; row.Cells[1].Value = mGoods.GoodsName; row.Cells[2].Value = string.Format("{0:F2}", mGoods.Price0); row.Cells[3].Value = "1"; row.Cells[4].Value = string.Format("{0:F2}", (mGoods.Price0 * int.Parse(row.Cells[3].Value.ToString()))); dGV.Rows.Add(row); row.Selected = true; tbCode.Text = ""; //计算总钱数 sumCash(); lblGoodsName.Text = mGoods.GoodsName; lblStock.Text = mGoods.Counts.ToString(); } else { MessageBox.Show("对不起,此商品缺货!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("对不起,没有此商品!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnSave_Click(object sender, EventArgs e) { //验证商品编号 if (tbCode.Text.Trim() == "") { MessageBoxEx.Show("请输入商品编码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); tbCode.Focus(); return; } //验证商品名称 if (tbName.Text.Trim() == "") { MessageBoxEx.Show("请输入商品名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); tbName.Focus(); return; } if (tbFactory.Text.Trim() == "") { MessageBoxEx.Show("请输入商品生产厂家!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); tbFactory.Focus(); return; } if (txtPrice0.Text.Trim() == "") { MessageBoxEx.Show("请输入零售价!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPrice0.Focus(); return; } double price0; if (!double.TryParse(txtPrice0.Text, out price0)) { MessageBoxEx.Show("零售价必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPrice0.Focus(); return; } if (txtPrice1.Text.Trim() == "") { MessageBoxEx.Show("请输入进货价!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPrice1.Focus(); return; } double price1; if (!double.TryParse(txtPrice1.Text, out price1)) { MessageBoxEx.Show("进货价必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPrice1.Focus(); return; } if (txtPrice2.Text.Trim() == "") { MessageBoxEx.Show("请输入成本价!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPrice2.Focus(); return; } double price2; if (!double.TryParse(txtPrice2.Text, out price2)) { MessageBoxEx.Show("成本价必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPrice2.Focus(); return; } Dong.BLL.GoodsInfo bll = new Dong.BLL.GoodsInfo(); Dong.Model.GoodsInfo model = new Dong.Model.GoodsInfo(); model.Code = tbCode.Text; model.GoodsName = tbName.Text; if (ddlCategory.SelectedValue != null && !string.IsNullOrEmpty(ddlCategory.SelectedValue.ToString())) { model.Category = Int32.Parse(ddlCategory.SelectedValue.ToString()); model.CategoryName = ddlCategory.Text; } else { model.CategoryName = ""; } if (ddlUnit.SelectedValue != null && !string.IsNullOrEmpty(ddlUnit.SelectedValue.ToString())) { model.Unit = Int32.Parse(ddlUnit.SelectedValue.ToString()); model.UnitName = ddlUnit.Text; } else { model.UnitName = ""; } if (ddlSupper.SelectedValue != null && !string.IsNullOrEmpty(ddlSupper.SelectedValue.ToString())) { model.Supplier = Int32.Parse(ddlSupper.SelectedValue.ToString()); model.SupplierName = ddlSupper.Text; } else { model.SupplierName = ""; } model.Factory = tbFactory.Text; model.Counts = 0; model.Price0 = price0; model.Price1 = price1; model.Price2 = price2; if (bll.Add(model)) { MessageBoxEx.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); frmGoods frm = (frmGoods)this.Owner; frm.refreshData(); this.Close(); } else { MessageBoxEx.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }