private void dgvStockList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { frmSelectStock selectStock = new frmSelectStock(); //创建frmSelectStock窗体对象 selectStock.buyStock = this; //将新创建的窗体对象设置为同一个窗体类的对象 selectStock.M_int_CurrentRow = e.RowIndex; //记录选中的行索引 selectStock.M_str_object = "BuyStock"; //用于识别是那一个窗体调用的selectStock窗口 selectStock.ShowDialog(); //显示frmSelectStock窗体 }
private void dgvStockList_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { frmSelectStock selectStock = new frmSelectStock(); selectStock.resellStock = this; //将新创建的窗体对象设置为同一个窗体类的实例(对象) selectStock.M_int_CurrentRow = e.RowIndex; selectStock.M_str_object = "ResellStock"; //用于识别 是那一个窗体调用的SelectStock窗口的 selectStock.ShowDialog(); }
private void ImportByStock(bool isMutiSelect) { frmSelectStock frmSelectStock = new frmSelectStock(isMutiSelect); Guid? itemCode = Guid.Empty; string model = string.Empty; if (!isMutiSelect) //单选时 { model = dgvSalesOrderLine.CurrentRow.Cells["colModel"].Value.ToStringHasNull(); itemCode = dgvSalesOrderLine.CurrentRow.Cells["colItemCode"].Value.ToGuid(); } if (!string.IsNullOrEmpty(model)) { frmSelectStock.Model = model; } if (itemCode != Guid.Empty) //如果已经存在关联的库存guid,则只筛选此条明细 { frmSelectStock.ItemCode = itemCode; } else //如果是新行,则排除掉已经存在列表里面的所有的库存guid { Guid?[] noItemCodes = addOrModifyList.Where(a => a.ItemCode.ToGuid() != Guid.Empty).Select(a => a.ItemCode).Distinct().ToArray(); frmSelectStock.NoItemCodes = noItemCodes; } frmSelectStock.BringToFront(); frmSelectStock.StartPosition = FormStartPosition.CenterScreen; DialogResult rst = frmSelectStock.ShowDialog(); if (rst == DialogResult.OK) { List <STK_StockResult> rstList = frmSelectStock.GetSelectList <STK_StockResult>(); if (rstList != null && rstList.Count > 0) { foreach (STK_StockResult stockResult in rstList) { bool isAddNew = true; foreach (DataGridViewRow row in dgvSalesOrderLine.Rows) { //如果是已经存在的行,则利用现成的行进行编辑 if (row.Cells["colItemCode"].Value.ToGuid() == stockResult.ItemCode) { isAddNew = false; ORD_SalesOrderLineResult orderLineResult = bsOrderLine[row.Index] as ORD_SalesOrderLineResult; SetOrderLineObjectValue(orderLineResult, stockResult); break; } } if (isAddNew) { if (!isMutiSelect) //单选 { ORD_SalesOrderLineResult orderLineResult = bsOrderLine.Current as ORD_SalesOrderLineResult; SetOrderLineObjectValue(orderLineResult, stockResult); } else //多选 { ORD_SalesOrderLineResult orderLineResult = new ORD_SalesOrderLineResult(); SetOrderLineObjectValue(orderLineResult, stockResult); bsOrderLine.Add(orderLineResult); } } } } } }