protected void btnsave_Click(object sender, EventArgs e)
 {
     //validate inputs
     //get employeeid
     try
     {
         if (txtFname.Text.ToString().Trim() == string.Empty)
         {
             throw new Exception("First Name is required");
         }
         else if (txtLname.Text.ToString().Trim() == string.Empty)
         {
             throw new Exception("Last Name is required");
         }
         else if (txtPhone.Text.ToString().Trim() == string.Empty)
         {
             throw new Exception("Phone/Mobile is required");
         }
         else if (ddldepartment.SelectedValue == "0")
         {
             throw new Exception("Select a department!");
         }
         else if (txtJOb.Text.ToString().Trim() == string.Empty)
         {
             throw new Exception("Job is required");
         }
         else if (txthiringdate.Text.ToString().Trim() == string.Empty)
         {
             throw new Exception("Hiring date is required");
         }
         else
         {
             //if param empty either update if record exist else create new ,check stored procedure if needed
             employeemodel.EmployeeId   = Convert.ToInt32(txtEmployeeId.Text.ToString());
             employeemodel.Emp_Fname    = txtFname.Text.ToString();
             employeemodel.Emp_Lname    = txtLname.Text.ToString();
             employeemodel.Emp_Address  = txtAddress.Text.ToString();
             employeemodel.Emp_Phone    = txtPhone.Text.ToString();
             employeemodel.Emp_Job      = txtJOb.Text.ToString();
             employeemodel.Hireddate    = Convert.ToDateTime(txthiringdate.Text.ToString());
             employeemodel.Endate       = (txtEnddate.Text != string.Empty ? Convert.ToDateTime(txtEnddate.Text.ToString()) : Convert.ToDateTime("1/1/1753"));
             employeemodel.DepartmentId = Convert.ToInt32(ddldepartment.SelectedValue.ToString());
             employeemodel.Emp_Email    = txtemail.Text.ToString();
             employeemodel.SSN          = txtSSN.Text.ToString();
             employeemodel.PayType      = ddlpaytype.SelectedValue.ToString();
             employeemodel.Rate         = Convert.ToDecimal(txtRate.Text.ToString());
             employeemodel.OTRate       = Convert.ToDecimal(txtOtRate.Text.ToString());
             int affectedrecords = employeemodel.Access_Employee(string.Empty);
             if (affectedrecords > 0)
             {
                 //clear header fields
                 //rebind griddata
                 //show save alert
                 Response.Write("<script>alert('Saving successful!');</script>");
                 Clear();
                 BindData();
                 btnsave.Text = "CREATE";
             }
         }
     }
     catch (Exception ex)
     {
         lblerror.Text     = ex.Message.ToString();
         div_error.Visible = true;
     }
 }