123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669 |
- 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 FrmStock : LYFZ.Software.UI.InventoryManagement.FrmStock
- {
- private delegate void UpdateControl();
- public FrmStock()
- {
- this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
- this.dgv1.CellMouseDown += dgv1_CellMouseDown;
- this.dgv1.DataGridViewConMenu_ItemClicked += dgv1_DataGridViewConMenu_ItemClicked;
- this.dgv1.MouseDoubleClick += dgv1_MouseDoubleClick;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmStock_Shown(object sender, EventArgs e)
- {
- bind();
- SelectGoods();
- btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StockCompetence, CustomAttributes.OperatingAuthority.Add);
- btndelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StockCompetence, CustomAttributes.OperatingAuthority.Delete);
- btnInventory.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StockCompetence, CustomAttributes.OperatingAuthority.InstockInventory);
- btnProcurementApplication.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StockCompetence, CustomAttributes.OperatingAuthority.ProcurementApplication);
- }
- /// <summary>
- /// 盘点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnInventory_Click(object sender, EventArgs e)
- {
- if (dgv1.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("你选择你要盘点的商品,可多选!");
- return;
- }
- string Id = null;
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- int id = Convert.ToInt32(dgv1.SelectedRows[i].Cells["ID"].Value);
- Id += id + ",";
- }
- LYFZ.Software.MainBusiness.InventoryManagement.FrmInventory set = new FrmInventory();
- set.ID = Id;
- if (set.ShowDialog() == DialogResult.OK)
- {
- dgv1.Rows.Clear();
- bind();
- }
- }
- /// <summary>
- /// 报警商品
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnPurchaseOrder_Click(object sender, EventArgs e)
- {
- DataTable dt = PurchaseProductbll.View_tb_ErpProduct(" and Prod_Quantity<=Prod_AlarmQuantity and Prod_Availability=1").Tables[0];
- if (dt.Rows.Count > 0)
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dgv2.Rows.Count > 0)
- {
- for (int t = 0; t < dgv2.Rows.Count; t++)
- {
- if (dt.Rows[i]["Prod_Number"].ToString().Trim() == dgv2.Rows[t].Cells["Prod_Number"].Value.ToString())
- {
- MessageBoxCustom.Show(dt.Rows[i]["Prod_Name"].ToString().Trim() + " 商品已经存在列表中!不能再增加!");
- return;
- }
- }
- }
- }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- 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]["Prod_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "0";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_ClassName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Class"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Number"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "";
- dgvr.Cells.Add(cell);
- this.Invoke(new UpdateControl(delegate()
- {
- this.dgv2.Rows.Add(dgvr);
- dgv2.ClearSelection();
- }));
- }
- });
- }
- else
- { MessageBoxCustom.Show("无报警商品!"); }
- }
- /// <summary>
- /// 申请采购管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnProcurementApplication_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InventoryManagement.FrmProcurementApplication set = new FrmProcurementApplication();
- set.ShowDialog();
- }
- /// <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>
- void dgv1_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (dgv1.Rows.Count > 0)
- {
- if (e.Location.Y > this.dgv1.ColumnHeadersHeight)
- {
- string Sp_Number = dgv1.CurrentRow.Cells["Sp_Number"].Value.ToString();
- string Ir_ProductName = dgv1.CurrentRow.Cells["Ir_ProductName"].Value.ToString();
- if (dgv2.Rows.Count > 0)
- {
- for (int i = 0; i < dgv2.Rows.Count; i++)
- {
- if (Sp_Number.ToString() == dgv2.Rows[i].Cells["Prod_Number"].Value.ToString())
- {
- MessageBoxCustom.Show(Ir_ProductName + " 商品已经存在列表中!不能再增加!");
- return;
- }
- }
- }
- #region 获取采购商品
- LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
- DataTable dt = Productbll.View_tb_ErpProduct("Prod_Number='" + Sp_Number + "'").Tables[0];
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
- DataTable dal = new DataTable();
- dal = PurchaseProductBll.GetList("Ppt_ProductNumber='" + dt.Rows[t]["Prod_Number"].ToString().Trim() + "' and (Ppt_PurchaseStatus='0' or Ppt_PurchaseStatus='3') ").Tables[0];
- 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]["Prod_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "0";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_ClassName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Class"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Number"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- if (dal.Rows.Count > 0)
- {
- if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "0")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString();
- }
- else if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "1")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString();
- }
- else if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "2")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString();
- }
- else if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "3")
- {
- cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString();
- }
- }
- else
- { cell.Value = "可申请"; }
- dgvr.Cells.Add(cell);
- this.dgv2.Rows.Add(dgvr);
- }
- dgv2.ClearSelection();
- #endregion
- }
- }
- }
- /// <summary>
- /// 商品库存双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgv1_DoubleClick(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 只能输入数字
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgv2_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (dgv2.Rows.Count > 0)
- {
- if (dgv2.CurrentRow.Cells["CgSl"].Value == null)
- {
- MessageBoxCustom.Show("采购数量不能为空!");
- dgv2.CurrentRow.Cells["CgSl"].Value = "0";
- return;
- }
- if (Command.Command_Validate.IsNumber(dgv2.CurrentRow.Cells["CgSl"].Value.ToString()) == false)
- {
- MessageBoxCustom.Show("只能输入纯数字!");
- dgv2.CurrentRow.Cells["CgSl"].Value = "0";
- return;
- }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btndelete_Click(object sender, EventArgs e)
- {
- if (dgv2.SelectedCells.Count == 0)
- {
- MessageBoxCustom.Show("请选择你要删除的数据!");
- return;
- }
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- for (int i = dgv2.SelectedRows.Count; i > 0; i--)
- {
- this.Invoke(new UpdateControl(delegate()
- {
- dgv2.Rows.RemoveAt(dgv2.SelectedRows[i - 1].Index);
- }));
- }
- });
- }
- }
- LYFZ.BLL.BLL_ErpPurchaseOrder PurchaseOrderBll = new BLL.BLL_ErpPurchaseOrder();
- LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductbll = new BLL.BLL_ErpPurchaseProduct();
- /// <summary>
- /// 采购
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- if (dgv2.Rows.Count > 0)
- {
- for (int i = 0; i < dgv2.Rows.Count; i++)
- {
- if (Convert.ToInt32(dgv2.Rows[i].Cells["CgSl"].Value) <= 0)
- {
- MessageBoxCustom.Show(dgv2.Rows[i].Cells["spmc"].Value.ToString().Trim() + " 采购数量不能小于等于0!");
- return;
- }
- }
- if (MessageBoxCustom.Show("你确定采购列表中的商品吗?", "增加提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- #region 增加采购订单表
- LYFZ.Model.Model_ErpPurchaseOrder PurchaseOrderModel = new Model.Model_ErpPurchaseOrder();
- PurchaseOrderModel.Pord_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- PurchaseOrderModel.Pord_PurchaseNumber = "St" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMMddHHmmss") + new Random().Next(100, 1000);
- PurchaseOrderModel.Pord_PurchaseName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd") + " 采购单";
- PurchaseOrderModel.Pord_RequisitionName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- PurchaseOrderModel.Pord_RequisitionTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- PurchaseOrderModel.Pord_ApprovalStatus = "1";
- PurchaseOrderModel.Pord_ApprovalName = "";
- PurchaseOrderModel.Pord_ApprovalTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- PurchaseOrderModel.Pord_ApprovalRemark = "";
- PurchaseOrderModel.Pord_PurchaseStatus = "3";
- clist.Add(PurchaseOrderBll.GetAddCommandInfo(PurchaseOrderModel));
- #endregion
- #region 增加采购商品表
- LYFZ.Model.Model_ErpPurchaseProduct PurchaseProductModel = null;
- for (int i = 0; i < dgv2.Rows.Count; i++)
- {
- PurchaseProductModel = new Model.Model_ErpPurchaseProduct();
- PurchaseProductModel.Ppt_PurchaseNumber = PurchaseOrderModel.Pord_PurchaseNumber;
- PurchaseProductModel.Ppt_ProductCategory = dgv2.Rows[i].Cells["Prod_Class"].Value.ToString();
- PurchaseProductModel.Ppt_ProductNumber = dgv2.Rows[i].Cells["Prod_Number"].Value.ToString();
- PurchaseProductModel.Ppt_PurchaseQuantity = Convert.ToInt32(dgv2.Rows[i].Cells["CgSl"].Value);
- PurchaseProductModel.Ppt_PurchaseVendor = "";
- PurchaseProductModel.Ppt_PurchasePrice = 0;
- PurchaseProductModel.Ppt_PurchaseStatus = "3";
- PurchaseProductModel.Ppt_PurchasePerson = "";
- PurchaseProductModel.Ppt_PurchaseTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- PurchaseProductModel.Ppt_AcceptanceQuantity = 0;
- PurchaseProductModel.Ppt_AcceptanceTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- PurchaseProductModel.Ppt_AcceptanceName = "";
- PurchaseProductModel.Ppt_StorageStatus = "0";
- PurchaseProductModel.Ppt_Remark = "";
- clist.Add(PurchaseProductbll.GetAddCommandInfo(PurchaseProductModel));
- }
- #endregion
- if (clist.Count > 0)
- {
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- {
- MessageBoxCustom.Show("保存成功!采购单号已生成!");
- FrmStock_Shown(sender, e);
- dgv2.Rows.Clear();
- }
- else
- { MessageBoxCustom.Show("增加采购失败!"); }
- }
- }
- }
- else
- { MessageBoxCustom.Show("列表中商品不能为空!请添加商品!"); }
- }
- /// <summary>
- /// 绑定查询商品类别
- /// </summary>
- public void SelectGoods()
- {
- CtvSelect.TreeView.Nodes.Clear();
- LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
- DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID='1'").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- TreeNode root = null;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- if (i == 0)
- {
- root = new TreeNode("全部");
- this.CtvSelect.TreeView.Nodes.Add(root);
- }
- root = new TreeNode();
- root.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
- root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- this.CreateTreeViewShop(root.Nodes, tbl.Rows[i]["ID"].ToString());
- this.CtvSelect.TreeView.Nodes.Add(root);
- }
- }
- }
- /// <summary>
- /// 绑定第三级商品类别
- /// </summary>
- /// <param name="nodes">TreeView的节点集合</param>
- /// <param name="dataSource">数据源</param>
- /// <param name="parentid"></param>
- private void CreateTreeViewShop(TreeNodeCollection nodes, string ClassCode)
- {
- if (ClassCode != "")
- {
- LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
- DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID=" + ClassCode + "").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- TreeNode node;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- node = new TreeNode();
- node.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
- node.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- nodes.Add(node);
- }
- }
- }
- }
- /// <summary>
- /// 商品查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void CtvSelect_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
- {
- bind();
- }
- DataTable dt_PurchaseProduct = null;
- public void bind()
- {
- this.ucPagerEx1.PageCurrent = 1;
- this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
- this.ucPagerEx1.Bind();
- }
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
- {
- dgv1.Rows.Clear();
- DataTable dt = new DataTable();
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- StringBuilder str = new StringBuilder();
- if (CtvSelect.Text == "" || CtvSelect.Tag == null || CtvSelect.Text == "全部")
- { str.Append(" 1=1 and Prod_IsEnabled='1' and Prod_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "' and Prod_Availability=1"); }
- if (CtvSelect.Tag != null)
- { str.Append(" 1=1 and Prod_Class='" + CtvSelect.Tag.ToString() + "' and Prod_IsEnabled='1' and Prod_DividedShop='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID() + "' and Prod_Availability=1"); }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- pageData.TableName = "View_tb_ErpProduct";
- pageData.PageIndex = this.ucPagerEx1.PageCurrent;
- pageData.PageSize = this.ucPagerEx1.PageSize;
- pageData.QueryCondition = str.ToString();
- pageData.QueryFieldName = "ID,Prod_Number,Prod_DividedShop,Prod_Name,Prod_Class,Prod_Unit,Prod_CostPrice,Prod_SalesPrice,Prod_SpecialPrice,Prod_AlarmQuantity,Prod_IsEnabled,Prod_Quantity,Prod_Expedited,Prod_CreateDatetime,Prod_PreSaleQuantity,Prod_Batch,Prod_ClassName,Sc_ClassCode,Prod_ClassName2,Prod_IsEnabledName,Prod_Availability";
- pageData.OrderStr = "ID desc";
- pageData.OrderType = 1;
- DataSet da = pageData.QueryDataTable();
- dt = da.Tables[0];
- if (dt.Rows.Count > 0)
- {
- dt_PurchaseProduct = PurchaseProductbll.GetAllList().Tables[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]["Prod_Number"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Quantity"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_ClassName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_AlarmQuantity"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_PreSaleQuantity"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- DataRow[] dt_PurchaseProduct2 = dt_PurchaseProduct.Select("Ppt_ProductNumber='" + dt.Rows[t]["Prod_Number"].ToString().Trim() + "' and (Ppt_PurchaseStatus='0' or Ppt_PurchaseStatus='3') ");
- if (dt_PurchaseProduct2.Length > 0)
- { cell.Value = "已申请"; }
- else
- { cell.Value = ""; }
- dgvr.Cells.Add(cell);
- if (Convert.ToInt32(dt.Rows[t]["Prod_Quantity"]) <= Convert.ToInt32(dt.Rows[t]["Prod_AlarmQuantity"]))
- { dgvr.DefaultCellStyle.ForeColor = Color.Red; }
- this.dgv1.Rows.Add(dgvr);
- }
- dgv1.ClearSelection();
- }));
- }
- });
- try
- {
- this.ucPagerEx1.TbDataSource = dt;
- }
- catch { }
- return pageData.TotalCount;
- }
- /// <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);
- item = new ToolStripMenuItem();
- item.Text = "增加采购";
- item.Tag = "Add";
- this.dgv1.conMenu.Items.Add(item);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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["Sp_Number"].Value.ToString().Trim());
- }
- else if (item.Tag.ToString().Trim() == "Add")
- {
- if (dgv1.Rows.Count > 0)
- {
- if (dgv1.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择你要采购的商品!"); return; }
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- if (dgv2.Rows.Count > 0)
- {
- for (int t = 0; t < dgv2.Rows.Count; t++)
- {
- if (dgv1.SelectedRows[i].Cells["Sp_Number"].Value.ToString().Trim() == dgv2.Rows[t].Cells["Prod_Number"].Value.ToString())
- {
- MessageBoxCustom.Show(dgv1.SelectedRows[i].Cells["Ir_ProductName"].Value.ToString().Trim() + " 商品已经存在列表中!不能再增加!");
- return;
- }
- }
- }
- }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- for (int i = 0; i < dgv1.SelectedRows.Count; i++)
- {
- string Sp_Number = dgv1.SelectedRows[i].Cells["Sp_Number"].Value.ToString();
- string Ir_ProductName = dgv1.SelectedRows[i].Cells["Ir_ProductName"].Value.ToString();
- LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
- DataTable dt = Productbll.View_tb_ErpProduct("Prod_Number='" + Sp_Number + "'").Tables[0];
- if (dt.Rows.Count > 0)
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
- DataTable dal = new DataTable();
- dal = PurchaseProductBll.GetList("Ppt_ProductNumber='" + dt.Rows[t]["Prod_Number"].ToString().Trim() + "' and (Ppt_PurchaseStatus='0' or Ppt_PurchaseStatus='3') ").Tables[0];
- 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]["Prod_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = "0";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_ClassName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Class"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Prod_Number"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- if (dal.Rows.Count > 0)
- {
- if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "0")
- { cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString(); }
- else if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "1")
- { cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString(); }
- else if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "2")
- { cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString(); }
- else if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "3")
- { cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString(); }
- }
- else
- { cell.Value = "可申请"; }
- dgvr.Cells.Add(cell);
- this.Invoke(new UpdateControl(delegate()
- {
- this.dgv2.Rows.Add(dgvr);
- }));
- }
- }
- }
- });
- dgv2.ClearSelection();
- }
- }
- }
- }
- }
|