private void BindType() { TypeBLL objTypeBLL = new TypeBLL(); DrpType.DataSource = objTypeBLL.GetLandType(); DrpType.DataTextField = "LANDTYPE"; DrpType.DataValueField = "LND_TYPEID"; DrpType.DataBind(); //DrpType.Items.Insert(0, "--Select--"); }
private void btn_chaxun_Click(object sender, EventArgs e) { try { this.dgv_xiangqing.DataSource = TypeBLL.GetDataTableLikeTypeName(this.txt_chaxun.Text); } finally { //初始化 id = 0; this.txt_typename.Text = ""; } }
private void Goodsadd_Load(object sender, EventArgs e) { DataTable type = TypeBLL.selecttype(); if (type.Rows.Count != 0) { foreach (DataRow row in type.Rows) { this.cbo_type.Items.Add(row[1].ToString()); } this.cbo_type.SelectedIndex = 0; } }
//在操作区域内部添加选项卡页,显示WarehouseForm窗体 private void btn_cangku_Click(object sender, EventArgs e) { DataTable type = TypeBLL.selecttype(); if (type.Rows.Count != 0) { //在操作区域内部添加选项卡页,显示WarehouseForm窗体 WarehouseForm warehouseForm = new WarehouseForm(); AddTabPage("仓库管理", warehouseForm); } else { MessageBox.Show("请先去添加书本类型", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void btn_jinhuo_Click(object sender, EventArgs e) { DataTable type = TypeBLL.selecttype(); if (type.Rows.Count != 0) { //new一个添加书本对象 Booksadd Add = new Booksadd(); //显示窗体 Add.Show(); } else { MessageBox.Show("请先去添加书本类型", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void btn_delete_Click(object sender, EventArgs e) { try { TypeBLL.InsertType(this.txt_typename.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.dgv_xiangqing.AutoGenerateColumns = false; this.dgv_xiangqing.DataSource = TypeBLL.selecttype(); this.txt_typename.Text = ""; } }
int booktype; //保存当前书本类型 private void WarehouseForm_Load(object sender, EventArgs e) { //显示所有书本 //不允许自动创建列 this.dgv_goods.AutoGenerateColumns = false; //绑定数据源 this.dgv_goods.DataSource = BooksBLL.GetBooksandType(); //初始最大化 this.WindowState = System.Windows.Forms.FormWindowState.Maximized; //设置为可编辑状态 // dgv_goods.BeginEdit(false); //查询类型 DataTable dt = TypeBLL.selecttype(); //遍历出所有类型 for (int i = 0; i < dt.Rows.Count; i++) { this.cbo_type.Items.Add(dt.Rows[i][1]); } }
//删除 private void btn_delete_Click_1(object sender, EventArgs e) { try { if (TypeBLL.DeleteType(id)) { MessageBox.Show("删除成功", "温馨提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //初始化 id = 0; this.txt_typename.Text = ""; this.dgv_xiangqing.DataSource = TypeBLL.selecttype(); } }
public void Put(int id, [FromBody] TypeBLL value) { value.Id = id; TA.ChangeType(value); }
public void Post([FromBody] TypeBLL value, string NameType) { value.NameType = NameType; TA.AddType(value); }
/// <summary> /// 添加书本 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinButton2_Click(object sender, EventArgs e) { //获取类型ID try { booktype = TypeBLL.GetTypeIDByTypeName(this.cbo_type.Text); } catch (Exception) { MessageBox.Show("请先去添加书本类型", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } try { //添加书本 if (this.txt_goodname.Text == "" || this.txt_jinjia.Text == "" || this.txt_kucun.Text == "" || this.txt_shoujia.Text == "" || this.txt_tiaoxingma.Text == "" || this.txt_zhekou.Text == "") { MessageBox.Show("带*号不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (TextBoxBll.Intextnull(this.txt_kucun.Text, 2)) { MessageBox.Show("库存必须为正整数", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (TextBoxBll.Intextnull(this.txt_zhekou.Text, 4)) { MessageBox.Show("折扣请输入0~1的数字", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (BooksBLL.SelectBooksTypeByBarCode(this.txt_tiaoxingma.Text).Rows.Count > 0) { MessageBox.Show("该条形码已存在", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (TextBoxBll.Intextnull(this.txt_tiaoxingma.Text, 1)) { MessageBox.Show("条形码长度过长", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { Books gs = new Books(); gs.BooksName = this.txt_goodname.Text; gs.TypeID = booktype; gs.BarCode = this.txt_tiaoxingma.Text; gs.StorePrice = decimal.Parse(this.txt_jinjia.Text.ToString()); gs.SalePrice = decimal.Parse(this.txt_shoujia.Text.ToString()); gs.Discount = decimal.Parse(this.txt_zhekou.Text.ToString()); gs.StockNum = int.Parse(this.txt_kucun.Text); gs.StockDate = DateTime.Parse(this.dtp_riqi.Text.ToString()); if (BooksBLL.InsertBooks(gs)) { MessageBox.Show("添加成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //绑定数据源 this.dgv_goods.DataSource = BooksBLL.GetBooksandType(); //初始化文本框数据 this.txt_goodsname.Text = null; this.txt_jinjia.Text = null; this.txt_kucun.Text = null; this.txt_shoujia.Text = null; this.txt_tiaoxingma.Text = null; this.txt_zhekou.Text = null; } } } catch (Exception) { MessageBox.Show("请正确填写信息", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
/// <summary> /// 修改书本 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinButton3_Click(object sender, EventArgs e) { if (id == 0) { return; } //获取类型ID booktype = TypeBLL.GetTypeIDByTypeName(this.cbo_type.Text); if (booktype == 0) { MessageBox.Show("请选择书本类型", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } try { if (error) { //修改书本 string pattern = @"^[0]+(\.[0-9]{1,3})?$"; Match m = Regex.Match(this.txt_zhekou.Text, pattern); // 匹配正则表达式 if (this.txt_goodname.Text == "" || this.txt_jinjia.Text == "" || this.txt_kucun.Text == "" || this.txt_shoujia.Text == "" || this.txt_tiaoxingma.Text == "" || this.txt_zhekou.Text == "") { MessageBox.Show("带*号不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (float.Parse(txt_zhekou.Text) > 1 || float.Parse(txt_zhekou.Text) < 0) { MessageBox.Show("折扣必须输入0~1的数", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (this.txt_tiaoxingma.Text.Length >= 50) { MessageBox.Show("条形码长度过长", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (!m.Success && this.txt_zhekou.Text != "1" && this.txt_zhekou.Text != "1.0") { MessageBox.Show("折扣请输入0~1的数字", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else { if (int.Parse(this.txt_kucun.Text) >= 0) { Books gs = new Books(); gs.BooksName = this.txt_goodname.Text; gs.TypeID = booktype; gs.BarCode = this.txt_tiaoxingma.Text; gs.StorePrice = decimal.Parse(this.txt_jinjia.Text.ToString()); gs.SalePrice = decimal.Parse(this.txt_shoujia.Text.ToString()); gs.Discount = decimal.Parse(this.txt_zhekou.Text.ToString()); gs.StockNum = int.Parse(this.txt_kucun.Text); gs.StockDate = DateTime.Parse(this.dtp_riqi.Text.ToString()); gs.BooksID = id; if (BooksBLL.UpdateBooks(gs)) { MessageBox.Show("修改成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); flag = true; } } else { MessageBox.Show("库存必须为正整数,请重新操作", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } else { MessageBox.Show("书本信息填写失误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception ex) { MessageBox.Show("请联系管理员:" + ex.Message, "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } finally { if (flag) { //绑定数据源 this.dgv_goods.DataSource = BooksBLL.GetBooksandType(); } } }
private void TypeForm_Load(object sender, EventArgs e) { //绑定数据 this.dgv_xiangqing.AutoGenerateColumns = false; this.dgv_xiangqing.DataSource = TypeBLL.selecttype(); }
/// <summary> /// 添加书本 /// </summary> public void 添加书本() { //执行命令 if (this.txt_goodsname.Text == "") { MessageBox.Show("书名不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (this.txt_tiaoxingma.Text == "") { MessageBox.Show("书的条形码不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (this.txt_tiaoxingma.Text == "") { MessageBox.Show("书的条形码不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (TextBoxBll.Intextnull(this.txt_zhekou.Text, 4)) { MessageBox.Show("折扣必须为0~1的小数", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (TextBoxBll.Intextnull(this.txt_goodsnum.Text, 2)) { MessageBox.Show("书的数量错误", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (decimal.Parse(this.txt_jinjia.Text.ToString()) < 0 || this.txt_jinjia.Text == "") { MessageBox.Show("请正确填写书的进价", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (decimal.Parse(this.txt_maijia.Text.ToString()) < 0 || this.txt_maijia.Text == "") { MessageBox.Show("请正确填写书的售价", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (decimal.Parse(this.txt_zhekou.Text.ToString()) > 0 && decimal.Parse(this.txt_zhekou.Text.ToString()) < 1 || this.txt_zhekou.Text == "") { MessageBox.Show("请正确填写书的折扣", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else if (int.Parse(this.txt_goodsnum.Text.ToString()) < 0) { MessageBox.Show("进货数量不正确", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } Books gs = new Books(); gs.BooksName = this.txt_goodsname.Text; gs.TypeID = TypeBLL.GetTypeIDByTypeName(this.cbo_type.Text); gs.BarCode = this.txt_tiaoxingma.Text; gs.StorePrice = decimal.Parse(this.txt_jinjia.Text.ToString()); gs.SalePrice = decimal.Parse(this.txt_maijia.Text.ToString()); gs.Discount = decimal.Parse(this.txt_zhekou.Text.ToString()); gs.StockNum = int.Parse(this.txt_goodsnum.Text); gs.StockDate = DateTime.Parse(DateTime.Now.ToString("yyyy年MM月dd日HH:mm:ss")); DataTable dt = BooksBLL.SelectBooksTypeByBarCode(this.txt_tiaoxingma.Text); //进货 if (dt.Rows.Count == 1) { try { //进货 int newGoods = int.Parse(this.txt_goodsnum.Text); int oldGoods = int.Parse(dt.Rows[0]["StockNum"].ToString()); BooksBLL.InsertbooksByBarCod(newGoods, oldGoods, this.txt_tiaoxingma.Text); MessageBox.Show("进货成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.txt_goodsname.ReadOnly = false; this.txt_jinjia.ReadOnly = false; this.txt_maijia.ReadOnly = false; this.txt_tiaoxingma.ReadOnly = false; this.txt_zhekou.ReadOnly = false; this.cbo_type.Enabled = true; //初始化数据 this.cbo_type.Text = ""; this.txt_goodsname.Text = ""; this.txt_goodsnum.Text = ""; this.txt_jinjia.Text = ""; this.txt_maijia.Text = ""; this.txt_tiaoxingma.Text = ""; this.txt_zhekou.Text = ""; } } else { try { //执行添加操作 if (BooksBLL.InsertBooks(gs)) { MessageBox.Show("添加成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //初始化数据 this.cbo_type.SelectedIndex = 0; this.txt_goodsname.Text = ""; this.txt_goodsnum.Text = ""; this.txt_jinjia.Text = ""; this.txt_maijia.Text = ""; this.txt_tiaoxingma.Text = ""; this.txt_zhekou.Text = ""; } } }