123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.InventoryManagement
- {
- public partial class FrmProductSearch : LYFZ.Software.UI.InventoryManagement.FrmProductSearch
- {
- public FrmProductSearch()
- {
- }
- public ArrayList ListArray = new ArrayList();
- #region 获取数据
- protected override void FrmProductSearch_Shown(object sender, EventArgs e)
- {
- try
- {
- CtvProd_Class.TreeView.Nodes.Clear();
- #region 绑定二级商品类别
- LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
- DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID='1'").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- TreeNode root = null;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- root = new TreeNode(tbl.Rows[i]["Sc_ClassName"].ToString());
- root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- this.CreateTreeViewShop(root.Nodes, tbl.Rows[i]["ID"].ToString());
- this.CtvProd_Class.TreeView.Nodes.Add(root);
- }
- }
- #endregion
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #region 绑定三级商品类别
- #region 绑定第三级商品类别
- /// <summary>
- /// 绑定第三级商品类别
- /// </summary>
- /// <param name="nodes">TreeView的节点集合</param>
- /// <param name="dataSource">数据源</param>
- /// <param name="parentid"></param>
- private void CreateTreeViewShop(TreeNodeCollection nodes, string ClassCode)
- {
- if (ClassCode != "")
- {
- LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
- DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID=" + ClassCode + "").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- TreeNode node;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- node = new TreeNode();
- node.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
- node.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- nodes.Add(node);
- }
- }
- }
- }
- #endregion
- #endregion
- #endregion
- #region 选择商品类别 获取商品
- protected override void CtvProd_Class_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
- {
- try
- {
- if (CtvProd_Class.Tag != null)
- {
- //获取商品表
- LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
- DataTable dt = Productbll.View_tb_ErpProduct("tb_ErpSystemCategory.Sc_ClassCode='" + CtvProd_Class.Tag.ToString() + "' and Prod_IsEnabled='1' and Prod_Quantity>Prod_AlarmQuantity ").Tables[0];
- this.dgv.AutoGenerateColumns = false;
- this.dgv.DataSource = dt;
- this.dgv.ClearSelection();
- }
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #endregion
- #region 查询
- protected override void btnSlect_Click(object sender, EventArgs e)
- {
- LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
- DataTable dt = new DataTable();
- if (CtvProd_Class.Tag != null)
- {
- dt = Productbll.View_tb_ErpProduct("tb_ErpSystemCategory.Sc_ClassCode='" + CtvProd_Class.Tag.ToString() + "' and tb_ErpProduct.Prod_Name like '%" + txtProd_Name.Text + "%' and Prod_IsEnabled='1' and Prod_Quantity>Prod_AlarmQuantity ").Tables[0];
- }
- this.dgv.AutoGenerateColumns = false;
- this.dgv.DataSource = dt;
- this.dgv.ClearSelection();
- }
- #endregion
- #region 双击事件增加商品
- protected override void dgv_DoubleClick(object sender, EventArgs e)
- {
- try
- {
- SelectAll(lstGoods);
- string Goods = "";
- for (int i = 0; i < lstGoods.Items.Count; i++)
- {
- Goods += lstGoods.SelectedItems[i].ToString() + ",";
- }
- string Prod_Name = dgv.CurrentRow.Cells["Prod_Name"].Value.ToString();
- string Prod_Number = dgv.CurrentRow.Cells["Prod_Number"].Value.ToString();
- string sp = "(" + Prod_Number + ")" + Prod_Name;
- // string jq = sp.Substring(sp.LastIndexOf(")") + 1);
- if (Goods.Contains(sp))
- {
- MessageBoxCustom.Show("此商品已在列表中!不能添加!");
- SelectAll(lstGoods);
- return;
- }
- this.lstGoods.Items.Add(sp);
- SelectAll(lstGoods);
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #endregion
- #region <<按钮增加商品
- protected override void btnRight_Click(object sender, EventArgs e)
- {
- try
- {
- SelectAll(lstGoods);
- string Goods = "";
- for (int i = 0; i < lstGoods.Items.Count; i++)
- {
- Goods += lstGoods.SelectedItems[i].ToString() + ",";
- }
- string Prod_Name = dgv.CurrentRow.Cells["Prod_Name"].Value.ToString();
- string Prod_Number = dgv.CurrentRow.Cells["Prod_Number"].Value.ToString();
- string sp = "(" + Prod_Number + ")" + Prod_Name;
- // string jq = sp.Substring(sp.LastIndexOf(")") + 1);
- if (Goods.Contains(sp))
- {
- MessageBoxCustom.Show("此商品已在列表中!不能添加!");
- SelectAll(lstGoods);
- return;
- }
- this.lstGoods.Items.Add(sp);
- SelectAll(lstGoods);
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #endregion
- #region 移除商品
- protected override void btnLeft_Click(object sender, EventArgs e)
- {
- try
- {
- if (lstGoods.Items.Count > 0)
- {
- lstGoods.Items.Remove(lstGoods.SelectedItem);
- }
- //Item obj = this.lstGoods.SelectedItem as Item;
- //MessageBox.Show("Text:" + obj.strText + " 值:" + obj.strValue);
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #endregion
- #region 确定
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- FrmPurchaseOrder set = new FrmPurchaseOrder();
- if (lstGoods.Items.Count > 0)
- {
- for (int i = 0; i < lstGoods.Items.Count; i++)
- {
- string start = lstGoods.Items[i].ToString();
- string end = start.Substring(1, start.LastIndexOf(")") - 1);
- ListArray.Add(end.ToString());
- }
- }
- this.Close();
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- #endregion
- #region 全选
- private void SelectAll(ListBox ListBox)
- {
- for (int i = 0; i < ListBox.Items.Count; i++)
- {
- ListBox.SelectedIndex = i;
- }
- }
- #endregion
- }
- }
|