public void btnLogin_Click()
        {
            User u = new User();
            if (u.LoadByPrimaryKey(txtUser.Text.Trim()))
            {
                if (HelperCrypto.MD5(txtPassword.Text.Trim()) == u.Password.Trim())
                {
                    HttpContext.Current.Session["user"] = txtUser.Text;

                    FormsAuthenticationTicket tkt;
                    string cookiestr;
                    HttpCookie ck;
                    tkt = new FormsAuthenticationTicket(1, txtUser.Text, DateTime.Now, DateTime.Now.AddHours(2), false, "");
                    cookiestr = FormsAuthentication.Encrypt(tkt);
                    ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
                    if (tkt.IsPersistent)
                        ck.Expires = tkt.Expiration;
                    ck.Expires = tkt.Expiration;
                    ck.Path = FormsAuthentication.FormsCookiePath;
                    Response.Cookies.Add(ck);
                    string strRedirect;
                    strRedirect = Request["ReturnUrl"];
                    if (strRedirect == null)
                        strRedirect = "default.aspx";
                    Response.Redirect(strRedirect, true);
                }
            }
        }
        public void SaveData()
        {
            if (txtPassword.Text.Trim() != txtPasswordConfirm.Text.Trim())
            {
                X.Msg.Alert("Error","Please review password, both must be same").Show();
                return;
            }
            if (cmbLevel.IsEmpty)
            {
                X.Msg.Alert("Error", "Please select a level for this user").Show();
                return;
            }

            User u = new User();
            u.Userid = txtUserId.Text.Trim();
            u.Password = HelperCrypto.MD5(txtPassword.Text.Trim());
            u.Level = cmbLevel.SelectedItem.Value;
            u.Nama = txtNama.Text.Trim();
            u.Jabatan = txtJabatan.Text;
            u.Divisi = txtBagian.Text;
            u.Lokasi = txtLokasi.Text;
            u.Save();
            HttpContext.Current.Session["isEditUser"] = true;
            X.AddScript("parentAutoLoadControl.close(); Delay='2' ");
        }
 public void DoYes(string userid)
 {
     BusinessObjects.User u = new User();
     if (u.LoadByPrimaryKey(userid.Trim()))
     {
         u.MarkAsDeleted();
         u.Save();
         HttpContext.Current.Session["isEditUser"] = true;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (Request.QueryString.Count == 0)
                    Response.Redirect("Default.aspx");
                if (Request.QueryString["userid"] == null)
                    X.AddScript("parentAutoLoadControl.close(); Delay='2' ");
                else
                {
                    userid = Request.QueryString["userid"].ToString().Trim();
                    HttpContext.Current.Session["userid"] = userid;
                    BusinessObjects.User u = new User();
                    if (u.LoadByPrimaryKey(userid))
                    {
                        //Populate the combobox
                        List<object> list = new List<object>
                        {
                            new {Text = "User", Value = "User"},
                            new {Text = "Admin", Value = "Admin"}
                        };
                        this.Store1.DataSource = list;
                        this.Store1.DataBind();

                        txtUserId.Text = u.Userid;
                        txtNama.Text = u.Nama;
                        txtLokasi.Text = u.Lokasi;
                        txtJabatan.Text = u.Jabatan;
                        txtBagian.Text = u.Divisi;
                        if (u.Level == "User")
                            cmbLevel.SelectedIndex = 0;
                        else
                            cmbLevel.SelectedIndex = 1;
                        if (u.Aktif == "Y")
                            chkAktif.Checked = true;
                        else if (u.Aktif == "N")
                            chkAktif.Checked = false;
                    }
                }
            }
        }
 public void SaveData()
 {
     if (string.IsNullOrEmpty(cmbLevel.SelectedItem.Value.Trim()))
         return;
     BusinessObjects.User u = new User();
     if (u.LoadByPrimaryKey(txtUserId.Text.Trim()))
     {
         u.Nama = txtNama.Text.Trim();
         u.Lokasi = txtLokasi.Text.Trim();
         u.Jabatan = txtJabatan.Text.Trim();
         u.Divisi = txtBagian.Text.Trim();
         u.Level = cmbLevel.SelectedItem.Value.Trim();
         if (chkAktif.Checked)
             u.Aktif = "Y";
         else
             u.Aktif = "N";
         u.Save();
     }
     HttpContext.Current.Session["isEditUser"] = true;
     X.AddScript("parentAutoLoadControl.close(); Delay='2' ");
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["activetab"] != null)
            {
                //TabPanel1.SetActiveTab(Request.QueryString["activetab"].ToString().Trim());
                this.lblWelcome.Text = Request.QueryString["activetab"].ToString().Trim();
            }

            if (HttpContext.Current.Session["activetab"] != null)
            {
                //TabPanel1.SetActiveTab(HttpContext.Current.Session["activetab"].ToString().Trim());
            }

            if (HttpContext.Current.Session["user"] != null)
            {
                string userid = HttpContext.Current.Session["user"].ToString().Trim();
                BusinessObjects.User u = new BusinessObjects.User();
                if (u.LoadByPrimaryKey(userid))
                {
                    HttpContext.Current.Session["username"] = u.Nama.Trim();
                    HttpContext.Current.Session["level"] = u.Level.Trim();
                    lblWelcome.Text = "Welcome " + HttpContext.Current.Session["username"].ToString().Trim();

                    if (HttpContext.Current.Session["level"].ToString().Trim() == "User")
                    {
                        btnMasterUser.Visible = false;
                        btnMasterGroup.Visible = false;
                    }
                }
            }

            if (!X.IsAjaxRequest)
                taskLocalTime.StartAll();
        }
        public void EditUser(string commandName, string userid)
        {
            taskManager1.StartAll();
            HttpContext.Current.Session["isEditUser"] = false;
            HttpContext.Current.Session["isEditUser"] = false;

            BusinessObjects.User u = new User();
            //EDIT
            if (u.LoadByPrimaryKey(userid.Trim()) && commandName.Trim() == "Edit")
            {
                var win = new Window()
                {
                    ID = "EditUserWindow",
                    Title = "Edit User : "******"~/frmUserWindowEdit.aspx?userid=" + userid.ToString().Trim();
                win.AutoLoad.Mode = LoadMode.IFrame;
                win.AutoLoad.ShowMask = true;
                win.Render(this.Form);
                win.Show();
            }
            //DELETE
            else if (u.LoadByPrimaryKey(userid.Trim()) && commandName.Trim() == "Delete")
            {
                X.Msg.Confirm("Warning", "Are you sure want to DELETE user : "******"Ext.net.DirectMethods.DoYes('" + userid + "')",
                        Text = "Yes, DELETE user: "******"Ext.net.DirectMethods.DoNo()",
                        Text = "No"
                    }
                }).Show();
            }
            //ADD NEW
            else if (commandName.Trim() == "New")
            {
                var win = new Window()
                {
                    ID = "AddUserWindow",
                    Title = "Add User",
                    Width = Unit.Pixel(800),
                    Height = Unit.Pixel(600),
                    Modal = true,
                    AutoRender = false,
                    Collapsed = false,
                    Maximizable = false,
                    Hidden = true,
                    Draggable = false,
                    Resizable = false,
                    Closable = true
                };

                win.AutoLoad.Url = "~/frmUserWindowAdd.aspx?userid=new";
                win.AutoLoad.Mode = LoadMode.IFrame;
                win.AutoLoad.ShowMask = true;
                win.Render(this.Form);
                win.Show();
            }
        }