123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- 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 FrmInventory : LYFZ.Software.UI.InventoryManagement.FrmInventory
- {
- private delegate void UpdateControl();
- public string ID;
- bool bl = false;
- public FrmInventory()
- {
- this.FormClosed += FrmInventory_FormClosed;
- }
- void FrmInventory_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (bl)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- #region 加载
- protected override void FrmInventory_Shown(object sender, EventArgs e)
- {
- try
- {
- if (!string.IsNullOrEmpty(ID))
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- string[] Id = ID.Split(',');
- for (int i = 0; i < Id.Length; i++)
- {
- #region 获取商品
- LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
- DataTable dt = Productbll.GetList("Id='" + Id[i] + "'").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]["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);
- this.dgv1.Rows.Add(dgvr);
- dgv1.ClearSelection();
- }
- }));
- }
- #endregion
- }
- });
- }
- lblcount.Text = dgv1.Rows.Count.ToString();
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 保存
- protected override void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- #region 修改商品库存
- if (dgv1.Rows.Count > 0)
- {
- for (int i = 0; i < dgv1.Rows.Count; i++)
- {
- int Id = Convert.ToInt32(dgv1.Rows[i].Cells["ID"].Value);
- int Prod_Quantity = Convert.ToInt32(dgv1.Rows[i].Cells["Prod_Quantity"].Value);
- LYFZ.BLL.BLL_ErpProduct ProductBll = new BLL.BLL_ErpProduct();
- LYFZ.Model.Model_ErpProduct ProductModel = ProductBll.GetModel(Id);
- ProductModel.Prod_Quantity = Prod_Quantity;
- ProductModel.Prod_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- ProductModel.Prod_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- ProductBll.Update(ProductModel);
- }
- bl = true;
- MessageBoxCustom.Show("保存成功!");
- }
- #endregion
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 只能输入数字
- protected override void dgv1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (dgv1.Rows.Count > 0)
- {
- if (dgv1.CurrentRow.Cells["Prod_Quantity"].Value == null)
- {
- MessageBoxCustom.Show("库存数量不能为空!");
- int id = Convert.ToInt32(dgv1.CurrentRow.Cells["ID"].Value);
- LYFZ.BLL.BLL_ErpProduct bll = new BLL.BLL_ErpProduct();
- dgv1.CurrentRow.Cells["Prod_Quantity"].Value = bll.GetList("ID=" + id + "").Tables[0].Rows[0]["Prod_Quantity"].ToString();
- return;
- }
- if (Command.Command_Validate.IsNumber(dgv1.CurrentRow.Cells["Prod_Quantity"].Value.ToString()) == false)
- {
- MessageBoxCustom.Show("只能输入纯数字!");
- int id = Convert.ToInt32(dgv1.CurrentRow.Cells["ID"].Value);
- LYFZ.BLL.BLL_ErpProduct bll = new BLL.BLL_ErpProduct();
- dgv1.CurrentRow.Cells["Prod_Quantity"].Value = bll.GetList("ID=" + id + "").Tables[0].Rows[0]["Prod_Quantity"].ToString();
- return;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 关闭
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- }
- }
|