/// <summary> /// 将CostumeStore转化为ReplenishDetail /// </summary> /// <param name="store"></param> /// <returns></returns> private ReplenishDetail CostumeStoreConvertToReplenishDetail(CostumeStore store, string replenishOrderID) { if (store == null) { return(null); } ReplenishDetail detail = new ReplenishDetail(); return(new ReplenishDetail() { ReplenishOrderID = replenishOrderID, CostumeID = store.CostumeID, CostumeName = GlobalCache.GetCostumeName(store.CostumeID), ColorName = store.ColorName, CostPrice = store.CostPrice, XS = store.XS, S = store.S, M = store.M, L = store.L, F = store.F, XL = store.XL, XL2 = store.XL2, XL3 = store.XL3, XL4 = store.XL4, XL5 = store.XL5, XL6 = store.XL6, Price = store.Price }); }
private void ReplenishDetailListAddItem(ReplenishDetail detail) { bool existed = false; DialogResult result = DialogResult.No; ReplenishDetail repeatItem = null; foreach (ReplenishDetail item in this.curReplenishDetailList) { if (item.CostumeID.ToUpper() == detail.CostumeID.ToUpper() && item.ColorName == detail.ColorName) { repeatItem = item; existed = true; result = GlobalMessageBox.Show(string.Format("款号:{0} 颜色:{1} 的服装已经存在待补货列表中,是否覆盖", item.CostumeID, item.ColorName), "", MessageBoxButtons.YesNo); break; } } if (!existed || result == DialogResult.Yes) { //不存在或者重复时直接覆盖 if (repeatItem != null) { this.curReplenishDetailList.Remove(repeatItem); } // this.curReplenishDetailList.Insert(0, detail); this.curReplenishDetailList.Add(detail); } }
private void BaseButton_Add_Click(object sender, EventArgs e) { try { if (this.curSelectedCostumeStoreList == null || this.curSelectedCostumeStoreList.Count == 0) { return; } List <CostumeStore> costumeStoreList = this.curSelectedCostumeStoreList.FindAll((x) => x.Title == "补货申请"); AddStoreCache(this.curSelectedCostumeStoreList.FindAll((x) => x.Title == "库存")); foreach (CostumeStore store in costumeStoreList) { if (store.SumCount == 0) { continue; } ReplenishDetail detail = this.CostumeStoreConvertToReplenishDetail(store, ""); this.ReplenishDetailListAddItem(detail); } //清空dataGirdView1的绑定源 this.SetCostumeDetails(null); this.BindingReplenishDetailSource(); this.CostumeCurrentShopTextBox1.Focus(); } catch (Exception ee) { GlobalUtil.ShowError(ee); } }
private void dataGridView2_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { //加载库存信息 ReplenishDetail detail = (ReplenishDetail)this.dataGridView2.CurrentRow.DataBoundItem; List <CostumeStore> stores = orderStoreCache.FindAll(t => t.CostumeID == detail.CostumeID && detail.ColorName == t.ColorName); this.curSelectedCostumeStoreList = stores; this.BindingSelectedCostumeStoreSource(detail); }
/// <summary> /// 添加ReplenishDetail到当前要绑定的 待补货的 集合源中。(过滤掉源集合中已存在同款同颜色的服装) /// </summary> /// <param name="detail"></param> private void CurReplenishDetailListAddItem(ReplenishDetail detail) { foreach (ReplenishDetail item in this.curReplenishDetailList) { if (item.CostumeID.ToUpper() == detail.CostumeID.ToUpper() && item.ColorName == detail.ColorName) { GlobalMessageBox.Show(string.Format("款号:{0} 颜色:{1} 的服装已经存在待补货列表中,重复添加", item.CostumeID, item.ColorName)); return; } } this.curReplenishDetailList.Add(detail); }
/// <summary> /// 绑定选定款号对应的CostumeStore集合 /// </summary> private void BindingSelectedCostumeStoreSource(ReplenishDetail detail) { if (this.curSelectedCostumeStoreList == null) { this.dataGridView1.DataSource = null; } else { this.dataGridView1.DataSource = null; if (this.curSelectedCostumeStoreList != null && this.curSelectedCostumeStoreList.Count > 0) { List <CostumeStore> tempList = new List <CostumeStore>(); foreach (CostumeStore store in this.curSelectedCostumeStoreList) { store.Title = "库存"; store.CostumeName = GlobalCache.GetCostumeName(store.CostumeID); CostumeStore tempStore = this.BuildCostumeStore4NeedReplenish(store, detail); //CJBasic.Helpers.ReflectionHelper.CopyProperty(store, obj); tempList.Add(store); tempList.Add(tempStore); } this.curSelectedCostumeStoreList = tempList; ////重新排序,同款同颜色排一起,且将补货数量拍在库存后面 //this.curSelectedCostumeStoreList.Sort((x, y) => //{ // int sort = x.ColorName.CompareTo(y.ColorName); // if (sort == 0) // { // sort = -x.Title.CompareTo(y.Title); // } // return sort; //}); this.dataGridView1.DataSource = this.curSelectedCostumeStoreList; } } foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Index % 2 == 0) { row.ReadOnly = true; row.HeaderCell.Value = "库存"; } else { row.ReadOnly = false; row.HeaderCell.Value = "补货申请"; } } this.dataGridView1.Refresh(); dataGridViewPagingSumCtrl1.AutoFocusToWritableCell(); }
public override void HighlightCostume() { if (this.dataGridView1.DataSource != null) { if (!String.IsNullOrEmpty(BaseModifyCostumeID)) { foreach (DataGridViewRow row in dataGridView1.Rows) { ReplenishDetail detail = row.DataBoundItem as ReplenishDetail; HighlightCostume(row, detail?.CostumeID); } } } }
private DataGridView deepCopyDataGridView() { DataGridView dgvTmp = new DataGridView(); dgvTmp.Name = "dgvTmp"; this.Controls.Add(dgvTmp); dgvTmp.AutoGenerateColumns = false; // dgvTmp.AllowUserToAddRows = false; //不允许用户生成行,否则导出后会多出最后一行 for (int i = 0; i < dataGridView1.Columns.Count; i++) { dgvTmp.Columns.Add(dataGridView1.Columns[i].Name, dataGridView1.Columns[i].HeaderText); if (dataGridView1.Columns[i].DefaultCellStyle.Format.Contains("N")) //使导出Excel文档金额列可做SUM运算 { dgvTmp.Columns[i].DefaultCellStyle.Format = dataGridView1.Columns[i].DefaultCellStyle.Format; } if (!dataGridView1.Columns[i].Visible) { dgvTmp.Columns[i].Visible = false; } dgvTmp.Columns[i].DataPropertyName = dataGridView1.Columns[i].DataPropertyName; dgvTmp.Columns[i].HeaderText = dataGridView1.Columns[i].HeaderText; dgvTmp.Columns[i].Tag = dataGridView1.Columns[i].Tag; dgvTmp.Columns[i].Name = dataGridView1.Columns[i].Name; } List <ReplenishDetail> listtb1 = (List <ReplenishDetail>)(dataGridView1.DataSource); List <ReplenishDetail> tb2 = new List <ReplenishDetail>(); foreach (ReplenishDetail idetail in listtb1) { ReplenishDetail tDetail = new ReplenishDetail(); ReflectionHelper.CopyProperty(idetail, tDetail); tb2.Add(tDetail); } dgvTmp.DataSource = tb2; return(dgvTmp); }
private BoundDetail ReplenishDetailConvertToOutboundDetail(ReplenishDetail from, string id) { return(new BoundDetail() { CostumeID = from.CostumeID, ColorName = from.ColorName, BoundOrderID = id, Price = from.Price, CostPrice = from.CostPrice, S = from.S, M = from.M, XS = from.XS, L = from.L, F = from.F, XL = from.XL, XL2 = from.XL2, XL3 = from.XL3, XL4 = from.XL4, XL5 = from.XL5, XL6 = from.XL6 }); }
/// <summary> /// 根据现在库存对象生成需补货的库存对象 /// </summary> /// <param name="oldCostumeStore"></param> /// <returns></returns> private CostumeStore BuildCostumeStore4NeedReplenish(CostumeStore oldCostumeStore, ReplenishDetail detail) { CostumeStore store = null; if (oldCostumeStore != null) { store = new CostumeStore() { CostumeID = oldCostumeStore.CostumeID, CostumeName = oldCostumeStore.CostumeName, ColorName = oldCostumeStore.ColorName, AllowReviseDiscount = oldCostumeStore.AllowReviseDiscount, ShopID = oldCostumeStore.ShopID, Price = oldCostumeStore.Price, CostPrice = oldCostumeStore.CostPrice, Title = "补货申请", F = 0, L = 0, XS = 0, M = 0, S = 0, XL = 0, XL2 = 0, XL3 = 0, XL4 = 0, XL5 = 0, XL6 = 0 }; if (detail != null) { store.F = detail.F; store.L = detail.L; store.XS = detail.XS; store.M = detail.M; store.S = detail.S; store.XL = detail.XL; store.XL2 = detail.XL2; store.XL3 = detail.XL3; store.XL4 = detail.XL4; store.XL5 = detail.XL5; store.XL6 = detail.XL6; } } return(store); }