private void updateData() { if (textBox1.Text != "") { Employee e = (from x in cheese.Employees where x.EmployeeID.Equals(textBox1.Text) select x).First(); if (e != null) { e.EmployeeName = textBox2.Text; if (radioButton1.Checked) { e.EmployeeGender = "Male"; } else if (radioButton2.Checked) { e.EmployeeGender = "Female"; } e.Division = comboBox2.SelectedValue.ToString(); e.Salary = (Int32)numericUpDown1.Value; e.DateOfBirth = dateTimePicker1.Value; e.EmployeeEmail = textBox7.Text; e.PhoneNumber = textBox8.Text; e.EmployeeStatus = comboBox1.SelectedValue.ToString(); DetailEmployee dE = new DetailEmployee(); dE.EmployeeID = textBox1.Text; dE.LastUpdatedBy = _MainForm.userID; dE.LastUpdateDate = DateTime.Now; cheese.DetailEmployees.Add(dE); cheese.SaveChanges(); refreshData(); clear(); EnabledStatus(false); ButtonStatus(true); label9.Visible = true; comboBox1.Visible = true; label10.Visible = false; flag = 0; } } }
private void insertData() { if (textBox2.Text == "") { label10.Visible = true; label10.Text = "Name Must Be Filled"; } else if (radioButton1.Checked == false && radioButton2.Checked == false) { label10.Visible = true; label10.Text = "Gender Must be Choose"; } else if (comboBox2.SelectedIndex < 1) { label10.Visible = true; label10.Text = "Choose Division"; } else if (numericUpDown1.Value < 1) { label10.Visible = true; label10.Text = "Please Input new Salary"; } else if (textBox7.Text == "") { label10.Visible = true; label10.Text = "Email Can Not Be Empty"; } else if (textBox8.Text == "") { label10.Visible = true; label10.Text = "Phone Number Cant be Empty"; } else { //FontEncoder font = new FontEncoder(); Employee e = new Employee(); DetailEmployee dE = new DetailEmployee(); e.EmployeeID = textBox1.Text; //String code = font.Code128(textBox1.Text, 0, false); //e.QRCode = code; e.EmployeeName = textBox2.Text; if (radioButton1.Checked) { e.EmployeeGender = "Male"; } else if (radioButton2.Checked) { e.EmployeeGender = "Female"; } e.Division = comboBox2.SelectedValue.ToString(); e.Salary = (Int32)numericUpDown1.Value; e.DateOfBirth = dateTimePicker1.Value; e.EmployeeEmail = textBox7.Text; e.PhoneNumber = textBox8.Text; e.RegisteredBy = _MainForm.userID; e.JoinDate = DateTime.Now; e.EmployeeStatus = "Active"; dE.EmployeeID = textBox1.Text; dE.LastUpdatedBy = _MainForm.userID; dE.LastUpdateDate = DateTime.Now; cheese.Employees.Add(e); cheese.DetailEmployees.Add(dE); cheese.SaveChanges(); refreshData(); _BarcodeForm barcodenew = new _BarcodeForm(textBox1.Text, comboBox2.SelectedValue.ToString()); barcodenew.Visible = true; clear(); EnabledStatus(false); ButtonStatus(true); label9.Visible = true; comboBox1.Visible = true; label10.Visible = false; flag = 0; } }