private void txtdepartmentcode_LostFocus(object sender, RoutedEventArgs e) { string a = "Update", b = Convert.ToString(Save.Content); try { if (b == a) { DEPARTMENTS DE = new DEPARTMENTS(); DE.DEPARTMENT_CODE = txtdepartmentcode.Text; DE.UPDATE_BY = login.u; DE.UPDATE_DATE = DateTime.Today; DE.UPDATE(); txtdepartmentname.Text = DE.DEPARTMENT_NAME; txtreportname.Text = DE.REPORT_NAME; ComboBox1.Text = DE.STATUS; } } catch (Exception) { MessageBox.Show("Eneter departmentcode correctly"); } }
private void Save_Click(object sender, RoutedEventArgs e) { DEPARTMENTS DE = new DEPARTMENTS(); try { if (error != 0 || txtdepartmentcode.Text == "" || txtdepartmentname.Text == "" || txtreportname.Text == "") { // pop1.IsOpen = true; if (txtdepartmentcode.Text == "") { txtdepartmentcode.Text = ""; } if (txtdepartmentname.Text == "") { txtdepartmentname.Text = ""; } if (txtreportname.Text == "") { txtreportname.Text = ""; } } else { DE.DEPARTMENT_CODE = txtdepartmentcode.Text; DE.DEPARTMENT_NAME = txtdepartmentname.Text; DE.REPORT_NAME = txtreportname.Text; DE.STATUS = ComboBox1.Text; //S R I I I 11/15/2017 //DE.USER_NAME = login.u; DE.INSERT_BY = login.u; DE.INSERT_DATE = DateTime.Today; //DEPARTMENT DE.INSERT(); string a1 = "Save", b1 = Convert.ToString(Save.Content); if (b1 == a1) { // insert.Content = "Inserted Sucessfully"; // pop2.IsOpen = true; DataTable dt = d.fill_deptgrid(); dgdept.ItemsSource = dt.DefaultView; //MessageBox.Show("inserted sucessfully"); popup_insert.IsOpen = true; } DE.UPDATE(); string a = "Update", b = Convert.ToString(Save.Content); if (b == a) {//Save.Content = "Update"; // insert.Content = "Updated Sucessfully"; // pop2.IsOpen = true; DataTable dt = d.fill_deptgrid(); dgdept.ItemsSource = dt.DefaultView; //MessageBox.Show("updated sucessfully"); popup_update.IsOpen = true; } txtdepartmentcode.Text = ""; txtdepartmentname.Text = ""; txtreportname.Text = ""; ComboBox1.Text = ""; this.NavigationService.Refresh(); } //Add.Background = new SolidColorBrush(Color.FromRgb(53, 71, 102)); //Modify.Background = new SolidColorBrush(Color.FromRgb(53, 71, 102)); } catch (Exception) { MessageBox.Show("please Eneter correct values"); } }