예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         AmecUser  LeaveUser = UserInitiate.LoggedUser;;
         DataTable dt        = lvDb.GetLeaves(LeaveUser);
         if (dt != null && dt.Rows.Count > 0)
         {
             gdVwLeave.DataSource = dt;
             gdVwLeave.DataBind();
         }
     }
 }
예제 #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //temp until windows auth enable
            AmecUser user = new AmecUser();

            user.NtId      = tbUserName.Text.Trim();
            user.Name      = user.NtId;
            user.GivenName = user.NtId;
            user.Email     = "*****@*****.**";
            lvDb.UserInit(user);
            Session[Constants.UserSession] = user;
            Response.Redirect("~/Leave/LeaveSubmit.aspx");
        }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         try
         {
             //Response.Redirect("~/Login.aspx");
             AmecUser user = UserInitiate.LoggedUser;
             lblUserName.Text = user.GivenName;
         }
         catch (Exception)
         {
             Response.Redirect(string.Format("~/LoginError.aspx?status={0}", "User Acces Error, Please contact Amec"));
         }
     }
 }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                foreach (int i in Enum.GetValues(typeof(Enums.LeaveTypes)))
                {
                    ddlLeaveType.Items.Add(new ListItem(Enums.GetDescription((Enums.LeaveTypes)i), i.ToString()));
                }

                AmecUser  LeaveUser = UserInitiate.LoggedUser;;
                DataTable dt        = lvDb.GetLeaves(LeaveUser);
                if (dt != null && dt.Rows.Count > 0)
                {
                    gdVwLeave.DataSource = dt;
                    gdVwLeave.DataBind();
                }
            }
        }
예제 #5
0
        public static AmecUser UserInit()
        {
            LeaveDataAccess lvDb     = new LeaveDataAccess();
            AmecUser        amecUser = new AmecUser();
            string          userName = HttpContext.Current.User.Identity.Name;
            string          ntid     = userName.Split('\\')[1];

            amecUser.NtId = ntid;

            using (PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "GICNT")) {
                using (UserPrincipal oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, userName))
                {
                    amecUser.Email     = oUserPrincipal.EmailAddress;
                    amecUser.GivenName = oUserPrincipal.GivenName;
                    amecUser.Name      = oUserPrincipal.ToString();
                }
            }
            lvDb.UserInit(amecUser);
            return(amecUser);
        }
예제 #6
0
 internal void UserInit(AmecUser user)
 {
     using (SqlConnection conn = new SqlConnection(AmecUtilDBConnection))
     {
         SqlCommand cmd = conn.CreateCommand();
         cmd.CommandText = "amec_user_init";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("ntid", user.NtId);
         cmd.Parameters.AddWithValue("name", user.Name);
         cmd.Parameters.AddWithValue("email", user.Email);
         cmd.Parameters.AddWithValue("givenName", user.GivenName);
         try
         {
             conn.Open();
             cmd.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
예제 #7
0
        internal DataTable GetLeaves(AmecUser leaveUser)
        {
            DataTable dt = new DataTable();

            using (SqlConnection conn = new SqlConnection(AmecUtilDBConnection))
            {
                string     sql = "SELECT l.id as [Leave Id],l.leave_type_desc as [Leave Type],l.leave_date_type as [Leave Date type],(CONVERT(varchar, l.leave_date, 106)) as [Leave Date], (CONVERT(varchar, l.created_date, 106)) as [Created Date], l.leave_remarks as [Remarks] FROM amec_leaves l join amec_members m on l.nt_id =m.nt_id where l.nt_id = @ntid order by l.created_date desc";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("ntid", leaveUser.NtId);
                try
                {
                    conn.Open();
                    var dataReader = cmd.ExecuteReader();
                    dt.Load(dataReader);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(dt);
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AmecUser user = UserInitiate.LoggedUser;

            ltName.Text = user.GivenName;
        }