FrmPurchasingManagement.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 FrmPurchasingManagement : LYFZ.Software.UI.InventoryManagement.FrmPurchasingManagement
  13. {
  14. private delegate void UpdateControl();
  15. public FrmPurchasingManagement()
  16. {
  17. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  18. }
  19. /// <summary>
  20. /// 加载
  21. /// </summary>
  22. /// <param name="sender"></param>
  23. /// <param name="e"></param>
  24. protected override void FrmPurchasingManagement_Shown(object sender, EventArgs e)
  25. {
  26. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.Delete);
  27. this.btnPurchasingManagement.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.PurchasingManagement);
  28. this.btnAcceptanceManagement.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.AcceptanceManagement);
  29. this.cmbPord_PurchaseStatus.Text = "全部";
  30. this.GetPurchaseOrder();
  31. }
  32. /// <summary>
  33. /// 获取采购订单表
  34. /// </summary>
  35. public void GetPurchaseOrder()
  36. {
  37. this.ucPagerEx1.PageCurrent = 1;
  38. this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  39. this.ucPagerEx1.Bind();
  40. }
  41. /// <summary>
  42. /// 查询状态
  43. /// </summary>
  44. /// <param name="sender"></param>
  45. /// <param name="e"></param>
  46. protected override void cmbPord_PurchaseStatus_SelectedIndexChanged(object sender, EventArgs e)
  47. {
  48. this.GetPurchaseOrder();
  49. }
  50. /// <summary>
  51. /// 采购管理
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. protected override void btnPurchasingManagement_Click(object sender, EventArgs e)
  56. {
  57. if (dgv.SelectedRows.Count == 0)
  58. { MessageBoxCustom.Show("请选择采购订单!"); return; }
  59. LYFZ.Software.MainBusiness.InventoryManagement.PurchasingManagement.FrmPurchase set = new PurchasingManagement.FrmPurchase();
  60. set.Pord_PurchaseNumber = dgv.CurrentRow.Cells["Pord_PurchaseNumber"].Value.ToString().Trim();
  61. if (set.ShowDialog() == DialogResult.OK)
  62. { this.GetPurchaseOrder(); }
  63. }
  64. /// <summary>
  65. /// 验收管理
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. protected override void btnAcceptanceManagement_Click(object sender, EventArgs e)
  70. {
  71. if (dgv.SelectedRows.Count == 0)
  72. { MessageBoxCustom.Show("请选择验收订单!"); return; }
  73. LYFZ.Software.MainBusiness.InventoryManagement.PurchasingManagement.FrmAcceptanceManagement set = new PurchasingManagement.FrmAcceptanceManagement();
  74. set.Pord_PurchaseNumber = dgv.CurrentRow.Cells["Pord_PurchaseNumber"].Value.ToString().Trim();
  75. if (set.ShowDialog() == DialogResult.OK)
  76. { this.GetPurchaseOrder(); }
  77. }
  78. /// <summary>
  79. /// 关闭
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. protected override void btnClose_Click(object sender, EventArgs e)
  84. {
  85. this.Close();
  86. }
  87. /// <summary>
  88. /// 画分页
  89. /// </summary>
  90. /// <param name="e"></param>
  91. /// <returns></returns>
  92. private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  93. {
  94. dgv.Rows.Clear();
  95. DataTable dt = new DataTable();
  96. StringBuilder str = new StringBuilder();
  97. if (!string.IsNullOrEmpty(cmbPord_PurchaseStatus.Text))
  98. {
  99. if (cmbPord_PurchaseStatus.Text == "采购中")
  100. { str.Append("Pord_PurchaseStatus='0'"); }
  101. else if (cmbPord_PurchaseStatus.Text == "采购完成")
  102. { str.Append("Pord_PurchaseStatus='1'"); }
  103. else if (cmbPord_PurchaseStatus.Text == "采购取消")
  104. { str.Append("Pord_PurchaseStatus='2' "); }
  105. else if (cmbPord_PurchaseStatus.Text == "申请中")
  106. { str.Append("Pord_PurchaseStatus='3' "); }
  107. }
  108. else
  109. { str.Append(" Pord_PurchaseStatus = '3' or Pord_PurchaseStatus='0'"); }
  110. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  111. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  112. {
  113. pageData.TableName = "tb_ErpPurchaseOrder";
  114. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  115. pageData.PageSize = this.ucPagerEx1.PageSize;
  116. pageData.QueryCondition = str.ToString();
  117. pageData.QueryFieldName = "ID,Pord_PurchaseNumber,Pord_PurchaseName,Pord_RequisitionName,Pord_RequisitionTime,Pord_ApprovalStatus,Pord_ApprovalName,Pord_ApprovalTime,Pord_ApprovalRemark,Pord_PurchaseStatus";
  118. pageData.OrderStr = " ID desc ";
  119. DataSet da = pageData.QueryDataTable();
  120. dt = da.Tables[0];
  121. if (dt.Rows.Count > 0)
  122. {
  123. this.Invoke(new UpdateControl(delegate()
  124. {
  125. for (int t = 0; t < dt.Rows.Count; t++)
  126. {
  127. DataGridViewRow dgvr = new DataGridViewRow();
  128. DataGridViewCell cell = null;
  129. cell = new DataGridViewTextBoxCell();
  130. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  131. dgvr.Cells.Add(cell);
  132. cell = new DataGridViewTextBoxCell();
  133. cell.Value = dt.Rows[t]["Pord_PurchaseNumber"].ToString().Trim();
  134. dgvr.Cells.Add(cell);
  135. cell = new DataGridViewTextBoxCell();
  136. LYFZ.BLL.BLL_ErpUser ErpUserBll = new BLL.BLL_ErpUser();
  137. cell.Value = ErpUserBll.GetUserName(dt.Rows[t]["Pord_RequisitionName"].ToString().Trim());
  138. dgvr.Cells.Add(cell);
  139. cell = new DataGridViewTextBoxCell();
  140. cell.Value = Convert.ToDateTime(dt.Rows[t]["Pord_RequisitionTime"]).ToString("yyyy-MM-dd").Trim();
  141. dgvr.Cells.Add(cell);
  142. #region 采购状态
  143. cell = new DataGridViewTextBoxCell();
  144. if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "0")
  145. {
  146. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString();
  147. dgvr.DefaultCellStyle.ForeColor = Color.Orange;
  148. }
  149. else if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "1")
  150. {
  151. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString();
  152. }
  153. else if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "2")
  154. {
  155. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString();
  156. }
  157. else if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "3")
  158. {
  159. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString();
  160. dgvr.DefaultCellStyle.ForeColor = Color.Orange;
  161. }
  162. dgvr.Cells.Add(cell);
  163. #endregion
  164. this.dgv.Rows.Add(dgvr);
  165. }
  166. dgv.ClearSelection();
  167. }));
  168. }
  169. });
  170. try
  171. {
  172. this.ucPagerEx1.TbDataSource = dt;
  173. }
  174. catch { }
  175. return pageData.TotalCount;
  176. }
  177. /// <summary>
  178. /// 删除
  179. /// </summary>
  180. /// <param name="sender"></param>
  181. /// <param name="e"></param>
  182. protected override void btnDelete_Click(object sender, EventArgs e)
  183. {
  184. if (this.dgv.SelectedRows.Count == 0)
  185. {
  186. MessageBoxCustom.Show("请选中你要删除的数据!");
  187. return;
  188. }
  189. string Pord_PurchaseStatus = dgv.CurrentRow.Cells["Pord_PurchaseStatus"].Value.ToString();
  190. string Pord_PurchaseNumber = dgv.CurrentRow.Cells["Pord_PurchaseNumber"].Value.ToString();
  191. if (Pord_PurchaseStatus == "采购完成")
  192. {
  193. MessageBoxCustom.Show("此订单采购完成不能删除!");
  194. return;
  195. }
  196. if (MessageBoxCustom.Show("此订单正在【" + Pord_PurchaseStatus + "】,你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  197. {
  198. if (new LYFZ.BLL.BLL_ErpPurchaseOrder().DeletePord_PurchaseNumber(Pord_PurchaseNumber) > 0)
  199. {
  200. string logsContent = "删除采购单订单号:" + Pord_PurchaseNumber;
  201. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除采购单, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  202. MessageBoxCustom.Show("删除成功!");
  203. GetPurchaseOrder();
  204. }
  205. else
  206. { MessageBoxCustom.Show("删除失败!"); }
  207. }
  208. }
  209. }
  210. }