private void buttonAll_Click(object sender, EventArgs e) { WMSEntities wmsEntities = new WMSEntities(); StandardFormPreviewExcel standardFormPreviewExcel = new StandardFormPreviewExcel("送检单预览"); SubmissionTicket[] submissionTicket = idsToSubmissionTickets(this.ids); try { foreach (SubmissionTicket st in submissionTicket) { string worksheetName = st.ID.ToString(); SubmissionTicketView submissionTicketView = (from stv in wmsEntities.SubmissionTicketView where stv.ID == st.ID select stv).FirstOrDefault(); SubmissionTicketItemView[] submissionTicketItemView = (from p in wmsEntities.SubmissionTicketItemView where p.SubmissionTicketID == st.ID select p).ToArray(); ReceiptTicketView receiptTicketView = (from rt in wmsEntities.ReceiptTicketView where rt.ID == st.ReceiptTicketID select rt).FirstOrDefault(); if (standardFormPreviewExcel.AddPatternTable(@"Excel\SubmissionTicket.xlsx", worksheetName) == false) { this.Close(); return; } if (st != null) { standardFormPreviewExcel.AddData("SubmissionTicket", submissionTicketView, worksheetName); } if (receiptTicketView != null) { standardFormPreviewExcel.AddData("ReceiptTicket", receiptTicketView, worksheetName); } standardFormPreviewExcel.AddData("SubmissionTicketItem", submissionTicketItemView, worksheetName); standardFormPreviewExcel.SetPrintScale(0.82f, worksheetName); } standardFormPreviewExcel.Show(); this.Close(); } catch { MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error); return; } //StartPreview(submissionTicketItemView); }
private void ReceiptTicketModify_Load(object sender, EventArgs e) { /* * this.tableLayoutPanelTextBoxes.Controls.Clear(); * for (int i = 0; i < ReceiptMetaData.receiptNameKeys.Length; i++) * { * KeyName curKeyName = ReceiptMetaData.receiptNameKeys[i]; * if (curKeyName.Editable == false && curKeyName.Visible == false && curKeyName.Save == true) * { * continue; * } * Label label = new Label(); * label.AutoSize = true; * label.Text = curKeyName.Name; * this.tableLayoutPanelTextBoxes.Controls.Add(label); * * TextBox textBox = new TextBox(); * textBox.Name = "textBox" + curKeyName.Key; * if(curKeyName.Editable == false) * { * textBox.Enabled = false; * } * * this.tableLayoutPanelTextBoxes.Controls.Add(textBox); * * }*/ Utilities.CreateEditPanel(this.tableLayoutPanelTextBoxes, ReceiptMetaData.receiptNameKeys); this.personIDGetter = Utilities.BindTextBoxSelect <FormSelectPerson, Person>(this, "textBoxPersonName", "Name"); if (this.formMode == FormMode.ALTER) { this.buttonOK.Text = "修改收货单"; this.Text = "修改收货单"; this.GroupBox.Text = "修改收货单"; ReceiptTicketView receiptTicketView = (from s in this.wmsEntities.ReceiptTicketView where s.ID == this.ID select s).Single(); Utilities.CopyPropertiesToTextBoxes(receiptTicketView, this); Utilities.CopyPropertiesToComboBoxes(receiptTicketView, this); if (receiptTicketView.SupplierID != null) { this.supplierID = (int)receiptTicketView.SupplierID; } else { MessageBox.Show("请重新选择供应商"); } if (receiptTicketView.HasPutawayTicket == "全部生成上架单" || receiptTicketView.HasPutawayTicket == "部分生成上架单" || receiptTicketView.State == "送检中") { this.Controls.Find("textBoxState", true)[0].Enabled = false; } if (user != null) { if (user.SupplierID != null) { //ComboBox comboxstate = (ComboBox)this.Controls.Find("comboBoxState", true)[0]; this.Controls.Find("textBoxState", true)[0].Enabled = false; //comboxstate.Enabled = false; } } ReceiptTicket receiptTicket = (from rt in wmsEntities.ReceiptTicket where rt.ID == receiptTicketView.ID select rt).FirstOrDefault(); if (receiptTicket != null) { if (receiptTicket.ReceiptTicketItem.ToArray().Length != 0) { this.Controls.Find("textBoxSupplierName", true)[0].Enabled = false; this.Controls.Find("textBoxSupplierNumber", true)[0].Enabled = false; } } //this.Controls.Find("comboBoxState", true)[0].Enabled = false; //TextBox textBoxLastUpdateUserID = (TextBox)this.Controls.Find("textBoxLastUpdateUserUserID", true)[0]; //textBoxLastUpdateUserID.Text = this.userID.ToString(); } else { this.buttonOK.Text = "添加收货单"; Warehouse warehouse = (from wh in wmsEntities.Warehouse where wh.ID == this.warehouseID select wh).FirstOrDefault(); if (warehouse == null) { Console.Write("this warehouse is null"); } else { TextBox textBoxWarehouseName = (TextBox)this.Controls.Find("textBoxWarehouseName", true)[0]; textBoxWarehouseName.Text = warehouse.Name; textBoxWarehouseName.Enabled = false; } Project project = (from p in wmsEntities.Project where p.ID == this.projectID select p).FirstOrDefault(); if (project == null) { Console.Write("this project is null"); } else { TextBox textBoxProjectName = (TextBox)this.Controls.Find("textBoxProjectName", true)[0]; textBoxProjectName.Text = project.Name; textBoxProjectName.Enabled = false; /* * TextBox textBoxWarehouseName = (TextBox)this.Controls.Find("textBoxWarehouseName", true)[0]; * textBoxWarehouseName.Text = warehouse.Name; * textBoxWarehouseName.Enabled = false;*/ } ComboBox comboBoxHasSubmission = (ComboBox)this.Controls.Find("comboBoxHasSubmission", true)[0]; comboBoxHasSubmission.Text = "否"; this.Controls.Find("textBoxReceiptDate", true)[0].Text = DateTime.Now.ToString(); comboBoxHasSubmission.Enabled = false; this.Controls.Find("textBoxState", true)[0].Text = "待收货"; if (this.user != null) { if (this.user.Supplier == null) { this.Controls.Find("textBoxSupplierName", true)[0].Click += textBoxSupplierID_Click; } else { this.Controls.Find("textBoxSupplierName", true)[0].Text = this.user.Supplier.Name; this.Controls.Find("textBoxSupplierName", true)[0].Enabled = false; this.supplierID = (int)this.user.SupplierID; } } //this.Controls.Find("textBoxState", true)[0].Enabled = false; //TextBox textBoxProjectID = (TextBox)this.Controls.Find("textBoxProjectID", true)[0]; //textBoxProjectID.Text = this.projectID.ToString(); //textBoxProjectID.Enabled = false; //TextBox textBoxCreateUserID = (TextBox)this.Controls.Find("textBoxCreateUserID", true)[0]; //textBoxCreateUserID.Text = this.userID.ToString(); //TextBox textBoxWarehouse = (TextBox)this.Controls.Find("textBoxWarehouse", true)[0]; //textBoxWarehouse.Text = this.warehouseID.ToString(); //TextBox textBoxID = (TextBox)this.Controls.Find("textBoxID", true)[0]; //textBoxID.Text = "0"; //textBoxCreateUserID.Enabled = false; } //else (this.formMode == FormMode.ADD); //this.Controls.Find("textBoxID", true)[0].TextChanged += textBoxID_TextChanged; //this.Controls.Find("textBoxProjectID", true)[0].TextChanged += textBoxProjectID_TextChanged; //this.Controls.Find("textBoxWarehouse", true)[0].TextChanged += textBoxWarehouseID_TextChanged; //this.Controls.Find("textBoxSupplierID", true)[0].TextChanged += textBoxSupplierID_TextChanged; }