/// <summary> /// 入库单列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void left_btn_put_1_Click(object sender, EventArgs e) { body.Controls.Clear(); //清除body中所有控件 PutInventory pi = new PutInventory(); pi.MdiParent = this; pi.Dock = DockStyle.Fill; pi.Parent = body; //设置入库单列表窗体的父容器为body(panel) pi.Show(); }
/// <summary> /// 入库按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_storage_Click_1(object sender, EventArgs e) { Boolean isnull = true; //标识textbox是否有空 foreach (Control c in this.Controls) //循环判断textbox是否为空 { if (c is TextBox) { if (c.Text == "") { isnull = false; } } } try { DateTime dt = DateTime.Parse(text_expiration_date.Text); //判断用户输入的日期格式是否正确 dt = DateTime.Parse(text_manufacture_date.Text); } catch (Exception) { isnull = false; } if (comb_goods_name.Text != "" && tree_label.Text != "" && com_warehouse_id.Text != "" && com_type_id.Text != "" && isnull && com_client_id.Text != "") //判断下拉列表是否为空 { gm.Goods_name = comb_goods_name.Text; //物品名 gm.Goods_type_id = goods_type_id; //物品类型ID gm.Goods_code = text_goods_code.Text; //物品代码 gm.Specifications = text_specifications.Text; //物品规格 gm.Goods_volume = text_goods_volume.Text; //物品体积 gm.Goods_wight = text_goods_wight.Text; //物品重量 gm.Goods_note = text_goods_note.Text; //物品备注 listgm.Clear(); listgm = gb.FindAllCondition(gm); //把物品所有信息当做条件进行查询 if (listgm.Count == 0) //如果插入的物品和数据库不一致 { bm.Goods_id = gb.Insert(gm); //物品ID } else { bm.Goods_id = listgm[0].Id; } bm.Goods_price = Double.Parse(text_goods_price.Text); //物品价格 bm.Lot_number = text_lot_number.Text; //入库批号 bm.Client_id = (int)com_client_id.SelectedValue; //客户ID bm.Goods_amount = Int32.Parse(text_goods_amount.Text); //物品数量 bm.Manager_id = LoginInfo.manager_info.Id; //管理员ID bm.Manufacture_date = text_manufacture_date.Text; //生产日期 bm.Expiration_date = text_expiration_date.Text; //到期日期 bm.Operation_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //操作日期 bm.Warehouse_id = (int)com_warehouse_id.SelectedValue; //仓库号 bm.Operation_type_id = (int)com_type_id.SelectedValue; //操作方式 bm.Bill_note = text_bill_note.Text; //清单备注 bb.Insert(bm); //插入到清单表 im.Goods_id = bm.Goods_id; //物品ID im.Warehouse_id = bm.Warehouse_id; //仓库ID im.Client_id = bm.Client_id; //客户ID im.Goods_amount = bm.Goods_amount; //物品总数 im.Goods_total = bm.Goods_amount * bm.Goods_price; //物品总价 listi = ib.FindId(im.Goods_id, im.Warehouse_id, im.Client_id); if (listi.Count > 0) { ib.Update(listi[0], im.Goods_amount, im.Goods_total); } else { ib.Insert(im); } PutInventory pi = new PutInventory(); pi.TopLevel = false; pi.MdiParent = this.MdiParent; pi.Parent = this.Parent; pi.Dock = DockStyle.Fill; pi.Show(); this.Close(); } else { MessageBox.Show("请确保填入内容的完整性!", "警告!"); } }