Пример #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Value == null || txtUsername.Value == "")
            {
                throw new ApplicationException("field username is mandatory");
            }

            if (txtPassword.Value == null || txtPassword.Value == "")
            {
                throw new ApplicationException("field password is mandatory");
            }

            if (txtUsername.Value != null && txtUsername.Value != "")
            {
                PenjaminanDataset.UserProfileRow dr = UserProfile.getUserLogin(txtUsername.Value, txtPassword.Value);

                if (dr != null)
                {
                    if (dr.password == txtPassword.Value)
                    {
                        Session["UserProfile"] = dr;
                        Response.Redirect("/Dashboard.aspx");
                    }
                }
                else
                {
                    throw new ApplicationException("Username and Password not found");
                }
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserProfile"] == null)
            {
                Response.Redirect("/Default.aspx");
            }
            if (!Page.IsPostBack)
            {
                if (eType == "add")
                {
                }
                else if (eType == "edit")
                {
                    bindData();
                }
                else if (eType == "delete")
                {
                    softDeleteData(eID);
                }
            }

            lblMenu.Text          = "Entry Master User";
            Session["activepage"] = "user";

            if (!Page.IsPostBack)
            {
                Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter ta     = new Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter();
                Models.PenjaminanDatasetTableAdapters.u_roleTableAdapter taRole = new Models.PenjaminanDatasetTableAdapters.u_roleTableAdapter();

                DropDownList1.DataSource = (PenjaminanDataset.DivisiDataTable)ta.GetData();
                DropDownList1.DataBind();

                RoleList.DataSource = (PenjaminanDataset.u_roleDataTable)taRole.GetData();
                RoleList.DataBind();

                //set jadi kosong ketika add new


                if (eType == "edit")
                {
                    PenjaminanDataset.UserProfileRow dr = UserProfile.selectUserProfileByID(eID);
                    tDivisiID = Convert.ToInt16(dr.division);
                    tRoleID   = Convert.ToInt16(dr.role);

                    DropDownList1.SelectedValue = tDivisiID.ToString();
                    RoleList.SelectedValue      = tRoleID.ToString();
                }
                //else if(eType == "add")
                //{
                //    DropDownList1.SelectedValue = " ";
                //    RoleList.SelectedValue = " ";
                //}

                //DropDownList1.DataTextFormatString = "{0} - {1}";
                //DropDownList1.DataTextField = "ID,NamaDivisi";
            }
        }
Пример #3
0
        private void bindData()
        {
            PenjaminanDataset.UserProfileRow dr = UserProfile.selectUserProfileByID(eID);
            Models.PenjaminanDatasetTableAdapters.u_roleTableAdapter taRole = new Models.PenjaminanDatasetTableAdapters.u_roleTableAdapter();
            Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter ta     = new Models.PenjaminanDatasetTableAdapters.DivisiTableAdapter();

            DropDownList1.DataSource = (PenjaminanDataset.DivisiDataTable)ta.GetDataByID(Convert.ToInt16(dr.division));
            RoleList.DataSource      = (PenjaminanDataset.u_roleDataTable)taRole.GetDataRoleByID(Convert.ToInt16(dr.role));

            DropDownList1.DataBind();
            RoleList.DataBind();
            txtUsername.Value = dr.username.ToString();
            txtPassword.Value = dr.password.ToString();
            //txtRole.Value = dr.role.ToString();
            //txtDivision.Value = dr.division.ToString();
        }
Пример #4
0
        public static PenjaminanDataset.UserProfileRow getUserLogin(string username, string password)
        {
            PenjaminanDatasetTableAdapters.UserProfileTableAdapter ta = new PenjaminanDatasetTableAdapters.UserProfileTableAdapter();
            PenjaminanDataset.UserProfileDataTable dt = new PenjaminanDataset.UserProfileDataTable();
            PenjaminanDataset.UserProfileRow       dr = null;

            try
            {
                ta.FillUserProfileByUsernamePassword(dt, username, password);

                if (dt.Count > 0)
                {
                    dr = dt[0];
                }

                return(dr);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message, ex);
            }
        }
Пример #5
0
        public static PenjaminanDataset.UserProfileRow selectUserProfileByID(int id)
        {
            PenjaminanDatasetTableAdapters.UserProfileTableAdapter ta = new PenjaminanDatasetTableAdapters.UserProfileTableAdapter();
            PenjaminanDataset.UserProfileDataTable dt = new PenjaminanDataset.UserProfileDataTable();
            PenjaminanDataset.UserProfileRow       dr = null;

            try
            {
                ta.FillUserProfileByID(dt, id);

                if (dt.Count > 0)
                {
                    dr = dt[0];
                }

                return(dr);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to load user profile data : " + ex.Message);
            }
        }