private void btn_Add_Click(object sender, EventArgs e) { //Invoices.ChooseProductForm f = new Invoices.ChooseProductForm(); //if (f.ShowDialog(this) == DialogResult.OK) //{ // if (Invoices.ChooseProductForm.ProductList != null && Invoices.ChooseProductForm.ProductList.Count > 0) // { // foreach (Model.Product product in Invoices.ChooseProductForm.ProductList) // { // Model.PCSamplingEarDetail detail = new Book.Model.PCSamplingEarDetail(); // detail.PCSamplingEarDetailId = Guid.NewGuid().ToString(); // detail.PCSamplingEarId = this._PCSamplingEar.PCSamplingEarId; // detail.PCSamplingEarDetailDate = DateTime.Now; // detail.Product = product; // detail.ProductId = product.ProductId; // this._PCSamplingEar.Details.Add(detail); // this.bindingSourceDetail.Position = this.bindingSourceDetail.IndexOf(detail); // } // } // else if (Invoices.ChooseProductForm.ProductList == null || Invoices.ChooseProductForm.ProductList.Count == 0) // { // Model.PCSamplingEarDetail detail = new Book.Model.PCSamplingEarDetail(); // detail.PCSamplingEarDetailId = Guid.NewGuid().ToString(); // detail.PCSamplingEarId = this._PCSamplingEar.PCSamplingEarId; // detail.PCSamplingEarDetailDate = DateTime.Now; // detail.Product = f.SelectedItem as Model.Product; // detail.ProductId = (f.SelectedItem as Model.Product).ProductId; // this._PCSamplingEar.Details.Add(detail); // this.bindingSourceDetail.Position = this.bindingSourceDetail.IndexOf(detail); // } //} if (this._PCSamplingEar.Details == null || this._PCSamplingEar.Details.Count == 0) { MessageBox.Show("请先从加工单拉取第一条测试内容。", this.Text, MessageBoxButtons.OK); return; } else { Model.PCSamplingEarDetail detail = new Book.Model.PCSamplingEarDetail(); detail.PCSamplingEarDetailId = Guid.NewGuid().ToString(); detail.PCSamplingEarId = this._PCSamplingEar.PCSamplingEarId; detail.PCSamplingEarDetailDate = DateTime.Now; detail.Product = this._PCSamplingEar.Details[0].Product; detail.ProductId = this._PCSamplingEar.Details[0].ProductId; this._PCSamplingEar.Details.Add(detail); this.bindingSourceDetail.Position = this.bindingSourceDetail.IndexOf(detail); } this.gridControl1.RefreshDataSource(); }
private void barPronoteHeader_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Book.UI.produceManager.PronoteHeader.ChoosePronoteHeaderDetailsForm pronoForm = new Book.UI.produceManager.PronoteHeader.ChoosePronoteHeaderDetailsForm(null, 0); if (pronoForm.ShowDialog(this) == DialogResult.OK) { Model.PronoteHeader currentModel = pronoForm.SelectItem; if (currentModel != null) { this.txt_PronoteHeaderId.Text = currentModel.PronoteHeaderID; //this.nccCustomer.EditValue = currentModel.InvoiceXO.Customer; Model.InvoiceXO xo = new BL.InvoiceXOManager().Get(currentModel.InvoiceXOId); if (xo != null) { this.nccCustomer.EditValue = xo.Customer; this.txt_InvoiceCusId.Text = xo.CustomerInvoiceXOId; } //this.txt_Model.Text = (currentModel.Product) == null ? "" : (currentModel.Product).CustomerProductName; Model.Product p = new BL.ProductManager().Get(currentModel.ProductId); if (p != null) { this.txt_Model.Text = p.CustomerProductName; } Model.PCSamplingEarDetail detail = new Book.Model.PCSamplingEarDetail(); detail.PCSamplingEarDetailId = Guid.NewGuid().ToString(); detail.PCSamplingEarDetailDate = DateTime.Now; detail.PCSamplingEarId = this._PCSamplingEar.PCSamplingEarId; detail.Product = p; detail.ProductId = currentModel.ProductId; this._PCSamplingEar.Details.Add(detail); this.bindingSourceDetail.Position = this.bindingSourceDetail.IndexOf(detail); this.gridControl1.RefreshDataSource(); } } pronoForm.Dispose(); GC.Collect(); }