123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- using LYFZ.ComponentLibrary;
- using System;
- using System.Collections;
- 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.PurchasingManagement
- {
- public partial class FrmAcceptanceManagement : LYFZ.Software.UI.InventoryManagement.PurchasingManagement.AcceptanceManagement
- {
- private delegate void UpdateControl();
- bool bl = false;
- public string Pord_PurchaseNumber;
- public FrmAcceptanceManagement()
- {
- this.FormClosed += FrmAcceptanceManagement_FormClosed;
- this.dgv1.CellMouseDown += dgv1_CellMouseDown;
- this.dgv1.DataGridViewConMenu_ItemClicked += dgv1_DataGridViewConMenu_ItemClicked;
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmAcceptanceManagement_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (bl)
- { this.DialogResult = DialogResult.OK; }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void AcceptanceManagement_Shown(object sender, EventArgs e)
- { this.GetPurchaseProduct(Pord_PurchaseNumber); }
- /// <summary>
- /// 获取采购商品表
- /// </summary>
- public void GetPurchaseProduct(string Ppt_PurchaseNumber)
- {
- dgv1.Rows.Clear();
- LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductbll = new BLL.BLL_ErpPurchaseProduct();
- DataTable dt = PurchaseProductbll.View_tb_PurchaseProduct(" and Ppt_PurchaseNumber='" + Ppt_PurchaseNumber + "'").Tables[0];
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- 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]["Ppt_PurchaseNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_ProductNumberName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_PurchaseQuantity"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_ProductCategoryName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_ProductCategory"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_ProductNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_PurchasePrice"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_PurchaseVendor"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "0")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString();
- dgvr.DefaultCellStyle.ForeColor = Color.Orange;
- }
- else if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "1")
- { cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString(); }
- else if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "2")
- { cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString(); }
- else if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "3")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString();
- dgvr.DefaultCellStyle.ForeColor = Color.Orange;
- }
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_PurchasePerson"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDateTime(dt.Rows[t]["Ppt_PurchaseTime"]).ToString("yyyy-MM-dd").Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_AcceptanceQuantity"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ppt_AcceptanceName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDateTime(dt.Rows[t]["Ppt_AcceptanceTime"]).ToString("yyyy-MM-dd").Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToInt32(dt.Rows[t]["Ppt_PurchaseQuantity"].ToString().Trim()) - Convert.ToInt32(dt.Rows[t]["Ppt_AcceptanceQuantity"].ToString().Trim());
- dgvr.Cells.Add(cell);
- this.dgv1.Rows.Add(dgvr);
- }
- this.dgv1.ClearSelection();
- }));
- });
- }
- /// <summary>
- /// 验收
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnPurchase_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
- if (dgv1.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择验收的商品!可多选!"); return; }
- // 商品采购状态判断
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- string Status = dgv1.SelectedRows[i].Cells["Status"].Value.ToString();
- string Ir_ProductName = dgv1.SelectedRows[i].Cells["Ir_ProductName"].Value.ToString();
- if (Status.ToString() == "申请中")
- { MessageBoxCustom.Show("商品正在申请中,不能验收!"); return; }
- if (Status.ToString() == "采购取消")
- { MessageBoxCustom.Show(Ir_ProductName + " 商品已经取消采购,不能验收!"); return; }
- if (Status.ToString() == "采购完成")
- { MessageBoxCustom.Show(Ir_ProductName + " 商品已经采购完成,不能验收!"); return; }
- }
- if (dgv1.SelectedRows.Count > 0)
- {
- #region 修改采购商品表
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- int id = Convert.ToInt32(dgv1.SelectedRows[i].Cells["ID"].Value);
- LYFZ.Model.Model_ErpPurchaseProduct PurchaseProductModel = PurchaseProductBll.GetModel(id);
- PurchaseProductModel.Ppt_AcceptanceQuantity = Convert.ToInt32(dgv1.SelectedRows[i].Cells["BcAcceptance"].Value) + Convert.ToInt32(dgv1.SelectedRows[i].Cells["Ppt_AcceptanceQuantity"].Value);
- PurchaseProductBll.Update(PurchaseProductModel);
- }
- #endregion
- #region 更新采购商品表状态
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- string Prod_Number = dgv1.SelectedRows[i].Cells["Prod_Number"].Value.ToString();
- int Id = Convert.ToInt32(dgv1.SelectedRows[i].Cells["ID"].Value);
- int Prod_Quantity = Convert.ToInt32(dgv1.SelectedRows[i].Cells["Prod_Quantity"].Value);
- int Ppt_AcceptanceQuantity = Convert.ToInt32(PurchaseProductBll.GetList("Ppt_PurchaseNumber='" + Pord_PurchaseNumber + "' and Ppt_ProductNumber='" + Prod_Number + "'").Tables[0].Rows[0]["Ppt_AcceptanceQuantity"]); //Convert.ToInt32(dgv1.SelectedRows[i].Cells["Ppt_AcceptanceQuantity"].Value);
- if (Prod_Quantity == Ppt_AcceptanceQuantity)
- {
- PurchaseProductBll.UpdatePpt_PurchaseStatus("Ppt_PurchaseStatus='1',Ppt_AcceptanceName='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name + "',Ppt_AcceptanceTime='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd") + "' ", Id);
- }
- if (Prod_Quantity < Ppt_AcceptanceQuantity)
- {
- PurchaseProductBll.UpdatePpt_PurchaseStatus("Ppt_PurchaseStatus='0',Ppt_AcceptanceName='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name + "',Ppt_AcceptanceTime='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd") + "' ", Id);
- }
- }
- #endregion
- #region 更新采购订单表状态
- int sum = PurchaseProductBll.GetCount("Ppt_PurchaseNumber='" + Pord_PurchaseNumber + "'");
- int Qx = PurchaseProductBll.GetCount("Ppt_PurchaseNumber='" + Pord_PurchaseNumber + "' and Ppt_PurchaseStatus='1'");
- int CgzOrQx = PurchaseProductBll.GetCount("Ppt_PurchaseNumber='" + Pord_PurchaseNumber + "' and (Ppt_PurchaseStatus='0' or Ppt_PurchaseStatus='3')");
- if (sum == Qx)
- {
- PurchaseProductBll.UpdateCgDd("1", Pord_PurchaseNumber);
- }
- if (CgzOrQx == 0)
- {
- PurchaseProductBll.UpdateCgDd("1", Pord_PurchaseNumber);
- }
- #endregion
- #region 新增入库
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- int id = Convert.ToInt32(dgv1.SelectedRows[i].Cells["ID"].Value);
- string Prod_Number = dgv1.SelectedRows[i].Cells["Prod_Number"].Value.ToString();
- int BcAcceptance = Convert.ToInt32(dgv1.SelectedRows[i].Cells["BcAcceptance"].Value);
- if (BcAcceptance != 0)
- {
- #region 新增入库记录表
- LYFZ.Model.Model_ErpProductIntStorage ProductIntStorageModel = new Model.Model_ErpProductIntStorage();
- LYFZ.BLL.BLL_ErpProductIntStorage ProductIntStorageBll = new BLL.BLL_ErpProductIntStorage();
- ProductIntStorageModel.Pis_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID();
- ProductIntStorageModel.Pis_ProductCategory = dgv1.SelectedRows[i].Cells["Prod_Class"].Value.ToString();
- ProductIntStorageModel.Pis_ProductNumber = dgv1.SelectedRows[i].Cells["Prod_Number"].Value.ToString();
- ProductIntStorageModel.Pis_PurchaseQuantity = Convert.ToInt32(dgv1.SelectedRows[i].Cells["BcAcceptance"].Value);
- ProductIntStorageModel.Pis_PurchaseVendor = dgv1.SelectedRows[i].Cells["Ppt_PurchaseVendor"].Value.ToString();
- ProductIntStorageModel.Pis_PurchasePrice = Convert.ToDecimal(dgv1.SelectedRows[i].Cells["Ppt_PurchasePrice"].Value);
- ProductIntStorageModel.Pis_Remark = "";
- ProductIntStorageModel.Pis_CreateDatetime = Convert.ToDateTime(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd"));
- ProductIntStorageModel.Pis_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- ProductIntStorageBll.Add(ProductIntStorageModel);
- #endregion
- #region 更新采购商品入库状态
- LYFZ.Model.Model_ErpPurchaseProduct PurchaseProductModel = PurchaseProductBll.GetModel(id);
- PurchaseProductModel.Ppt_StorageStatus = "1";
- PurchaseProductBll.Update(PurchaseProductModel);
- #endregion
- #region 更新商品库存数量
- LYFZ.BLL.BLL_ErpProduct ProductBll = new BLL.BLL_ErpProduct();
- DataTable dt = ProductBll.GetList("Prod_Number='" + Prod_Number + "'").Tables[0];
- int sumQuantity = BcAcceptance + Convert.ToInt32(dt.Rows[0]["Prod_Quantity"]);
- ProductBll.UpdateProduct("Prod_Quantity=" + sumQuantity + "", Prod_Number);
- #endregion
- }
- }
- #endregion
- }
- GetPurchaseProduct(Pord_PurchaseNumber);
- bl = true;
- MessageBoxCustom.Show("保存成功!");
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 不验收
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnNotPurchase_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
- if (dgv1.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择不验收的商品!可多选!"); return; }
- // 判断商品状态
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- string Ir_ProductName = dgv1.SelectedRows[i].Cells["Ir_ProductName"].Value.ToString();
- string Status = dgv1.SelectedRows[i].Cells["Status"].Value.ToString();
- if (Status.ToString() == "申请中")
- { MessageBoxCustom.Show("商品正在申请中,不能验收!"); return; }
- if (Status.ToString() == "采购取消")
- { MessageBoxCustom.Show(Ir_ProductName + " 商品已经取消采购,不能验收!"); return; }
- if (Status.ToString() == "采购完成")
- { MessageBoxCustom.Show(Ir_ProductName + " 商品已经采购完成,不能验收!"); return; }
- }
- #region 更新采购商品表状态
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- int Id = Convert.ToInt32(dgv1.SelectedRows[i].Cells["ID"].Value);
- PurchaseProductBll.UpdatePpt_PurchaseStatus("Ppt_PurchaseStatus='2',Ppt_AcceptanceName='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name + "',Ppt_AcceptanceTime='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd") + "' ", Id);
- }
- #endregion
- #region 更新采购订单表状态
- int sum = PurchaseProductBll.GetCount("Ppt_PurchaseNumber='" + Pord_PurchaseNumber + "'");
- int Qx = PurchaseProductBll.GetCount("Ppt_PurchaseNumber='" + Pord_PurchaseNumber + "' and Ppt_PurchaseStatus='2'");
- int CgzOrQx = PurchaseProductBll.GetCount("Ppt_PurchaseNumber='" + Pord_PurchaseNumber + "' and (Ppt_PurchaseStatus='0' or Ppt_PurchaseStatus='3')");
- if (sum == Qx)
- {
- PurchaseProductBll.UpdateCgDd("2", Pord_PurchaseNumber);
- }
- if (CgzOrQx == 0)
- {
- PurchaseProductBll.UpdateCgDd("1", Pord_PurchaseNumber);
- }
- #endregion
- GetPurchaseProduct(Pord_PurchaseNumber);
- bl = true;
- MessageBoxCustom.Show("保存成功!");
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- /// <summary>
- /// 保存更改数量
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if (dgv1.Rows.Count > 0)
- {
- if (MessageBoxCustom.Show("你确定修改采购列表中的商品吗?", "增加提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- #region 修改采购商品表
- for (int i = 0; i < dgv1.Rows.Count; i++)
- {
- int id = Convert.ToInt32(dgv1.Rows[i].Cells["ID"].Value);
- //string Ppt_PurchaseVendor = dgv1.Rows[i].Cells["Ppt_PurchaseVendor"].Value.ToString();
- //LYFZ.BLL.BLL_ErpVendor VendorBll = new BLL.BLL_ErpVendor();
- LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
- LYFZ.Model.Model_ErpPurchaseProduct PurchaseProductModel = PurchaseProductBll.GetModel(id);
- PurchaseProductModel.Ppt_PurchasePrice = Convert.ToDecimal(dgv1.Rows[i].Cells["Ppt_PurchasePrice"].Value);
- PurchaseProductModel.Ppt_PurchaseVendor = dgv1.Rows[i].Cells["Ppt_PurchaseVendor"].Value.ToString();
- PurchaseProductModel.Ppt_AcceptanceQuantity = Convert.ToInt32(dgv1.Rows[i].Cells["Ppt_AcceptanceQuantity"].Value);
- PurchaseProductBll.Update(PurchaseProductModel);
- }
- GetPurchaseProduct(Pord_PurchaseNumber);
- MessageBoxCustom.Show("保存成功!");
- #endregion
- }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <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="sender"></param>
- /// <param name="e"></param>
- protected override void dgv1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (dgv1.Rows.Count > 0)
- {
- if (dgv1.CurrentRow.Cells["BcAcceptance"].Value == null)
- {
- MessageBoxCustom.Show("本次验收数量不能为空!");
- dgv1.CurrentRow.Cells["BcAcceptance"].Value = Convert.ToInt32(dgv1.CurrentRow.Cells["Prod_Quantity"].Value) - Convert.ToInt32(dgv1.CurrentRow.Cells["Ppt_AcceptanceQuantity"].Value);
- return;
- }
- if (Command.Command_Validate.IsNumber(dgv1.CurrentRow.Cells["BcAcceptance"].Value.ToString()) == false)
- {
- MessageBoxCustom.Show("只能输入纯数字!");
- dgv1.CurrentRow.Cells["BcAcceptance"].Value = Convert.ToInt32(dgv1.CurrentRow.Cells["Prod_Quantity"].Value) - Convert.ToInt32(dgv1.CurrentRow.Cells["Ppt_AcceptanceQuantity"].Value);
- return;
- }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 导出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnExport_Click(object sender, EventArgs e)
- {
- if (dgv1.Rows.Count > 0)
- { dgv1.ExportDataTable(); }
- }
- /// <summary>
- /// 打印
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnPrint_Click(object sender, EventArgs e)
- {
- if (dgv1.Rows.Count == 0)
- { MessageBoxCustom.Show("无打印数据!"); return; }
- Hashtable htData = new Hashtable();
- htData["dgvData"] = this.dgv1;
- LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.库存采购验收单, htData);
- }
- /// <summary>
- /// 左键菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgv1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- ToolStripMenuItem item = null;
- item = new ToolStripMenuItem();
- item.Text = "查看商品图片";
- item.Tag = "View";
- this.dgv1.conMenu.Items.Add(item);
- }
- }
- void dgv1_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- ToolStripItem item = e.ClickedItem;
- if (item.Tag.ToString().Trim() == "View")
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ProductViewPhoto(this.dgv1.CurrentRow.Cells["Prod_Number"].Value.ToString().Trim());
- }
- }
- }
- }
|