InventoryPurchaseOrderManagementFrmMain.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. using System;
  2. using System.Collections;
  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 InventoryPurchaseOrderManagementFrmMain : LYFZ.Software.UI.InventoryManagement.InventoryPurchaseOrderManagementFrmMain
  13. {
  14. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  15. LYFZ.BLL.BLL_ErpPurchaseOrder porbll = new BLL.BLL_ErpPurchaseOrder();
  16. LYFZ.BLL.BLL_ErpPurchaseProduct pptbll = new BLL.BLL_ErpPurchaseProduct();
  17. public InventoryPurchaseOrderManagementFrmMain()
  18. {
  19. this.Load += InventoryPurchaseOrderManagementFrmMain_Load;
  20. this.Shown += InventoryPurchaseOrderManagementFrmMain_Shown;
  21. this.cmbtrrevOrderStatus.ComboBoxTree_NodeMouseClick += cmbtrrevOrderStatus_ComboBoxTree_NodeMouseClick;
  22. this.btnPurchaseRequest.Click += btnPurchaseRequest_Click;
  23. this.btnProcurementOrderUpdate.Click += btnProcurementOrderUpdate_Click;
  24. this.btnPurchaseProduct.Click += btnPurchaseProduct_Click;
  25. this.btnPurchaseCheckAccept.Click += btnPurchaseCheckAccept_Click;
  26. this.btnByVendorPurchase.Click += btnByVendorPurchase_Click;
  27. this.btnByVendorCheckAccept.Click += btnByVendorCheckAccept_Click;
  28. this.btnPrint.Click += btnPrint_Click;
  29. this.btnDelete.Click += btnDelete_Click;
  30. this.btnClose.Click += btnClose_Click;
  31. this.Resize += InventoryPurchaseOrderManagementFrmMain_Resize;
  32. }
  33. /// <summary>
  34. /// 相片集合
  35. /// </summary>
  36. ImageList mlistImage = new ImageList();
  37. /// <summary>
  38. /// 窗体加载事件
  39. /// </summary>
  40. /// <param name="sender"></param>
  41. /// <param name="e"></param>
  42. void InventoryPurchaseOrderManagementFrmMain_Load(object sender, EventArgs e)
  43. {
  44. this.btnPurchaseRequest.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StockCompetence, CustomAttributes.OperatingAuthority.Add);
  45. this.btnProcurementOrderUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StockCompetence, CustomAttributes.OperatingAuthority.Add);
  46. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.Delete);
  47. this.btnPurchaseProduct.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.PurchasingManagement);
  48. this.btnByVendorPurchase.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.PurchasingManagement);
  49. this.btnPurchaseCheckAccept.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.AcceptanceManagement);
  50. this.btnByVendorCheckAccept.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.AcceptanceManagement);
  51. this.listViewData.View = View.Details;
  52. this.listViewData.GridLines = true;
  53. string[] StrColumns = "采购单号,采购申请人,采购申请时间,采购状态,".Split(',');
  54. for (int i = 0; i < StrColumns.Length; i++)
  55. {
  56. ColumnHeader ch = new ColumnHeader();
  57. ch.Text = StrColumns[i].Trim();
  58. switch (StrColumns[i].Trim())
  59. {
  60. case "采购单号":
  61. case "采购申请人":
  62. case "采购申请时间":
  63. case "采购状态":
  64. ch.Width = 150;
  65. break;
  66. default:
  67. ch.Width = this.listViewData.Width - (150 * 4) - 23;
  68. break;
  69. }
  70. ch.TextAlign = HorizontalAlignment.Center;
  71. this.listViewData.Columns.Add(ch);
  72. }
  73. this.mlistImage.ImageSize = new Size(1, 25);
  74. this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
  75. this.listViewData.SmallImageList = mlistImage;
  76. }
  77. /// <summary>
  78. /// 窗体加载事件
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. void InventoryPurchaseOrderManagementFrmMain_Shown(object sender, EventArgs e)
  83. {
  84. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
  85. VersionControl.VersionFunctionEnum.库存管理库存采购流程
  86. );
  87. if (!b)
  88. {
  89. this.Close();
  90. return;
  91. }
  92. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtrrevOrderStatus, "3:申请中,0:采购中,1:采购OK", IsFirstNodeNull: true, IsFirstNodeName: "全部", IsSplit: true, StrSplitSymbol: ':');
  93. this.cmbtrrevOrderStatus.TextFindTag("全部");
  94. this.PublicFunctionRows();
  95. }
  96. /// <summary>
  97. /// 采购单状态
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. void cmbtrrevOrderStatus_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  102. {
  103. this.PublicFunctionRows();
  104. }
  105. /// <summary>
  106. /// 申请采购
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. void btnPurchaseRequest_Click(object sender, EventArgs e)
  111. {
  112. LYFZ.Software.MainBusiness.InventoryManagement.InventoryDetailFrmMain frm = new InventoryDetailFrmMain();
  113. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  114. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  115. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  116. frm.IsShowUcNavigationTool = false;
  117. frm.ShowDialog();
  118. if (frm.IsSaveed)
  119. { this.PublicFunctionRows(); }
  120. else
  121. { this.listViewData.Select(); }
  122. }
  123. /// <summary>
  124. /// 采购申请单修改
  125. /// </summary>
  126. /// <param name="sender"></param>
  127. /// <param name="e"></param>
  128. void btnProcurementOrderUpdate_Click(object sender, EventArgs e)
  129. {
  130. if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
  131. {
  132. LYFZ.Software.MainBusiness.InventoryManagement.SetSmallForm.InventoryRequisitionUpdateSmallForm frm = new SetSmallForm.InventoryRequisitionUpdateSmallForm();
  133. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  134. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  135. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  136. frm.StrOrderNumber = this.listViewData.SelectedItems[0].Text.Trim();
  137. frm.ShowDialog();
  138. if (frm.IsSaveed)
  139. { this.PublicFunctionRows(); }
  140. else
  141. { this.listViewData.Select(); }
  142. }
  143. }
  144. /// <summary>
  145. /// 采购商品
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. void btnPurchaseProduct_Click(object sender, EventArgs e)
  150. {
  151. if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
  152. {
  153. LYFZ.Software.MainBusiness.InventoryManagement.SetSmallForm.InventoryPurchaseProductSmallForm frm = new SetSmallForm.InventoryPurchaseProductSmallForm();
  154. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  155. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  156. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  157. frm.StrOrderNumber = this.listViewData.SelectedItems[0].Text.Trim();
  158. frm.ShowDialog();
  159. if (frm.IsSaveed)
  160. { this.PublicFunctionRows(); }
  161. else
  162. { this.listViewData.Select(); }
  163. }
  164. }
  165. /// <summary>
  166. /// 采购验收
  167. /// </summary>
  168. /// <param name="sender"></param>
  169. /// <param name="e"></param>
  170. void btnPurchaseCheckAccept_Click(object sender, EventArgs e)
  171. {
  172. if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
  173. {
  174. LYFZ.Software.MainBusiness.InventoryManagement.SetSmallForm.InventoryPurchaseProductCheckAcceptSmallForm frm = new SetSmallForm.InventoryPurchaseProductCheckAcceptSmallForm();
  175. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  176. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  177. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  178. frm.StrOrderNumber = this.listViewData.SelectedItems[0].Text.Trim();
  179. frm.ShowDialog();
  180. if (frm.IsSaveed)
  181. { this.PublicFunctionRows(); }
  182. else
  183. { this.listViewData.Select(); }
  184. }
  185. }
  186. /// <summary>
  187. /// 按厂家采购
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. void btnByVendorPurchase_Click(object sender, EventArgs e)
  192. {
  193. LYFZ.Software.MainBusiness.InventoryManagement.SetSmallForm.InventoryByVendorPurchaseSmallForm frm = new SetSmallForm.InventoryByVendorPurchaseSmallForm();
  194. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  195. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  196. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  197. frm.ShowDialog();
  198. if (frm.IsSaveed)
  199. { this.PublicFunctionRows(); }
  200. }
  201. /// <summary>
  202. /// 按厂家验收
  203. /// </summary>
  204. /// <param name="sender"></param>
  205. /// <param name="e"></param>
  206. void btnByVendorCheckAccept_Click(object sender, EventArgs e)
  207. {
  208. LYFZ.Software.MainBusiness.InventoryManagement.SetSmallForm.InventoryByVendorCheckAcceptSmallForm frm = new SetSmallForm.InventoryByVendorCheckAcceptSmallForm();
  209. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  210. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  211. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  212. frm.ShowDialog();
  213. if (frm.IsSaveed)
  214. { this.PublicFunctionRows(); }
  215. }
  216. /// <summary>
  217. /// 打印
  218. /// </summary>
  219. /// <param name="sender"></param>
  220. /// <param name="e"></param>
  221. void btnPrint_Click(object sender, EventArgs e)
  222. {
  223. if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
  224. {
  225. LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.库存采购申请单, this.listViewData.SelectedItems[0].Text.Trim());
  226. }
  227. else
  228. { MessageBoxCustom.Show("无打印的数据!"); return; }
  229. }
  230. /// <summary>
  231. /// 删除
  232. /// </summary>
  233. /// <param name="sender"></param>
  234. /// <param name="e"></param>
  235. void btnDelete_Click(object sender, EventArgs e)
  236. {
  237. if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
  238. {
  239. LYFZ.Model.Model_ErpPurchaseOrder modelOrder = porbll.GetModel(Convert.ToInt32(this.listViewData.SelectedItems[0].Tag));
  240. if (modelOrder.Pord_PurchaseStatus.Trim() == "0")
  241. { MessageBoxCustom.Show("采购单已在采购中,不能删除采购单!"); return; }
  242. if (modelOrder.Pord_PurchaseStatus.Trim() == "1")
  243. { MessageBoxCustom.Show("采购单已采购OK,不能删除采购单!"); return; }
  244. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  245. clist.Add(porbll.GetDeleteCommandInfo("ID", "=", modelOrder.ID));
  246. clist.Add(pptbll.GetDeleteCommandInfo("Ppt_PurchaseNumber", "=", modelOrder.Pord_PurchaseNumber));
  247. if (clist.Count > 0)
  248. {
  249. if (MessageBoxCustom.Show("采购单删除后,则无法找!您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  250. { return; }
  251. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  252. {
  253. MessageBoxCustom.Show("删除成功!");
  254. this.listViewData.Items.Remove(this.listViewData.SelectedItems[0]);
  255. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData);
  256. }
  257. else
  258. { MessageBoxCustom.Show("删除失败!"); }
  259. }
  260. }
  261. }
  262. /// <summary>
  263. /// 关闭
  264. /// </summary>
  265. /// <param name="sender"></param>
  266. /// <param name="e"></param>
  267. void btnClose_Click(object sender, EventArgs e)
  268. {
  269. this.Close();
  270. }
  271. /// <summary>
  272. /// 窗体加载事件
  273. /// </summary>
  274. /// <param name="sender"></param>
  275. /// <param name="e"></param>
  276. void InventoryPurchaseOrderManagementFrmMain_Resize(object sender, EventArgs e)
  277. {
  278. for (int i = 0; i < this.listViewData.Columns.Count; i++)
  279. {
  280. switch (this.listViewData.Columns[i].Text.Trim())
  281. {
  282. case "采购单号":
  283. case "采购申请人":
  284. case "采购申请时间":
  285. case "采购状态":
  286. this.listViewData.Columns[i].Width = 150;
  287. break;
  288. default:
  289. this.listViewData.Columns[i].Width = this.listViewData.Width - (150 * 4) - 23;
  290. break;
  291. }
  292. }
  293. switch (this.panelCloseed.Location.Y)
  294. {
  295. case 5: this.flowLayoutPanel1.Height = 40; break;
  296. case 41: this.flowLayoutPanel1.Height = 75; break;
  297. }
  298. }
  299. /// <summary>
  300. /// 创建行
  301. /// </summary>
  302. void PublicFunctionRows()
  303. {
  304. this.listViewData.Items.Clear();
  305. string StrWhere = "";
  306. if (!string.IsNullOrEmpty(this.cmbtrrevOrderStatus.Text.Trim()) && this.cmbtrrevOrderStatus.Text.Trim() != "全部")
  307. { StrWhere += "Pord_PurchaseStatus = '" + this.cmbtrrevOrderStatus.Tag.ToString().Trim() + "'"; }
  308. DataTable dt = orbll.GetView_Custom("tb_ErpPurchaseOrder Left Join tb_ErpUser on User_EmployeeID = Pord_RequisitionName", StrWhere: StrWhere, ShowColumnName: "tb_ErpPurchaseOrder.ID,Pord_PurchaseNumber AS 采购单号,User_Name AS 采购申请人,dbo.fn_CheckDateTime(Pord_RequisitionTime) AS 申请采购时间,Pord_PurchaseStatus AS 采购状态", filedOrder: "Pord_RequisitionTime Desc").Tables[0];
  309. for (int i = 0; i < dt.Rows.Count; i++)
  310. {
  311. ListViewItem lvItem = new ListViewItem();
  312. if ((i % 2) > 0)
  313. { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
  314. else
  315. { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
  316. lvItem.Tag = dt.Rows[i]["ID"].ToString().Trim();
  317. lvItem.Text = dt.Rows[i]["采购单号"].ToString().Trim();
  318. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  319. ListSubItem.Name = "采购申请人";
  320. ListSubItem.Text = dt.Rows[i]["采购申请人"].ToString().Trim();
  321. lvItem.SubItems.Add(ListSubItem);
  322. ListSubItem = new ListViewItem.ListViewSubItem();
  323. ListSubItem.Name = "采购申请时间";
  324. ListSubItem.Text = dt.Rows[i]["申请采购时间"].ToString().Trim();
  325. lvItem.SubItems.Add(ListSubItem);
  326. ListSubItem = new ListViewItem.ListViewSubItem();
  327. ListSubItem.Name = "采购状态";
  328. ListSubItem.Text = Enum.GetName(typeof(LYFZ.EnumPublic.Ppt_PurchaseStatus), Convert.ToInt32(dt.Rows[i]["采购状态"]));
  329. lvItem.SubItems.Add(ListSubItem);
  330. if (dt.Rows[i]["采购状态"].ToString().Trim() == "0" || dt.Rows[i]["采购状态"].ToString().Trim() == "3")
  331. { lvItem.ForeColor = Color.Red; }
  332. this.listViewData.Items.Add(lvItem);
  333. }
  334. }
  335. }
  336. }