123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- 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.SetSmallForm
- {
- public partial class InventoryRequisitionUpdateSmallForm : LYFZ.Software.UI.InventoryManagement.SetSmallForm.InventoryRequisitionUpdateSmallForm
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpPurchaseProduct pptbll = new BLL.BLL_ErpPurchaseProduct();
- public InventoryRequisitionUpdateSmallForm()
- {
- this.Load += InventoryRequisitionUpdateSmallForm_Load;
- this.Shown += InventoryRequisitionUpdateSmallForm_Shown;
- this.btnDelete.Click += btnDelete_Click;
- this.btnPrint.Click += btnPrint_Click;
- this.btnSaveed.Click += btnSaveed_Click;
- this.btnClose.Click += btnClose_Click;
- this.listViewData.MouseDoubleClick += listViewData_MouseDoubleClick;
- this.txtText.Leave += txtText_Leave;
- this.txtText.KeyPress += txtText_KeyPress;
- }
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 订单号
- /// </summary>
- public string StrOrderNumber = "";
- /// <summary>
- /// 相片集合
- /// </summary>
- ImageList mlistImage = new ImageList();
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void InventoryRequisitionUpdateSmallForm_Load(object sender, EventArgs e)
- {
- this.listViewData.View = View.Details;
- this.listViewData.GridLines = true;
- string[] StrColumns = "商品名称,采购数量,采购状态".Split(',');
- for (int i = 0; i < StrColumns.Length; i++)
- {
- ColumnHeader ch = new ColumnHeader();
- ch.Text = StrColumns[i].Trim();
- if (i == 0)
- { ch.Width = (this.listViewData.Width - 23) - 200 * 2; }
- else
- { ch.Width = 200; }
- switch (StrColumns[i].Trim())
- {
- case "采购数量":
- case "采购状态":
- ch.TextAlign = HorizontalAlignment.Center;
- break;
- default:
- ch.TextAlign = HorizontalAlignment.Left;
- break;
- }
- this.listViewData.Columns.Add(ch);
- }
- this.mlistImage.ImageSize = new Size(30, 30);
- this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
- this.listViewData.SmallImageList = mlistImage;
- this.listViewData.ShowGroups = true;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void InventoryRequisitionUpdateSmallForm_Shown(object sender, EventArgs e)
- {
- this.txtProcurementOrderNumber.Text = this.StrOrderNumber;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
- {
- LYFZ.Model.Model_ErpPurchaseProduct model = pptbll.GetModel(Convert.ToInt32(this.listViewData.SelectedItems[0].Tag));
- if (model.Ppt_PurchaseStatus.Trim() != "3")
- { MessageBoxCustom.Show("商品‘" + this.listViewData.SelectedItems[0].Text.Trim() + "’已经" + Enum.GetName(typeof(LYFZ.EnumPublic.Ppt_PurchaseStatus), Convert.ToInt32(model.Ppt_PurchaseStatus)) + "不能删除!"); return; }
- if (MessageBoxCustom.Show("您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (pptbll.Delete(model))
- {
- MessageBoxCustom.Show("删除成功!");
- this.listViewData.Items.Remove(this.listViewData.SelectedItems[0]);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData);
- }
- else
- { MessageBoxCustom.Show("删除失败!"); }
- }
- }
- /// <summary>
- /// 打印
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnPrint_Click(object sender, EventArgs e)
- {
- if (this.listViewData.Items.Count <= 0)
- {
- MessageBoxCustom.Show("无打印数据!");
- return;
- }
- LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.库存采购申请单, this.StrOrderNumber);
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSaveed_Click(object sender, EventArgs e)
- {
- if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0)
- {
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- for (int i = 0; i < this.listViewData.Items.Count; i++)
- {
- if (this.listViewData.Items[i].SubItems["采购数量"].Tag != null)
- {
- LYFZ.Model.Model_ErpPurchaseProduct model = pptbll.GetModel(Convert.ToInt32(this.listViewData.Items[i].Tag));
- model.Ppt_PurchaseQuantity = Convert.ToInt32(this.listViewData.Items[i].SubItems["采购数量"].Text.Trim());
- clist.Add(pptbll.GetUpdateCommandInfo(model));
- }
- }
- if (clist.Count > 0)
- {
- if (MessageBoxCustom.Show("您确定要保存修改的数据吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- { MessageBoxCustom.Show("保存成功!"); }
- else
- { MessageBoxCustom.Show("保存失败!"); }
- }
- else
- { MessageBoxCustom.Show("没做任何修改无须保存"); }
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void listViewData_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- this.txtText.Visible = false;
- ListViewHitTestInfo info = this.listViewData.HitTest(e.X, e.Y);
- if (!string.IsNullOrEmpty(info.SubItem.Name.Trim()))
- {
- if (this.listViewData.SelectedItems[0].SubItems["采购状态"].Text.Trim() == "申请中")
- {
- Rectangle rect = info.SubItem.Bounds;
- switch (info.SubItem.Name.Trim())
- {
- case "采购数量":
- this.txtText.Location = new Point(rect.Location.X + this.listViewData.Location.X + 3, rect.Location.Y + this.listViewData.Location.Y + 2);
- this.txtText.Size = rect.Size;
- this.txtText.Visible = true;
- this.txtText.Tag = info.SubItem.Name.Trim();
- this.txtText.Text = info.SubItem.Text.Trim();
- this.txtText.Focus();
- break;
- }
- }
- }
- else
- {
- DataTable dt = orbll.GetView_Custom("tb_ErpProduct", StrWhere: "Prod_Number = '" + this.listViewData.SelectedItems[0].Tag.ToString().Trim() + "'", ShowColumnName: "Prod_Thumbnail").Tables[0];
- if (dt.Rows.Count > 0)
- {
- if (!string.IsNullOrEmpty(dt.Rows[0]["Prod_Thumbnail"].ToString().Trim()))
- {
- LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic frm = new InitialSet.Product.FrmProductPic();
- frm.FrmImage = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetImage(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.StringToByte(dt.Rows[0]["Prod_Thumbnail"].ToString()));
- frm.ShowDialog();
- }
- else
- { MessageBoxCustom.Show("产品未上传相片!"); return; }
- }
- }
- }
- /// <summary>
- /// 文本框离开事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtText_Leave(object sender, EventArgs e)
- {
- try
- {
- if (this.txtText.Tag != null)
- {
- string StrText = "0";
- switch (this.txtText.Tag.ToString().Trim())
- {
- case "采购数量":
- if (!string.IsNullOrEmpty(this.txtText.Text.Trim()))
- {
- if (LYFZ.Command.Command_Validate.IsNumberSign(this.txtText.Text.Trim()))
- { StrText = this.txtText.Text.Trim(); }
- }
- this.listViewData.SelectedItems[0].SubItems[this.txtText.Tag.ToString().Trim()].Text = StrText;
- this.listViewData.SelectedItems[0].SubItems[this.txtText.Tag.ToString().Trim()].Tag = "1";
- break;
- }
- }
- }
- catch
- { }
- this.txtText.Visible = false;
- }
- /// <summary>
- /// 文本框限制输入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtText_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 创建行
- /// </summary>
- void PublicFunctionRows()
- {
- string StrColumnName = "tb_ErpPurchaseProduct.ID,Prod_Class,Sc_ClassName,Prod_Number,Prod_Name,Ppt_PurchaseQuantity,Ppt_PurchaseStatus,Prod_Thumbnail";
- string StrTableName = "tb_ErpPurchaseProduct Left Join tb_ErpProduct on Prod_Number = Ppt_ProductNumber Left Join tb_ErpSystemCategory on Sc_ClassCode = Ppt_ProductCategory";
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "Ppt_PurchaseNumber = '" + this.StrOrderNumber + "'", ShowColumnName: StrColumnName).Tables[0];
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- {
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (!this.mlistImage.Images.Keys.Contains(dt.Rows[i]["Prod_Number"].ToString().Trim()))
- {
- Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage(dt.Rows[i]["Prod_Thumbnail"].ToString().Trim());
- this.mlistImage.Images.Add(dt.Rows[i]["Prod_Number"].ToString().Trim(), img);
- }
- ListViewItem lvItem = new ListViewItem();
- lvItem.Tag = dt.Rows[i]["ID"].ToString().Trim();
- lvItem.ImageKey = dt.Rows[i]["Prod_Number"].ToString().Trim();
- lvItem.Text = dt.Rows[i]["Prod_Name"].ToString().Trim();
- ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "采购数量";
- ListSubItem.Text = dt.Rows[i]["Ppt_PurchaseQuantity"].ToString().Trim();
- lvItem.SubItems.Add(ListSubItem);
- ListSubItem = new ListViewItem.ListViewSubItem();
- ListSubItem.Name = "采购状态";
- ListSubItem.Text = Enum.GetName(typeof(LYFZ.EnumPublic.Ppt_PurchaseStatus), Convert.ToInt32(dt.Rows[i]["Ppt_PurchaseStatus"]));
- lvItem.SubItems.Add(ListSubItem);
- if (this.listViewData.Groups[dt.Rows[i]["Prod_Class"].ToString().Trim()] == null)
- {
- ListViewGroup man_lvg = new ListViewGroup();
- man_lvg.Name = dt.Rows[i]["Prod_Class"].ToString().Trim();
- man_lvg.Header = dt.Rows[i]["Sc_ClassName"].ToString().Trim();
- man_lvg.HeaderAlignment = HorizontalAlignment.Left;
- this.listViewData.Groups.Add(man_lvg);
- }
- if (this.listViewData.Groups.Count > 0)
- { this.listViewData.Groups[dt.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
- this.listViewData.Items.Add(lvItem);
- }
- }));
- });
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData);
- }
- }
- }
|