123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- 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 FrmPurchasingManagement : LYFZ.Software.UI.InventoryManagement.FrmPurchasingManagement
- {
- private delegate void UpdateControl();
- public FrmPurchasingManagement()
- {
- this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
- }
- /// <summary>
- /// 加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmPurchasingManagement_Shown(object sender, EventArgs e)
- {
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.Delete);
- this.btnPurchasingManagement.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.PurchasingManagement);
- this.btnAcceptanceManagement.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PurchasingManagementCompetence, CustomAttributes.OperatingAuthority.AcceptanceManagement);
- this.cmbPord_PurchaseStatus.Text = "全部";
- this.GetPurchaseOrder();
- }
- /// <summary>
- /// 获取采购订单表
- /// </summary>
- public void GetPurchaseOrder()
- {
- 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 cmbPord_PurchaseStatus_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.GetPurchaseOrder();
- }
- /// <summary>
- /// 采购管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnPurchasingManagement_Click(object sender, EventArgs e)
- {
- if (dgv.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择采购订单!"); return; }
- LYFZ.Software.MainBusiness.InventoryManagement.PurchasingManagement.FrmPurchase set = new PurchasingManagement.FrmPurchase();
- set.Pord_PurchaseNumber = dgv.CurrentRow.Cells["Pord_PurchaseNumber"].Value.ToString().Trim();
- if (set.ShowDialog() == DialogResult.OK)
- { this.GetPurchaseOrder(); }
- }
- /// <summary>
- /// 验收管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnAcceptanceManagement_Click(object sender, EventArgs e)
- {
- if (dgv.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择验收订单!"); return; }
- LYFZ.Software.MainBusiness.InventoryManagement.PurchasingManagement.FrmAcceptanceManagement set = new PurchasingManagement.FrmAcceptanceManagement();
- set.Pord_PurchaseNumber = dgv.CurrentRow.Cells["Pord_PurchaseNumber"].Value.ToString().Trim();
- if (set.ShowDialog() == DialogResult.OK)
- { this.GetPurchaseOrder(); }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
- {
- dgv.Rows.Clear();
- DataTable dt = new DataTable();
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(cmbPord_PurchaseStatus.Text))
- {
- if (cmbPord_PurchaseStatus.Text == "采购中")
- { str.Append("Pord_PurchaseStatus='0'"); }
- else if (cmbPord_PurchaseStatus.Text == "采购完成")
- { str.Append("Pord_PurchaseStatus='1'"); }
- else if (cmbPord_PurchaseStatus.Text == "采购取消")
- { str.Append("Pord_PurchaseStatus='2' "); }
- else if (cmbPord_PurchaseStatus.Text == "申请中")
- { str.Append("Pord_PurchaseStatus='3' "); }
- }
- else
- { str.Append(" Pord_PurchaseStatus = '3' or Pord_PurchaseStatus='0'"); }
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- pageData.TableName = "tb_ErpPurchaseOrder";
- pageData.PageIndex = this.ucPagerEx1.PageCurrent;
- pageData.PageSize = this.ucPagerEx1.PageSize;
- pageData.QueryCondition = str.ToString();
- pageData.QueryFieldName = "ID,Pord_PurchaseNumber,Pord_PurchaseName,Pord_RequisitionName,Pord_RequisitionTime,Pord_ApprovalStatus,Pord_ApprovalName,Pord_ApprovalTime,Pord_ApprovalRemark,Pord_PurchaseStatus";
- 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]["Pord_PurchaseNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- LYFZ.BLL.BLL_ErpUser ErpUserBll = new BLL.BLL_ErpUser();
- cell.Value = ErpUserBll.GetUserName(dt.Rows[t]["Pord_RequisitionName"].ToString().Trim());
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDateTime(dt.Rows[t]["Pord_RequisitionTime"]).ToString("yyyy-MM-dd").Trim();
- dgvr.Cells.Add(cell);
- #region 采购状态
- cell = new DataGridViewTextBoxCell();
- if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "0")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString();
- dgvr.DefaultCellStyle.ForeColor = Color.Orange;
- }
- else if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "1")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString();
- }
- else if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "2")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString();
- }
- else if (dt.Rows[t]["Pord_PurchaseStatus"].ToString().Trim() == "3")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString();
- dgvr.DefaultCellStyle.ForeColor = Color.Orange;
- }
- dgvr.Cells.Add(cell);
- #endregion
- this.dgv.Rows.Add(dgvr);
- }
- dgv.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)
- {
- if (this.dgv.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("请选中你要删除的数据!");
- return;
- }
- string Pord_PurchaseStatus = dgv.CurrentRow.Cells["Pord_PurchaseStatus"].Value.ToString();
- string Pord_PurchaseNumber = dgv.CurrentRow.Cells["Pord_PurchaseNumber"].Value.ToString();
- if (Pord_PurchaseStatus == "采购完成")
- {
- MessageBoxCustom.Show("此订单采购完成不能删除!");
- return;
- }
- if (MessageBoxCustom.Show("此订单正在【" + Pord_PurchaseStatus + "】,你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- if (new LYFZ.BLL.BLL_ErpPurchaseOrder().DeletePord_PurchaseNumber(Pord_PurchaseNumber) > 0)
- {
- string logsContent = "删除采购单订单号:" + Pord_PurchaseNumber;
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除采购单, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- MessageBoxCustom.Show("删除成功!");
- GetPurchaseOrder();
- }
- else
- { MessageBoxCustom.Show("删除失败!"); }
- }
- }
- }
- }
|