private void btnOk_Click(object sender, EventArgs e) { //判断是新增还是修改 if (CheckEmpty()) { CategoryInfoBLL bll = new CategoryInfoBLL(); CategoryInfo cat = new CategoryInfo(); cat.Catname = txtCName.Text; cat.Catnum = txtCNum.Text; cat.Remark = txtCRemark.Text; if (this.Tp == 1) { cat.Delflag = 0; cat.Subtime = DateTime.Now; cat.Subby = 1; } else if (this.Tp == 2) { cat.Catid = Convert.ToInt32(labId.Text); } string msg = bll.SaveCategory(cat, this.Tp) ? "操作成功" : "操作失败"; MessageBox.Show(msg); this.Close(); } }
private void btnDeleteCategory_Click(object sender, EventArgs e) { CategoryInfoBLL bll = new CategoryInfoBLL(); if (dgvCategory.SelectedRows.Count <= 0) { msg.MsgDivShow("请选择要删除的项", 1); return; } if (MessageBox.Show("确定删除该产品吗?", "删除商品", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { int id = ((CategoryInfo)dgvCategory.SelectedRows[0].DataBoundItem).CId; ProductInfoBLL pbll = new ProductInfoBLL(); if (pbll.GetProCountByCId(id) > 0) { msg.MsgDivShow("该类别下有很多商品部能删除", 1); return; } string strMsg = bll.SoftDeleteCategoryInfo(id) ? "删除成功" : "删除失败"; msg.MsgDivShow(strMsg, 1); LoadCategoryInfoByDelFlag(0); } else { msg.MsgDivShow("您已经取消删除", 1); } }
private void btnOk_Click(object sender, EventArgs e) { //判断文本框不能为空 if (IsCheck()) { //判断是新增还是修改 CategoryInfo cat = new CategoryInfo(); cat.CatName = txtCName.Text; cat.CatNum = txtCNum.Text; cat.Remark = txtCRemark.Text; if (this.Tp == 1)//新增 { cat.DelFlag = 0; cat.SubBy = 1; cat.SubTime = DateTime.Now; } else if (this.Tp == 2)//修改 { cat.CatId = Convert.ToInt32(labId.Text); } CategoryInfoBLL bll = new CategoryInfoBLL(); string msg = bll.SaveCategory(cat, this.Tp) ? "操作成功" : "操作失败"; MessageBox.Show(msg); this.Close(); } }
//加载节点树 private void LoadProductAndCategory() { CategoryInfoBLL bll = new CategoryInfoBLL(); List <CategoryInfo> list = bll.GetAllCategoryInfoByDelFlag(0); LoadCategory(list, tvCategory.Nodes); }
private void LoadCategoryInfoByDelFlag(int p) { CategoryInfoBLL bll = new CategoryInfoBLL(); dgvCategory.AutoGenerateColumns = false;//禁止自动生成列 dgvCategory.DataSource = bll.GetAllCategoryInfoByDelFlag(p); }
private void btnOk_Click(object sender, EventArgs e) { if (Check()) { CategoryInfoBLL bll = new CategoryInfoBLL(); CategoryInfo ct = new CategoryInfo(); ct.CatName = txtCName.Text; ct.CatNum = txtCNum.Text; ct.Remark = txtCRemark.Text; //新增还是修改 if (this.TP==1) { ct.DelFlag = 0; ct.SubBy = 1; ct.SubTime = System.DateTime.Now; } else if (this.TP==2) { ct.CatId = Convert.ToInt32(labId.Text); } string msg = bll.SaveCategoryInfo(ct, this.TP) ? "操作成功" : "操作失败"; MessageBox.Show(msg); this.Close(); } }
private void btnOk_Click(object sender, EventArgs e) { var cti = new CategoryInfo { CatName = txtCName.Text, CatNum = txtCNum.Text, Remark = txtCRemark.Text }; if (CheckTextBox()) { if (this._tp == 1)//新增 { cti.DelFlag = 0; cti.Subtime = DateTime.Now; } else if (this._tp == 2)//修改 { cti.CatId = Convert.ToInt32(labId.Text); } var bll = new CategoryInfoBLL(); var msg = bll.SaveCategoryInfoBLL(cti, _tp) ? "操作成功" : "操作失败"; MessageBox.Show(msg); this.Close(); } }
//加载商品类别的方法 private void LoadCategoryInfo(int delFlag) { CategoryInfoBLL bll = new CategoryInfoBLL(); //获取所有没有被删除的商品类别 List <CategoryInfo> list = bll.GetAllCategoryInfoByDelFlag(delFlag); LoadCategoryBingTv(list, tvCategory.Nodes); }
//加载所有商品类别 private void LoadCategoryInfoByDelFlag(int delFlag) { CategoryInfoBLL bll = new CategoryInfoBLL(); dgvCategoryInfo.AutoGenerateColumns = false; //禁止自动生成列 dgvCategoryInfo.DataSource = bll.GetAllCategoryInfoByDelFlag(delFlag); dgvCategoryInfo.SelectedRows[0].Selected = false; //没有被选中的 }
private void LoadCategoryInfoToCmb() { var bll = new CategoryInfoBLL(); var list = bll.GetAllCategoryInfoByDelFlag(0); cmbCategory.DataSource = list; cmbCategory.DisplayMember = "CatName"; cmbCategory.ValueMember = "CatId"; }
private void LoadTvCategory() { List <CategoryInfo> categories = new CategoryInfoBLL().GetAllCategoryInfoByDelFlag(0); foreach (CategoryInfo cat in categories) { TreeNode cNode = tvCategory.Nodes.Add(cat.CName); LoadCnode(cNode.Nodes, (int)cat.CId); } }
/// <summary> /// 所有商品类别 /// </summary> /// <param name="v"></param> private void LoadCategoryInfoDelFlag(int v) { CategoryInfoBLL bll = new CategoryInfoBLL(); dgvCategoryInfo.AutoGenerateColumns = false; dgvCategoryInfo.DataSource = bll.GetAllCategoryInfoByDelFlag(v); if (dgvCategoryInfo.Rows.Count > 0) { dgvCategoryInfo.SelectedRows[0].Selected = false; } }
//加载节点树 private void LoadCategoryInfoByDelFlag(int p) { var bll = new CategoryInfoBLL(); var list = bll.GetAllCategoryInfoByDelFlag(p); foreach (var c in list) { var tn = tvCategory.Nodes.Add(c.CatName); LoadProductInfoByCatId(c.CatId, tn.Nodes); } }
//加载所有的类别 private void LoadAllCategoryInfoByDelFlag(int p) { CategoryInfoBLL cbll = new CategoryInfoBLL(); List <CategoryInfo> list = cbll.GetAllCategoryInfoByDelFlag(p); for (int i = 0; i < list.Count; i++) { TreeNode tn = tvCategory.Nodes.Add(list[i].CName); LoadProductInfoByCId(tn.Nodes, list[i].CId); } }
private void BingCMBLoadCategoryInfoByDelFlag(int delFlag) { CategoryInfoBLL bll = new CategoryInfoBLL(); List <CategoryInfo> list = bll.GetAllCategoryInfoByDelFlag(delFlag); list.Insert(0, new CategoryInfo { CatId = -1, CatName = "请选择" }); cmbCategory.DataSource = list;//为下拉框绑定数据 cmbCategory.DisplayMember = "CatName"; cmbCategory.ValueMember = "CatId"; }
private void LoadCategory() { CategoryInfoBLL categoryBll = new CategoryInfoBLL(); List <CategoryInfo> list = categoryBll.GetAllCategoryInfoByDelFlag(0); list.Insert(0, new CategoryInfo { CName = "请选择", CId = -1 }); cmbCategory.DataSource = list; cmbCategory.DisplayMember = "CName"; cmbCategory.ValueMember = "CId"; }
/// <summary> /// 把类别加载到下拉框中 /// </summary> /// <param name="v"></param> private void LoadCategoryInfoByDelFlagInComboBox(int v) { CategoryInfoBLL bll = new CategoryInfoBLL(); List <CategoryInfo> list = bll.GetAllCategoryInfoByDelFlag(v); list.Insert(0, new CategoryInfo() { CatName = "请选择", CatId = -1 }); cmbCategory.DataSource = list; cmbCategory.DisplayMember = "CatName"; cmbCategory.ValueMember = "CatId"; }
private void LoadCategory() { CategoryInfoBLL bll = new CategoryInfoBLL(); List <CategoryInfo> list = bll.GetAllCategoryInfoByDelFlag(0); list.Insert(0, new CategoryInfo() { Catid = -1, Catname = "请选择" }); cmbCategory.DataSource = list; cmbCategory.DisplayMember = "Catname"; cmbCategory.ValueMember = "Catid"; }
//修改商品类别 2--修改 private void btnUpdateCategory_Click(object sender, EventArgs e) { if (dgvCategoryInfo.SelectedRows.Count > 0) { //获取选中的id int id = Convert.ToInt32(dgvCategoryInfo.SelectedRows[0].Cells[0].Value); //根据id查询数据 CategoryInfoBLL bll = new CategoryInfoBLL(); CategoryInfo cat = bll.GetCategoryInfoByCaitId(id); cat.CatId = id; //传对象 fea.obj = cat; ShowFrmChangeCategory(2); } }
//删除商品 private void benDeleteCategory_Click(object sender, EventArgs e) { if (dgvCategoryInfo.SelectedRows.Count > 0) { int id = Convert.ToInt32(dgvCategoryInfo.SelectedRows[0].Cells[0].Value); //根据id删除选中的行 CategoryInfoBLL bll = new CategoryInfoBLL(); string msg = bll.DeleteCategoryById(id) ? "操作成功" : "操作失败"; MessageBox.Show(msg); LoadCategoryInfoByDelFlag(0); } else { MessageBox.Show("请选中要删除的行!"); } }
//修改商品类别----2 private void btnUpdateCategory_Click(object sender, EventArgs e) { if (dgvCategoryInfo.SelectedRows.Count > 0) { //获取选中的行的id int id = Convert.ToInt32(dgvCategoryInfo.SelectedRows[0].Cells[0].Value.ToString()); //根据id获取该商品类别的所有信息 CategoryInfoBLL bll = new CategoryInfoBLL(); //村对象 fea.obj = bll.GetCategoryInfoByCatId(id);//判断不是nul在赋值 LoadFrmChangeCategory(2); } else { MessageBox.Show("请选中要修改的行"); } }
//修改商品类别 private void btnUpdateCategory_Click(object sender, EventArgs e) { if (dgvCategoryInfo.SelectedRows.Count > 0) { //获取id string id = dgvCategoryInfo.SelectedRows[0].Cells[0].Value.ToString(); //获取对象,通过id去数据库查询该id对应的商品类别信息 CategoryInfoBLL bll = new CategoryInfoBLL(); CategoryInfo ct = bll.GetCategoryInfoByCatId(Convert.ToInt32(id)); ct.CatId = Convert.ToInt32(id); fea.Obj = ct; //传对象 ShowFrmChangeCategory(2);//添加 } else { MessageBox.Show("请选中行"); } }
//删除商品类别 private void btnDeleteCategory_Click(object sender, EventArgs e) { if (dgvCategoryInfo.SelectedRows.Count > 0) { CategoryInfoBLL bll = new CategoryInfoBLL(); int id = Convert.ToInt32(dgvCategoryInfo.SelectedRows[0].Cells[0].Value); if (bll.DeleteCategoryInfoByCatId(id)) { MessageBox.Show("删除成功"); LoadCategoryInfoByDelFlag(0); } else { MessageBox.Show("删除失败"); } } else { MessageBox.Show("请选择要处理的行"); } }
private void btnDeleteCategory_Click(object sender, EventArgs e) { string msg = null; if (dgvCategory.SelectedRows.Count <= 0) { md.MsgDivShow("请选择要注销的商品类别", 1); return; } if (MessageBox.Show("亲,真的要注销这个商品类别吗?", "注销提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { //判断该类别下是否有产品,提示删除吗? ProductInfoBLL pbll = new ProductInfoBLL(); CategoryInfoBLL cbll = new CategoryInfoBLL(); CategoryInfo c = (CategoryInfo)dgvCategory.SelectedRows[0].DataBoundItem; if (pbll.GetProductInfoCountByCid((int)c.CId) > 0) { if (MessageBox.Show("该类别下有若干产品,产品会随之一起注销,真的要注销吗?", "注销提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { msg = cbll.SoftDeleteCategoryInfoByCId((int)c.CId) > 0 ? "操作成功" : "操作失败"; md.MsgDivShow(msg, 1); //刷新 LoadCategory(); LoadProduct(); return; } md.MsgDivShow("您已经取消了注销", 1); return; } //无产品,删除 msg = cbll.SoftDeleteCategoryInfoByCId((int)c.CId) > 0 ? "操作成功" : "操作失败"; md.MsgDivShow(msg, 1); //刷新 LoadCategory(); return; } //提示取消删除 md.MsgDivShow("您已经取消了注销", 1); }
private void btnOk_Click(object sender, EventArgs e) { if (IsEmpty()) { return; } CategoryInfo newCategory = new CategoryInfo(); newCategory.CName = txtCName.Text; newCategory.CNum = txtCNum.Text; newCategory.CRemark = txtCRemark.Text; CategoryInfoBLL categorybll = new CategoryInfoBLL(); int i = 0; //插入时,给未在窗体显示的值添加默认值 if (status == HandleStatus.Insert) { newCategory.DelFlag = 0; newCategory.SubBy = 1; newCategory.SubTime = DateTime.Now; i = categorybll.add(newCategory); } //更新时,将未在窗体显示的值赋予原来的值 if (status == HandleStatus.Update) { newCategory.CId = oldCategory.CId; newCategory.DelFlag = oldCategory.DelFlag; newCategory.SubBy = oldCategory.SubBy; newCategory.SubTime = oldCategory.SubTime; i = categorybll.update(newCategory); } string msg = i > 0 ? "操作成功" : "操作失败"; md.MsgDivShow(msg, 1, Bind); }
private void btnOK_Click(object sender, EventArgs e) { CategoryInfoBLL bll = new CategoryInfoBLL(); CategoryInfo c = new CategoryInfo(); c.CName = txtName.Text; c.CNum = Convert.ToInt32(txtNum.Text); c.CRemark = txtNum.Text; if (CheckEmpty()) { if (Temp == 1)//新增 { c.DelFlag = 0; c.SubTime = DateTime.Now; c.SubBy = 1; } else if (Temp == 2)//修改 { c.CId = Convert.ToInt32(labId.Text); } string strMsg = bll.AddOrUpdateCategoryInfo(c, Temp) ? "操作成功" : "操作失败"; msg.MsgDivShow(strMsg, 1, Bind); } }
private string[] GetAllCategoryName() { var bll = new CategoryInfoBLL(); return(bll.GetAllCategoryInfoByDelFlag(0).Select(ci => ci.CatName).ToArray()); }