FrmReceipt.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.InventoryManagement
  11. {
  12. public partial class FrmReceipt : LYFZ.Software.UI.InventoryManagement.FrmReceipt
  13. {
  14. private delegate void UpdateControl();
  15. public FrmReceipt()
  16. {
  17. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  18. this.dgv2.CellMouseDown += dgv2_CellMouseDown;
  19. this.dgv2.DataGridViewConMenu_ItemClicked += dgv2_DataGridViewConMenu_ItemClicked;
  20. }
  21. protected override void FrmReceipt_Shown(object sender, EventArgs e)
  22. {
  23. SelectGoods();
  24. //绑定数据表
  25. GetProductIntStorage();
  26. btnWarehousing.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ReceiptCompetence, CustomAttributes.OperatingAuthority.Receipt);
  27. btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ReceiptCompetence, CustomAttributes.OperatingAuthority.Delete);
  28. }
  29. /// <summary>
  30. /// 获取入库记录表
  31. /// </summary>
  32. public void GetProductIntStorage()
  33. {
  34. this.ucPagerEx1.PageCurrent = 1;
  35. this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  36. this.ucPagerEx1.Bind();
  37. }
  38. /// <summary>
  39. /// 新增入库
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="e"></param>
  43. protected override void btnWarehousing_Click(object sender, EventArgs e)
  44. {
  45. LYFZ.Software.MainBusiness.InventoryManagement.Receipt.FrmWarehousing set = new Receipt.FrmWarehousing();
  46. if (set.ShowDialog() == DialogResult.OK)
  47. { GetProductIntStorage(); }
  48. }
  49. /// <summary>
  50. /// 绑定查询商品类别
  51. /// </summary>
  52. public void SelectGoods()
  53. {
  54. CtvSelect.TreeView.Nodes.Clear();
  55. LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
  56. DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID='1'").Tables[0];
  57. if (tbl.Rows.Count > 0)
  58. {
  59. TreeNode root = null;
  60. for (int i = 0; i < tbl.Rows.Count; i++)
  61. {
  62. if (i == 0)
  63. {
  64. root = new TreeNode("全部");
  65. this.CtvSelect.TreeView.Nodes.Add(root);
  66. }
  67. root = new TreeNode();
  68. root.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
  69. root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
  70. this.CreateTreeViewShop(root.Nodes, tbl.Rows[i]["ID"].ToString());
  71. this.CtvSelect.TreeView.Nodes.Add(root);
  72. }
  73. }
  74. }
  75. /// <summary>
  76. /// 绑定第三级商品类别
  77. /// </summary>
  78. /// <param name="nodes">TreeView的节点集合</param>
  79. /// <param name="dataSource">数据源</param>
  80. /// <param name="parentid"></param>
  81. private void CreateTreeViewShop(TreeNodeCollection nodes, string ClassCode)
  82. {
  83. if (ClassCode != "")
  84. {
  85. LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
  86. DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID=" + ClassCode + "").Tables[0];
  87. if (tbl.Rows.Count > 0)
  88. {
  89. TreeNode node;
  90. for (int i = 0; i < tbl.Rows.Count; i++)
  91. {
  92. node = new TreeNode();
  93. node.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
  94. node.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
  95. nodes.Add(node);
  96. }
  97. }
  98. }
  99. }
  100. /// <summary>
  101. /// 商品查询
  102. /// </summary>
  103. /// <param name="sender"></param>
  104. /// <param name="e"></param>
  105. protected override void CtvSelect_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
  106. {
  107. GetProductIntStorage();
  108. }
  109. /// <summary>
  110. /// 画分页
  111. /// </summary>
  112. /// <param name="e"></param>
  113. /// <returns></returns>
  114. private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  115. {
  116. dgv2.Rows.Clear();
  117. DataTable dt = new DataTable();
  118. StringBuilder str = new StringBuilder();
  119. if (CtvSelect.Text == "" || CtvSelect.Tag == null || CtvSelect.Text == "全部")
  120. { str.Append(" 1=1 and Pis_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "'"); }
  121. else if (CtvSelect.Tag != null)
  122. { str.Append(" 1=1 and Pis_ProductCategory='" + CtvSelect.Tag.ToString() + "' and Pis_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "'"); }
  123. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  124. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  125. {
  126. pageData.TableName = "View_ErpProductIntStorage";
  127. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  128. pageData.PageSize = this.ucPagerEx1.PageSize;
  129. pageData.QueryCondition = str.ToString();
  130. 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";
  131. pageData.OrderStr = " ID desc ";
  132. DataSet da = pageData.QueryDataTable();
  133. dt = da.Tables[0];
  134. if (dt.Rows.Count > 0)
  135. {
  136. this.Invoke(new UpdateControl(delegate()
  137. {
  138. for (int t = 0; t < dt.Rows.Count; t++)
  139. {
  140. DataGridViewRow dgvr = new DataGridViewRow();
  141. DataGridViewCell cell = null;
  142. cell = new DataGridViewTextBoxCell();
  143. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  144. dgvr.Cells.Add(cell);
  145. cell = new DataGridViewTextBoxCell();
  146. cell.Value = dt.Rows[t]["Pis_ProductCategory"].ToString().Trim();
  147. dgvr.Cells.Add(cell);
  148. cell = new DataGridViewTextBoxCell();
  149. cell.Value = dt.Rows[t]["Pis_ProductNumber"].ToString().Trim();
  150. dgvr.Cells.Add(cell);
  151. cell = new DataGridViewTextBoxCell();
  152. cell.Value = dt.Rows[t]["Pis_ProductCategoryName"].ToString().Trim();
  153. dgvr.Cells.Add(cell);
  154. cell = new DataGridViewTextBoxCell();
  155. cell.Value = dt.Rows[t]["Pis_ProductNumberName"].ToString().Trim();
  156. dgvr.Cells.Add(cell);
  157. cell = new DataGridViewTextBoxCell();
  158. cell.Value = dt.Rows[t]["Pis_PurchaseQuantity"].ToString().Trim();
  159. dgvr.Cells.Add(cell);
  160. cell = new DataGridViewTextBoxCell();
  161. cell.Value = dt.Rows[t]["Pis_PurchaseVendor"].ToString().Trim();
  162. dgvr.Cells.Add(cell);
  163. cell = new DataGridViewTextBoxCell();
  164. cell.Value = dt.Rows[t]["Pis_PurchasePrice"].ToString().Trim();
  165. dgvr.Cells.Add(cell);
  166. cell = new DataGridViewTextBoxCell();
  167. cell.Value = dt.Rows[t]["Pis_Remark"].ToString().Trim();
  168. dgvr.Cells.Add(cell);
  169. cell = new DataGridViewTextBoxCell();
  170. cell.Value = dt.Rows[t]["Pis_CreateName"].ToString().Trim();
  171. dgvr.Cells.Add(cell);
  172. cell = new DataGridViewTextBoxCell();
  173. cell.Value = Convert.ToDateTime(dt.Rows[t]["Pis_CreateDatetime"]).ToString("yyyy-MM-dd").Trim();
  174. dgvr.Cells.Add(cell);
  175. this.dgv2.Rows.Add(dgvr);
  176. dgv2.ClearSelection();
  177. }
  178. }));
  179. }
  180. });
  181. try
  182. {
  183. this.ucPagerEx1.TbDataSource = dt;
  184. }
  185. catch { }
  186. return pageData.TotalCount;
  187. }
  188. /// <summary>
  189. /// 删除
  190. /// </summary>
  191. /// <param name="sender"></param>
  192. /// <param name="e"></param>
  193. protected override void btnDelete_Click(object sender, EventArgs e)
  194. {
  195. try
  196. {
  197. if (this.dgv2.SelectedRows.Count == 0)
  198. {
  199. MessageBoxCustom.Show("请选中你要删除的数据!");
  200. return;
  201. }
  202. LYFZ.BLL.BLL_ErpProductIntStorage ProductIntStoragebll = new BLL.BLL_ErpProductIntStorage();
  203. LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
  204. DataTable dt = new DataTable();
  205. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  206. {
  207. int id = Convert.ToInt32(this.dgv2.CurrentRow.Cells["ID"].Value);
  208. string Pro_number = dgv2.CurrentRow.Cells["Pro_number"].Value.ToString();
  209. int Quantity = Convert.ToInt32(this.dgv2.CurrentRow.Cells["Quantity"].Value);
  210. //删除入库记录
  211. if (ProductIntStoragebll.Delete(id))
  212. {
  213. #region 更新商品库存数量
  214. //获取商品数量
  215. dt = Productbll.GetList("Prod_Number='" + Pro_number + "'").Tables[0];
  216. if (dt.Rows.Count > 0)
  217. {
  218. int Count = Convert.ToInt32(Convert.ToInt32(dt.Rows[0]["Prod_Quantity"]) - Quantity);
  219. Productbll.UpdateProduct("Prod_Quantity=" + Count + "", Pro_number);
  220. }
  221. #endregion
  222. }
  223. MessageBoxCustom.Show("删除成功!");
  224. GetProductIntStorage();
  225. }
  226. }
  227. catch (Exception ex)
  228. {
  229. MessageBoxCustom.Show(ex.Message);
  230. }
  231. }
  232. /// <summary>
  233. /// 右键菜单选择事件
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. void dgv2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
  238. {
  239. if (e.Button == MouseButtons.Right)
  240. {
  241. ToolStripMenuItem item = null;
  242. item = new ToolStripMenuItem();
  243. item.Text = "查看商品图片";
  244. item.Tag = "View";
  245. this.dgv2.conMenu.Items.Add(item);
  246. }
  247. }
  248. void dgv2_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  249. {
  250. ToolStripItem item = e.ClickedItem;
  251. if (item.Tag.ToString().Trim() == "View")
  252. {
  253. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ProductViewPhoto(this.dgv2.CurrentRow.Cells["Pro_number"].Value.ToString().Trim());
  254. }
  255. }
  256. }
  257. }