123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- using LYFZ.ComponentLibrary;
- using System;
- 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 FrmReceipt : LYFZ.Software.UI.InventoryManagement.FrmReceipt
- {
- private delegate void UpdateControl();
- public FrmReceipt()
- {
- this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
- this.dgv2.CellMouseDown += dgv2_CellMouseDown;
- this.dgv2.DataGridViewConMenu_ItemClicked += dgv2_DataGridViewConMenu_ItemClicked;
- }
- protected override void FrmReceipt_Shown(object sender, EventArgs e)
- {
- SelectGoods();
- //绑定数据表
- GetProductIntStorage();
- btnWarehousing.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ReceiptCompetence, CustomAttributes.OperatingAuthority.Receipt);
- btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ReceiptCompetence, CustomAttributes.OperatingAuthority.Delete);
- }
- /// <summary>
- /// 获取入库记录表
- /// </summary>
- public void GetProductIntStorage()
- {
- this.ucPagerEx1.PageCurrent = 1;
- this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
- this.ucPagerEx1.Bind();
- }
- /// <summary>
- /// 新增入库
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnWarehousing_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InventoryManagement.Receipt.FrmWarehousing set = new Receipt.FrmWarehousing();
- if (set.ShowDialog() == DialogResult.OK)
- { GetProductIntStorage(); }
- }
- /// <summary>
- /// 绑定查询商品类别
- /// </summary>
- public void SelectGoods()
- {
- CtvSelect.TreeView.Nodes.Clear();
- 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++)
- {
- if (i == 0)
- {
- root = new TreeNode("全部");
- this.CtvSelect.TreeView.Nodes.Add(root);
- }
- root = new TreeNode();
- root.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
- root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- this.CreateTreeViewShop(root.Nodes, tbl.Rows[i]["ID"].ToString());
- this.CtvSelect.TreeView.Nodes.Add(root);
- }
- }
- }
- /// <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);
- }
- }
- }
- }
- /// <summary>
- /// 商品查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void CtvSelect_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
- {
- GetProductIntStorage();
- }
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
- {
- dgv2.Rows.Clear();
- DataTable dt = new DataTable();
- StringBuilder str = new StringBuilder();
- if (CtvSelect.Text == "" || CtvSelect.Tag == null || CtvSelect.Text == "全部")
- { str.Append(" 1=1 and Pis_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "'"); }
- else if (CtvSelect.Tag != null)
- { str.Append(" 1=1 and Pis_ProductCategory='" + CtvSelect.Tag.ToString() + "' and Pis_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "'"); }
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- pageData.TableName = "View_ErpProductIntStorage";
- pageData.PageIndex = this.ucPagerEx1.PageCurrent;
- pageData.PageSize = this.ucPagerEx1.PageSize;
- pageData.QueryCondition = str.ToString();
- pageData.QueryFieldName = "ID,Pis_DividedShop,Pis_ProductCategory,Pis_ProductNumber,Pis_PurchaseQuantity,Pis_PurchaseVendor,Pis_PurchasePrice,Pis_Remark,Pis_CreateDatetime,Pis_CreateNameId,Pis_CreateName,Pis_ProductCategoryName ,Pis_ProductNumberName";
- pageData.OrderStr = " ID desc ";
- DataSet da = pageData.QueryDataTable();
- dt = da.Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new UpdateControl(delegate()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_ProductCategory"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_ProductNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_ProductCategoryName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_ProductNumberName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_PurchaseQuantity"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_PurchaseVendor"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_PurchasePrice"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_Remark"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pis_CreateName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDateTime(dt.Rows[t]["Pis_CreateDatetime"]).ToString("yyyy-MM-dd").Trim();
- dgvr.Cells.Add(cell);
- this.dgv2.Rows.Add(dgvr);
- dgv2.ClearSelection();
- }
- }));
- }
- });
- try
- {
- this.ucPagerEx1.TbDataSource = dt;
- }
- catch { }
- return pageData.TotalCount;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnDelete_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgv2.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("请选中你要删除的数据!");
- return;
- }
- LYFZ.BLL.BLL_ErpProductIntStorage ProductIntStoragebll = new BLL.BLL_ErpProductIntStorage();
- LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
- DataTable dt = new DataTable();
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- int id = Convert.ToInt32(this.dgv2.CurrentRow.Cells["ID"].Value);
- string Pro_number = dgv2.CurrentRow.Cells["Pro_number"].Value.ToString();
- int Quantity = Convert.ToInt32(this.dgv2.CurrentRow.Cells["Quantity"].Value);
- //删除入库记录
- if (ProductIntStoragebll.Delete(id))
- {
- #region 更新商品库存数量
- //获取商品数量
- dt = Productbll.GetList("Prod_Number='" + Pro_number + "'").Tables[0];
- if (dt.Rows.Count > 0)
- {
- int Count = Convert.ToInt32(Convert.ToInt32(dt.Rows[0]["Prod_Quantity"]) - Quantity);
- Productbll.UpdateProduct("Prod_Quantity=" + Count + "", Pro_number);
- }
- #endregion
- }
- MessageBoxCustom.Show("删除成功!");
- GetProductIntStorage();
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- /// <summary>
- /// 右键菜单选择事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgv2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- ToolStripMenuItem item = null;
- item = new ToolStripMenuItem();
- item.Text = "查看商品图片";
- item.Tag = "View";
- this.dgv2.conMenu.Items.Add(item);
- }
- }
- void dgv2_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- ToolStripItem item = e.ClickedItem;
- if (item.Tag.ToString().Trim() == "View")
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ProductViewPhoto(this.dgv2.CurrentRow.Cells["Pro_number"].Value.ToString().Trim());
- }
- }
- }
- }
|