/// <summary> /// 绑定编辑商品的详细信息 /// </summary> private void BindGoodsTest() { goods = new VipSoft.BLL.Goods(); gs = new VipSoft.Model.Goods(); gs = goods.GetModel(GoodsID); lblGoodsCode.Text = gs.GoodsCode; lblGoodsName.Text = gs.Name; lblUnitType.Text = gs.Unit; // lblRemark.Text = gs.Remark; lblNameCode.Text = gs.NameCode; // lblRemark.Text = gs.Remark; lblNameCode.Text = gs.NameCode; lblBuyPrice.Text = gs.BuyPrice.ToString(); //参考进价 lblNumber.Text = gs.Number.ToString(); //当前库存 // txtReferencePrice.Text = gs.BuyPrice.ToString("¥0.00"); if (goodsModify == null) //不是修改商品 { this.txtReferencePrice.Text = ((decimal)gs.BuyPrice).ToString("¥0.00"); } else { this.txtCount.Text = _goodsNumber.ToString(); this.txtReferencePrice.Text = _buyPrice; } }
// 使用多线程读取产品列表,以防止读取产品列表的速度影响窗口显示的速度 private void BindGoodsList() { this.dgvGoodsList.Rows.Clear(); VipSoft.BLL.Goods goods = new VipSoft.BLL.Goods(); DataSet dtGoods = goods.GetList(" GoodsType=0 and ShopID="+PublicState.Master.ShopID + condtion); foreach (DataRow dr in dtGoods.Tables[0].Rows) { this.dgvGoodsList.Rows.Add(dr["ID"], dr["GoodsCode"], dr["Name"], dr["Unit"], dr["BuyPrice"], dr["Number"]); } this.label_Tree_load.Visible = false; condtion = ""; }
/// <summary> /// 编辑时,绑定数据 /// </summary> private void BindGoodsData() { VipSoft.Model.Goods model = new VipSoft.BLL.Goods().GetModel(CurrentGoodsID); if (model==null) { return; } this.Text = "修改产品信息"; this.checkBox_save.Visible = false; this.checkBox_AutoCode.Visible = false; this.textBox_GoodsCode.Enabled = false; this.textBox_Number.Enabled = false; textBox_GoodsCode.Text = model.GoodsCode; textBox_GoodsName.Text = model.Name; textBox_NameCode.Text = model.NameCode; comboBox_Class.SelectedValue = model.ClassID; comboBox_Unit.Text = model.Unit; textBox_Number.Text = model.Number.ToString(); textBox_Point.Text = model.Point.ToString(); textBox_Price.Text = ((decimal)model.Price).ToString("¥0.00"); myMoneyTextBox1.Text = ((decimal)model.BuyPrice).ToString("¥0.00"); textBox_MinPercent.Text = model.MinPercent.ToString(); }
private void toolStripMenuItem_Item_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; TreeNode node = this.treeView_Class.SelectedNode; int id = int.Parse(node.Name.Replace("class_", "")); switch (item.Name) { case "toolStripMenuItem_Edit": this.label_ID.Text = node.Name.Replace("class_", ""); this.textBox_Parent.Text = node.Parent != null ? node.Parent.Text : "根类别"; this.textBox_ClassName.Text = node.Text; this.button_Add.Text = "修改类别"; this.groupBox_manage.Text = "修改类别"; break; case "toolStripMenuItem_Delete": if (this.treeView_Class.SelectedNode.Text == "根类别") return; DialogResult res = MessageBox.Show("您确定要删除这个分类么?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (res == DialogResult.Yes) { VipSoft.BLL.GoodsClass gc = new VipSoft.BLL.GoodsClass(); DataTable listClass = gc.GetList("[ShopID]="+PublicState.Master.ShopID).Tables[0]; CheckHasGoods hasGoods = new CheckHasGoods(); if (hasGoods.Exist(listClass, id.ToString()) != 0) { MessageBox.Show("当前分类下面还有商品,要删除分类,请首先删除该分类下面的全部商品。"); return; } if (gc.Delete(id)) { MessageBox.Show("分类删除成功。"); // 移除节点 node.Remove(); // 写入日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "商品分类管理", string.Format("删除分类成功,名称:{0}父类:{1}", this.textBox_ClassName.Text, this.textBox_Parent.Text), DateTime.Now)); } else MessageBox.Show("删除失败,请重试。"); } break; case "toolStripMenuItem_Add": this.label_ParentID.Text = id.ToString(); //查询该类别下是否有产品,如果有则不能再增加子类别 DataSet ds = new VipSoft.BLL.Goods().GetList("ClassId=" + id + ""); if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("该类别下已有产品!不能再添加子类别"); return; } this.textBox_Parent.Text = node.Text; this.textBox_ClassName.Text = "新类别"; this.button_Add.Text = "增加分类"; this.groupBox_manage.Text = "增加下级分类"; break; } }
private void treeView_Class_AfterSelect(object sender, TreeViewEventArgs e) { this.dgvGoods.Rows.Clear(); string name = e.Node.Name; string condition = " ShopID=" + PublicState.Master.ShopID; if (name == "class_0") { condition += " and GoodsType=0"; } else if (name.IndexOf("class_") != -1) { string classID = name.Substring(6, name.Length - 6); if (!Function.CheckIsLowestClass(dtClass, classID)) { condition += (" and ClassId in (" + Function.GetChildClassListStr(dtClass, classID) + "," + classID + ") and GoodsType=0"); } else { condition += " and ClassId in (" + classID + ") and GoodsType=0"; } } DataSet ds = new VipSoft.BLL.Goods().GetList(condition); foreach (DataRow dr in ds.Tables[0].Rows) { this.dgvGoods.Rows.Add(dr["ID"], dr["GoodsCode"], dr["Name"], dr["Unit"], dr["BuyPrice"], dr["Number"]); } }
// 删除记录 private void DeleteItem() { if (this.dataGridView_List.SelectedRows.Count != 1) return; int goodsID = int.Parse(this.dataGridView_List.SelectedRows[0].Cells[1].Value.ToString()); string goodsCode = this.dataGridView_List.SelectedRows[0].Cells[2].Value.ToString(); string goodsName = this.dataGridView_List.SelectedRows[0].Cells[3].Value.ToString(); DialogResult dRes = MessageBox.Show("您确定要删除此产品么?此操作不可恢复。注意:删除后此产品相关的消费数据统计会出现错乱", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dRes == DialogResult.No) return; VipSoft.BLL.Goods goods = new VipSoft.BLL.Goods(); VipSoft.Model.Goods ginfo = goods.GetModel(goodsID); if (goods.Delete(goodsID)) { // 记录日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品管理", string.Format("删除产品,ID:{0}编号:{1}名称:{2}库存:{3}销售量:{4}售价:{5}积分:{6}最低折扣:{7}", goodsID.ToString(), goodsCode, goodsName, ginfo.Number, ginfo.SaleNumber, ginfo.Price, ginfo.Point, ginfo.MinPercent), DateTime.Now)); // 提示 MessageBox.Show("产品已被删除。"); // 重新绑定 BindList(); } }
/// <summary> /// 绑定商品树 /// </summary> private void BindGoodsTreeThread() { Thread.Sleep(50); //延时100毫秒 VipSoft.BLL.GoodsClass goodsC = new VipSoft.BLL.GoodsClass(); VipSoft.BLL.Goods goods = new VipSoft.BLL.Goods(); string where = "ShopID="+PublicState.Master.ID; DataTable dtClass = goodsC.GetList(where).Tables[0]; DataTable dtGoods = goods.GetList(where).Tables[0]; ExpenseGoodsTreeShowHandler goodsTreeHandler = new ExpenseGoodsTreeShowHandler(BindGoodsTreeInvoke); this.BeginInvoke(goodsTreeHandler, dtClass, dtGoods); }