Esempio n. 1
0
        protected void ProceedButton_Click(object sender, EventArgs e)
        {
            ReportedAbsenceEntity entity = new ReportedAbsenceEntity();
            entity.ManagerEmployeeId = new UserMapper().GetUserByUserName(UserPrincipal.Current.SamAccountName).EmployeeId;

            entity.AbsenceEmployeeId = Convert.ToInt32(AbsenceEmployeeDropDownList.SelectedValue);
            entity.Notes = OtherInfoTextBox.Text;
            entity.Date = DateTime.Now;

            new ReportedAbsenceMapper().ReportAbsence(entity);

            Response.Redirect("~/Dashboard.aspx");
        }
        public void ReportAbsence(ReportedAbsenceEntity t)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;

            try
            {
                conn = DALHelper.CreateSqlDbConnection();
                cmd = new SqlCommand("usp_ReportAbsence", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Date", t.Date);
                cmd.Parameters.AddWithValue("@AbsenceEmployeeId", t.AbsenceEmployeeId);
                cmd.Parameters.AddWithValue("@ManagerEmployeeId", t.ManagerEmployeeId);
                cmd.Parameters.AddWithValue("@Notes", t.Notes);

                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }