Exemplo n.º 1
0
 private void Insert_Button_Click(object sender, EventArgs e)
 {
     if (From == "Insert")
     {
         Employee.Id   = int.Parse(Id_Textbox.Text);
         Employee.Name = Name_Textbox.Text;
         Employee.Experience_In_Years = Experience_Textbox.Text;
         Employee.JobRole             = JobRole_Textbox.Text;
         Employee.Salary = int.Parse(Salary_Textbox.Text);
         Data_Object.EmployeeTables.InsertOnSubmit(Employee); // Data that is to be submitted is now in pending state
         Data_Object.SubmitChanges();
         MessageBox.Show(" Data Has Been Inserted Successfully. ");
         Clear("Insert");
     }
     else if (From == "Update")
     {
         EmployeeTable Employee = Data_Object.EmployeeTables.SingleOrDefault(X => X.Id == int.Parse(Id_Textbox.Text));
         Employee.Id                  = int.Parse(Id_Textbox.Text.ToString());
         Employee.Name                = Name_Textbox.Text.ToString();
         Employee.Salary              = decimal.Parse(Salary_Textbox.Text.ToString());
         Employee.JobRole             = JobRole_Textbox.Text.ToString();
         Employee.Experience_In_Years = Experience_Textbox.Text.ToString();
         Data_Object.SubmitChanges();
         MessageBox.Show(" Data Has Been Updated. ");
         Clear("Update");
     }
     else
     {
         MessageBox.Show(" An Error Occured, Please Try Again ");
     }
 }
Exemplo n.º 2
0
 public Insert_Form(ref EmployeeDataContext Data_Object_, ref Table <EmployeeTable> EmployeeTable_, string From_, string Id_ = "")
 {
     InitializeComponent();
     Data_Object   = Data_Object_;
     EmployeeTable = EmployeeTable_;
     From          = From_;
     Id            = Id_;
     Employee      = new EmployeeTable();
 }
Exemplo n.º 3
0
 private void Delete_Button_Click(object sender, EventArgs e)
 {
     if (Data_Grid.SelectedRows.Count > 0)
     {
         if (MessageBox.Show("Are You Sure Do You Want To Delete ? ", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             for (int Record = 0; Record < Data_Grid.SelectedRows.Count; ++Record)
             {
                 int           Emp_Id   = Convert.ToInt32(Data_Grid.SelectedRows[Record].Cells[0].Value);
                 EmployeeTable Employee = Data_Object.EmployeeTables.SingleOrDefault(Emp => Emp.Id == Emp_Id);
                 Data_Object.EmployeeTables.DeleteOnSubmit(Employee);
                 Data_Object.SubmitChanges();
             }
             Load_Data();
         }
     }
 }
Exemplo n.º 4
0
 partial void DeleteEmployeeTable(EmployeeTable instance);
Exemplo n.º 5
0
 partial void UpdateEmployeeTable(EmployeeTable instance);
Exemplo n.º 6
0
 partial void InsertEmployeeTable(EmployeeTable instance);