private void FrmDeptCode_Load(object sender, EventArgs e) { OnLoadSystemCommonData onLoad = new OnLoadSystemCommonData(); onLoad.GetTADeptCode(); onLoad.GetTADeptCodeDetail(); dgvDeptCode.DataSource = CommonData.TaDeptCodeList; dgvDeptCode.Columns[0].Visible = false; dgvDeptCode.Columns[1].HeaderCell.Value = "Code"; dgvDeptCode.Columns[2].HeaderCell.Value = "Dept Name"; dgvDeptCode.Columns[3].HeaderCell.Value = "Other Name"; if (CommonData.TaDeptCodeDetailList != null && dgvDeptCode.CurrentRow != null) { if (dgvDeptCode.CurrentRow.Index > 0) { txtDeptCode.Text = dgvDeptCode.CurrentRow.Cells[1].Value.ToString(); txtDeptName.Text = dgvDeptCode.CurrentRow.Cells[2].Value.ToString(); txtOtherName.Text = dgvDeptCode.CurrentRow.Cells[3].Value.ToString(); var deptCode = CommonData.TaDeptCodeDetailList.FirstOrDefault( s => s.DeptCodeSysKey.Equals(dgvDeptCode.CurrentRow.Cells[0].Value.ToString())); if (deptCode != null) { cmbBoxPrinterName1.Items.Clear(); GetPrinter1(); cmbBoxNumberOfCopy1.Items.Clear(); cmbBoxNumberOfCopy1.Items.Add("1"); cmbBoxNumberOfCopy1.Items.Add("2"); cmbBoxNumberOfCopy1.SelectedIndex = cmbBoxNumberOfCopy1.Items.IndexOf(deptCode.NumCopy1.Equals("1") ? "1" : "2"); chkPrtDishSeper1.Checked = deptCode.PrtDishSeper1.Equals("Y"); cmbBoxPrinterName2.Items.Clear(); GetPrinter2(); cmbBoxNumberOfCopy2.Items.Clear(); cmbBoxNumberOfCopy2.Items.Add("1"); cmbBoxNumberOfCopy2.Items.Add("2"); cmbBoxNumberOfCopy2.SelectedIndex = cmbBoxNumberOfCopy2.Items.IndexOf(deptCode.NumCopy2.Equals("1") ? "1" : "2"); chkPrtDishSeper2.Checked = deptCode.PrtDishSeper2.Equals("Y"); } } } else { cmbBoxPrinterName1.Items.Clear(); GetPrinter1(); cmbBoxNumberOfCopy1.Items.Clear(); cmbBoxNumberOfCopy1.Items.Add("1"); cmbBoxNumberOfCopy1.Items.Add("2"); cmbBoxPrinterName2.Items.Clear(); GetPrinter2(); cmbBoxNumberOfCopy2.Items.Clear(); cmbBoxNumberOfCopy2.Items.Add("1"); cmbBoxNumberOfCopy2.Items.Add("2"); } }
private void dgvDeptCode_SelectionChanged(object sender, EventArgs e) { if (dgvDeptCode.RowCount == 0) { MessageBox.Show("This table is empty,please add data first!"); return; } if (dgvDeptCode.CurrentRow == null) { return; } if (dgvDeptCode.CurrentRow.Index < 0) { return; } txtDeptCode.Text = dgvDeptCode.CurrentRow.Cells[1].Value.ToString(); txtDeptName.Text = dgvDeptCode.CurrentRow.Cells[2].Value.ToString(); txtOtherName.Text = dgvDeptCode.CurrentRow.Cells[3].Value.ToString(); OnLoadSystemCommonData onLoad = new OnLoadSystemCommonData(); onLoad.GetTADeptCodeDetail(); var deptCode = CommonData.TaDeptCodeDetailList.FirstOrDefault(s => s.DeptCodeSysKey.Equals(dgvDeptCode.CurrentRow.Cells[0].Value.ToString())); if (deptCode != null) { cmbBoxPrinterName1.Items.Clear(); GetPrinter1(); //cmbBoxPrinterName1.SelectedItem = deptCode.PrintName1; cmbBoxNumberOfCopy1.Items.Clear(); cmbBoxNumberOfCopy1.Items.Add("1"); cmbBoxNumberOfCopy1.Items.Add("2"); cmbBoxNumberOfCopy1.SelectedIndex = cmbBoxNumberOfCopy1.Items.IndexOf(deptCode.NumCopy1.Equals("1") ? "1" : "2"); chkPrtDishSeper1.Checked = deptCode.PrtDishSeper1.Equals("Y"); cmbBoxPrinterName2.Items.Clear(); GetPrinter2(); //cmbBoxPrinterName2.SelectedItem = deptCode.PrintName2; cmbBoxNumberOfCopy2.Items.Clear(); cmbBoxNumberOfCopy2.Items.Add("1"); cmbBoxNumberOfCopy2.Items.Add("2"); cmbBoxNumberOfCopy2.SelectedIndex = cmbBoxNumberOfCopy2.Items.IndexOf(deptCode.NumCopy2.Equals("1") ? "1" : "2"); chkPrtDishSeper2.Checked = deptCode.PrtDishSeper2.Equals("Y"); } }