private void btnAdd_Click(object sender, EventArgs e) { switch (flag) { case 1: pDetail.Controls.Clear(); UCPrinter ucPrinter = new UCPrinter(); ucPrinter.Dock = DockStyle.Fill; ucPrinter.btnRemove.Hide(); ucPrinter.btnSave.Click += btnSaveInforPrinter_Click; ucPrinter.ResetPrinterList = new ResetPrinterList(this.ResetPriter); pDetail.Controls.Add(ucPrinter); break; case 2: pDetail.Controls.Clear(); UCPrinterJobDetail ucJob = new UCPrinterJobDetail(); ucJob.Dock = DockStyle.Fill; pDetail.Controls.Add(ucJob); ucJob.LoadPriterMapp(); ucJob.btnSave.Click += btnSaveInforPrinterJob_Click; ucJob.btnRemove.Hide(); break; } }
void ucPListJob_Click(object sender, EventArgs e) { UCPrinterList ucPList = (UCPrinterList)sender; PrintJobModel item = (PrintJobModel)ucPList.Tag; foreach (Control ctr in flpPrintList.Controls) { if (ctr.BackColor == Color.FromArgb(0, 153, 51)) { ctr.BackColor = Color.FromArgb(255, 255, 255); ctr.ForeColor = Color.FromArgb(51, 51, 51); } } ucPList.BackColor = Color.FromArgb(0, 153, 51); ucPList.ForeColor = Color.FromArgb(255, 255, 255); if (pDetail.Controls.Count > 0) { if (pDetail.Controls[0] is UCPrinterJobDetail) { UCPrinterJobDetail ucJob = (UCPrinterJobDetail)pDetail.Controls[0]; ucJob.btnRemove.Show(); ucJob.lblTittel.Text = item.PrintJobName; ucJob.txtPrintJobName.Text = item.PrintJobName; ucJob.cbPrintContent.Text = item.PrintContent; ucJob.LoadPriterMappByPrinteJobID(item.ID); ucJob.btnSave.Tag = item; ucJob.btnSave.Click += btnSaveInforPrinterJob_Click; ucJob.btnRemove.Tag = item; ucJob.btnRemove.Click += btnRemovePrinterJob_Click; } } else { pDetail.Controls.Clear(); UCPrinterJobDetail ucJob = new UCPrinterJobDetail(); ucJob.Dock = DockStyle.Fill; ucJob.lblTittel.Text = item.PrintJobName; ucJob.txtPrintJobName.Text = item.PrintJobName; ucJob.btnRemove.Show(); ucJob.btnSave.Tag = item; ucJob.btnSave.Click += btnSaveInforPrinterJob_Click; ucJob.btnRemove.Tag = item; ucJob.btnRemove.Click += btnRemovePrinterJob_Click; pDetail.Controls.Add(ucJob); var test = (UCPrinterJobDetail)pDetail.Controls[0]; test.cbPrintContent.Text = item.PrintContent; ucJob.LoadPriterMappByPrinteJobID(item.ID); } }