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; } /// /// 是否保存 /// public bool IsSaveed = false; /// /// 订单号 /// public string StrOrderNumber = ""; /// /// 相片集合 /// ImageList mlistImage = new ImageList(); /// /// 窗体加载事件 /// /// /// 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; } /// /// 窗体加载事件 /// /// /// void InventoryRequisitionUpdateSmallForm_Shown(object sender, EventArgs e) { this.txtProcurementOrderNumber.Text = this.StrOrderNumber; this.PublicFunctionRows(); } /// /// 删除 /// /// /// 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("删除失败!"); } } } /// /// 打印 /// /// /// 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); } /// /// 保存 /// /// /// void btnSaveed_Click(object sender, EventArgs e) { if (this.listViewData.Items.Count > 0 && this.listViewData.SelectedItems.Count > 0) { List clist = new List(); 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("没做任何修改无须保存"); } } } /// /// 关闭 /// /// /// void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 列表双击事件 /// /// /// 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; } } } } /// /// 文本框离开事件 /// /// /// 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; } /// /// 文本框限制输入 /// /// /// void txtText_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } } /// /// 创建行 /// 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); } } }