protected void btndel_Click(object sender, EventArgs e)
        {
            var del = (from x in db.tblStaff_infos
                       where x.Staff_id == Convert.ToInt32(dropstaff.SelectedValue)
                       select new
            {
                id = x.Staff_id,
                count = x.tblTime_Records.Count
            }).SingleOrDefault();

            if (del != null)
            {
                if (del.count < 250)
                {
                    //Delete Permanently
                    tblStaff_info stf = db.tblStaff_infos.Single(x => x.Staff_id == del.id);
                    db.tblStaff_infos.DeleteOnSubmit(stf);
                    db.SubmitChanges();
                    Response.Write("<script>alert ('Staff Deleted Permanently');</script>");
                }
                else
                {
                    //terminate
                    tblStaff_info stf = db.tblStaff_infos.Single(x => x.Staff_id == del.id);
                    stf.Del_status = "Terminated";
                    db.SubmitChanges();
                    Response.Write("<script>alert ('Staff Terminated');</script>");
                }
            }
        }
 protected void btnupd_Click(object sender, EventArgs e)
 {
     try
     {
         if (validateinput())
         {
             if (dropstaff.SelectedValue.ToString() == "")
             {
                 Response.Write("<script>alert ('Please Selerct a staff member');</script>");
                 return;
             }
             tblStaff_info upd = db.tblStaff_infos.Single(x => x.Staff_id == Convert.ToInt32(dropstaff.SelectedValue));
             upd.Fname        = txtfname.Text;
             upd.Lname        = txtlname.Text;
             upd.Join_date    = Convert.ToDateTime(txtdate.Text);
             upd.Phone_number = Convert.ToInt32(txtphone.Text);
             if (RadioButton1.Checked == true)
             {
                 upd.Sex = 'M';
             }
             else if (RadioButton2.Checked == true)
             {
                 upd.Sex = 'F';
             }
             upd.Hrs_per_day = Convert.ToInt32(txthour.Text);
             upd.Profession  = dropprofession.SelectedItem.ToString();
             upd.Age         = Convert.ToInt32(txtage.Text);
             upd.Address     = txtaddress.Text;
             db.SubmitChanges();
             Response.Write("<script>alert ('Record Updated Successfully');</script>");
             clear();
         }
         else
         {
             return;
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert ('Please Try Again');</script>");
         return;
     }
 }
 protected void btnadd_Click(object sender, EventArgs e)
 {
     Label10.Text = "";
     try
     {
         if (validateinput())
         {
             tblStaff_info person = new tblStaff_info();
             person.Fname        = txtfname.Text;
             person.Lname        = txtlname.Text;
             person.Join_date    = Convert.ToDateTime(txtdate.Text);
             person.Phone_number = Convert.ToInt32(txtphone.Text);
             person.Address      = txtaddress.Text;
             person.Profession   = (dropjob.SelectedItem.Text);
             person.Jop_id       = Convert.ToInt32(dropjob.SelectedValue);
             person.Hrs_per_day  = Convert.ToInt32(txthour.Text);
             person.Age          = Convert.ToInt32(txtage.Text);
             if (RadioButton1.Checked == true)
             {
                 person.Sex = 'M';
             }
             else if (RadioButton2.Checked == true)
             {
                 person.Sex = 'F';
             }
             db.tblStaff_infos.InsertOnSubmit(person);
             db.SubmitChanges();
             Response.Write("<script>alert ('Record Added Successfully');</script>");
             clear();
         }
         else
         {
             return;
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert ('Please Try Again');</script>");
         // Label10.Text = ex.ToString();
     }
 }
Ejemplo n.º 4
0
 partial void DeletetblStaff_info(tblStaff_info instance);
Ejemplo n.º 5
0
 partial void UpdatetblStaff_info(tblStaff_info instance);
Ejemplo n.º 6
0
 partial void InserttblStaff_info(tblStaff_info instance);
Ejemplo n.º 7
0
 private void detach_tblStaff_infos(tblStaff_info entity)
 {
     this.SendPropertyChanging();
     entity.tblJob_Title = null;
 }