protected void btnSave_Click(object sender, EventArgs e)
        {
            if (txtNewPwd.Text == "")
            {
                txtNewPwd.Focus();
                return;
            }

            if (txtConfirmPwd.Text == txtNewPwd.Text)
            {
                BL_Users obj = new BL_Users();
                obj.USER_NAME       = "";
                obj.ID              = Convert.ToInt32(Session["UserId"]);
                obj.REGISTERED_DATE = System.DateTime.Now;
                obj.PWD             = EncryptDecrypt.base64Encode(txtConfirmPwd.Text);
                obj.EVENT           = 'C';
                int    Id  = 0;
                string msg = "";
                msg = obj.InsUpdDeleteUsers(out Id);
                if (msg == "Password Changed Successfully")
                {
                    msgbox.ShowSuccess(msg);
                    txtNewPwd.Text     = "";
                    txtConfirmPwd.Text = "";
                    txtCurrentPwd.Text = "";
                }
                else
                {
                    msgbox.ShowWarning(msg);
                }
            }
        }
 private void BindData()
 {
     DataSource = new ObservableCollection <Users>(BL_Users.GetAll());
     DataSource.CollectionChanged += DataSource_CollectionChanged;
     grdUserOverview.ItemsSource   = DataSource;
     grdUserOverview.DataContext   = DataSource;
 }
示例#3
0
        /// <summary>
        /// default constructor
        /// </summary>
        public Mainwindow()
        {
            InitializeComponent();

            currentUser = BL_Users.GetCurrentUser();
            SetTitle();
        }
        private void grdUserOverview_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            DataGridRow _dgRow        = e.Row;
            var         _changedValue = _dgRow.DataContext as Users;

            BL_Users.Save(_changedValue);
        }
        // GET: Admin
        public ActionResult Index()
        {
            string UserName = Request["username"];
            string Password = Request["password"];

            Constants.LoginResult result;
            BO_Users user        = new BO_Users();
            BO_Users currentUser = BL_Users.Login(Session, UserName, Password, out result);

            if (UserName != null && Password != null)
            {
                if (result == Constants.LoginResult.Success)
                {
                    Session[Constants.SESSION_USERKEY] = currentUser;
                    return(Redirect("/Sales/Index"));
                }
                else
                {
                    ViewBag.Validation = "Invalid";
                }
            }



            return(View());
        }
示例#6
0
        public ActionResult GetUserByID(int _userId)
        {
            BO_Users obj = new BussinessObject.BO_Users();

            obj = BL_Users.GetUserByID(_userId);
            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
示例#7
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text != "" && txtPwd.Text != "")
            {
                var pwd = EncryptDecrypt.base64Encode(txtPwd.Text);
                var dt  = new DataTable();
                dt = BL_Users.GetUsers(2, 0, txtUserName.Text);

                if (dt.Rows.Count > 0)
                {
                    var a = EncryptDecrypt.base64Decode(dt.Rows[0]["PWD"].ToString());
                    if (pwd == dt.Rows[0]["PWD"].ToString())
                    {
                        var userID = Convert.ToInt32(dt.Rows[0]["ID"].ToString());
                        var roleId = Convert.ToInt32(dt.Rows[0]["ROLE_ID"].ToString());
                        var obj    = new BK_Session(Convert.ToInt32(userID), roleId, this.PrepareMenu(roleId));
                        obj.UserName = dt.Rows[0]["USER_NAME"].ToString();
                        obj.RoleName = dt.Rows[0]["ROLE_NAME"].ToString();
                        obj.BranchId = Convert.ToInt32(dt.Rows[0]["BRANCH_ID"].ToString());
                        BK_Session.SetSession(obj);
                        var opdate = DateTime.Parse(GetOperationDate(BK_Session.GetSession().BranchId));
                        InsertDayOpen(BK_Session.GetSession().BranchId, opdate, BK_Session.GetSession().UserId);
                        obj.OpDate = opdate;
                        obj.Name   = dt.Rows[0]["NAME"].ToString();
                        BK_Session.SetSession(obj);

                        Session["Username"] = dt.Rows[0]["USER_NAME"].ToString();
                        FormsAuthenticationTicket tkt;
                        string cookiestr;

                        tkt       = new FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, "your custom data");
                        cookiestr = FormsAuthentication.Encrypt(tkt);

                        //   FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
                        string strRedirect;
                        strRedirect = Request["ReturnUrl"];
                        if (strRedirect == null)
                        {
                            strRedirect = "~/DashBoard.aspx";
                        }
                        Response.Redirect(strRedirect, true);
                    }
                    else
                    {
                        //lblError.Text = "Invalid Password For the Given User..!!";
                        txtPwd.Text = "";
                        txtPwd.Focus();
                    }
                }
                else
                {
                    //lblError.Text = "Invalid User Name..!!";
                    txtUserName.Text = "";
                    txtPwd.Text      = "";
                    txtUserName.Focus();
                }
            }
        }
示例#8
0
        private void Accountform_Confirming(Users user, string pwd)
        {
            try
            {
                BL_Users.Update(user, pwd);

                mainContent.Content = null;
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#9
0
        public void btnChangepwd_Click(object sender, RoutedEventArgs e)
        {
            var obj = ((FrameworkElement)sender).DataContext as Users;

            string newPass = StringExtensions.GetRandomString();

            BL_Users.Update(obj, newPass);

            BL_Users.SendCredentials(obj.Firstname, obj.Lastname, obj.Email, obj.Username, newPass);

            MessageBox.Show("The new password has been sent to the user.", "New password");

            BindData();
        }
示例#10
0
        private void FillgvUsers()
        {
            var dt = new DataTable();

            dt = BL_Users.GetUsers(1, Convert.ToInt32(BK_Session.GetSession().BranchId), "");
            if (dt.Rows.Count > 0)
            {
                gvUsers.DataSource = dt;
                gvUsers.DataBind();
            }
            else
            {
                gvUsers.DataSource = new string[] { };
                gvUsers.DataBind();
            }
        }
示例#11
0
        private void Authenticate()
        {
            bool Validation = true;

            lblUsernameError.Content = "";
            lblPasswordError.Content = "";

            try
            {
                if (string.IsNullOrWhiteSpace(txtUsername.Text))
                {
                    Validation = false;
                    lblUsernameError.Content = "is mandatory.";
                }

                if (string.IsNullOrWhiteSpace(txtPassword.Password))
                {
                    Validation = false;
                    lblPasswordError.Content = "is mandatory.";
                }

                if (Validation && BL_Users.Authenticate(new Loginmodel()
                {
                    CredentialName = txtUsername.Text, Password = txtPassword.Password
                }))
                {
                    new MainWindow().Show();
                    this.Close();
                }
                else
                {
                    throw new Exception("Authentication failed. Please check your credentials");
                }
            }
            catch (UserNotFoundException ex)
            {
                lblUsernameError.Content = ex.Message;
            }
            catch (Exception ex)
            {
                lblAuthError.Content = ex.Message;
            }
            ShowPassword = false;
            TogglePassword();

            txtUsername.Focus();
        }
示例#12
0
        private void DataSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (Users item in e.NewItems)
                {
                    BL_Users.Save(item);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (Users item in e.OldItems)
                {
                    BL_Users.Delete(item);
                }
                break;
            }
        }
示例#13
0
        private void FormConfirming(Users user, string pwd)
        {
            if (string.IsNullOrWhiteSpace(pwd))
            {
                MessageBox.Show("The password is mandatory");
            }
            else
            {
                user = BL_Users.ChangePassword(user, pwd);

                BL_Users.Create(user);

                if (OnUserCreated != null)
                {
                    OnUserCreated(user.Username, pwd);
                }

                this.Close();
            }
        }
示例#14
0
        private void NewUserForm_Confirming(Users user, string pwd)
        {
            try
            {
                if (string.IsNullOrEmpty(pwd))
                {
                    pwd = StringExtensions.GetRandomString();
                }

                user = BL_Users.ChangePassword(user, pwd);
                BL_Users.Create(user);



                btnUserOverview_Click(btnUserOverview, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#15
0
 protected void txtCurrentPwd_TextChanged(object sender, EventArgs e)
 {
     if (txtCurrentPwd.Text != "")
     {
         DataTable dt = BL_Users.GetUsers(3, 0, Session["UserId"].ToString());
         if (dt.Rows.Count > 0)
         {
             if (EncryptDecrypt.base64Encode(txtCurrentPwd.Text) != dt.Rows[0]["PWD"].ToString())
             {
                 msgbox.ShowWarning("Current Password didnot Match");
                 btnSave.Enabled = false;
                 txtNewPwd.Focus();
             }
             else
             {
                 btnSave.Enabled = true;
                 txtNewPwd.Focus();
             }
         }
     }
 }
示例#16
0
        public LoginWindow()
        {
            InitializeComponent();

            ShowPassword = false;
            TogglePassword();

            txtUsername.Focus();

            if (BL_Users.Any())
            {
                txtUsername.Focus();
            }
            else
            {
                var _initUserWindow = new Initialuserwindow();
                _initUserWindow.OnUserCreated += InitialUserWindow_OnUserCreated;

                _initUserWindow.Show();
            }
        }
示例#17
0
        public string AddUsers(string firstname, string lastname, string emailID, string contact, bool Active, string Groups)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                eUsers eObj = new eUsers();
                eObj.sUserName = emailID;
                byte[] b        = new byte[1];
                string Password = emailID.Substring(0, emailID.IndexOf("@")).ToLower();
                Password = SimpleHash.ComputeHash(Password, "SHA1", b);

                eObj.sPassword    = Password;
                eObj.sFirstName   = firstname;
                eObj.sLastName    = lastname;
                eObj.sEmail       = emailID;
                eObj.sContact     = contact;
                eObj.dtCreatedOn  = DateTime.Now;
                eObj.dtActionDate = DateTime.Now;
                eObj.cStatus      = Active ? "A" : "D";
                eObj.iActionBy    = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;

                int i = BL_Users.AddRecord(eObj, Groups.Substring(0, Groups.Length - 1));
                if (i == 1)
                {
                    result = new { st = 1, msg = clsUtils.ErrorMsg("User", 1) };
                }
                else
                {
                    result = new { st = 0, msg = clsUtils.ErrorMsg("User", 0) };
                }
            }
            catch (Exception ex)
            {
                result = new { st = 0, msg = clsUtils.ErrorMsg("", 3) };
            }
            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }
示例#18
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (Confirming != null)
            {
                Confirming(Model, txtPassword.Password);
            }

            try
            {
                if (BL_Users.Save(Model))
                {
                    if (OnModelSaved != null)
                    {
                        OnModelSaved(Model);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#19
0
        public string DeleteUsers(int id)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                int i = BL_Users.DeleteRecord(id);
                if (i == 1)
                {
                    result = new { st = 1, msg = "Deleted successfully." };
                }
                else
                {
                    result = new { st = 0, msg = "Kindly try after some time." };
                }
            }
            catch (Exception)
            {
                result = new { st = 0, msg = "Kindly try after some time." };
            }
            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }
示例#20
0
        public string UpdateUsers(string Usersname, string firstname, string lastname, string emailID, string contact, bool Active, int id, string Groups)
        {
            object result    = null;
            string strReturn = string.Empty;

            try
            {
                eUsers Obj = new eUsers();
                Obj              = BL_Users.GetSingleRecordById(id);
                Obj.sUserName    = emailID;
                Obj.sFirstName   = firstname;
                Obj.sLastName    = lastname;
                Obj.sEmail       = emailID;
                Obj.sContact     = contact;
                Obj.dtCreatedOn  = DateTime.Now;
                Obj.dtActionDate = DateTime.Now;
                Obj.cStatus      = Active ? "A" : "I";
                int a = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId;
                Obj.iActionBy = a;
                int i = BL_Users.UpdateRecord(Obj, Groups.Substring(0, Groups.Length - 1));
                if (i == 1)
                {
                    result = new { st = 1, msg = clsUtils.ErrorMsg("User", 2) };
                }
                else
                {
                    result = new { st = 0, msg = clsUtils.ErrorMsg("User", 0) };
                }
            }
            catch (Exception)
            {
                result = new { st = 0, msg = clsUtils.ErrorMsg("", 3) };
            }
            strReturn = OneFineRateAppUtil.clsUtils.ConvertToJson(result);
            return(strReturn);
        }
示例#21
0
        public string DeleteUser(int id)
        {
            var pl = BL_Users.DeleteUser(id, UserAprosysAccounting.id);

            return(BL_Common.Serialize("success"));
        }
示例#22
0
        public ActionResult LoadUserTable(JQueryDataTableParamModel Param)
        {
            MYJSONTblCustom MYJSON = BL_Users.LoadUserTable(Param, Request);

            return(Json(MYJSON, JsonRequestBehavior.AllowGet));
        }
示例#23
0
        public string SaveUser(string paramuser)
        {
            var _user = BL_Common.Deserialize <BO_Users>(paramuser);

            return(BL_Common.Serialize(BL_Users.SaveUser(_user, UserAprosysAccounting.id)));
        }
示例#24
0
        private void InsupdDeleteusers(char Event, int Id)
        {
            var obj = new BL_Users();

            if (Event == 'I')
            {
                if (txtPassword.Text == txtConfirmPassword.Text)
                {
                    obj.EVENT = 'I';
                    //  obj.NAME = txtFirstName.Text + " " + txtLastName.Text;
                    obj.STAFF_ID        = Convert.ToInt32((string)ddlStaffName.SelectedValue);
                    obj.PWD             = EncryptDecrypt.base64Encode(txtPassword.Text);
                    obj.CONTACT_NO      = txtContactNo.Text;
                    obj.ADDRESS         = txtAddress.Text;
                    obj.EMAIL_ID        = txtEmail.Text;
                    obj.REGISTERED_BY   = Convert.ToInt32(BK_Session.GetSession().UserId);
                    obj.REGISTERED_DATE = System.DateTime.Now;
                    obj.USER_NAME       = txtUserName.Text + lblCompanyCode.Text;

                    obj.USER_STATUS = true;
                    obj.ROLE_ID     = Convert.ToInt32((string)ddlRoles.SelectedValue);
                    obj.BranchId    = Convert.ToInt32(BK_Session.GetSession().BranchId);
                    Id = 0;
                    var msg = "";
                    msg = obj.InsUpdDeleteUsers(out Id);
                    if (msg == "Record Inserted Successfully")
                    {
                        msgbox.ShowSuccess(msg);
                        Clear();
                    }
                    else
                    {
                        msgbox.ShowWarning(msg);
                    }
                }
            }
            else if (Event == 'U')
            {
                obj.EVENT           = Event;
                obj.ID              = Id;
                obj.STAFF_ID        = Convert.ToInt32((string)ddlStaffName.SelectedValue);
                obj.PWD             = EncryptDecrypt.base64Encode(txtPassword.Text + lblCompanyCode.Text);
                obj.CONTACT_NO      = txtContactNo.Text;
                obj.ADDRESS         = txtAddress.Text;
                obj.EMAIL_ID        = txtEmail.Text;
                obj.REGISTERED_BY   = Convert.ToInt32(BK_Session.GetSession().UserId);
                obj.REGISTERED_DATE = BK_Session.GetSession().OpDate;
                obj.USER_NAME       = txtUserName.Text;
                obj.USER_STATUS     = true;
                obj.ROLE_ID         = Convert.ToInt32((string)ddlRoles.SelectedValue);
                obj.BranchId        = Convert.ToInt32(BK_Session.GetSession().BranchId);
                Id = 0;
                var msg = "";
                msg = obj.InsUpdDeleteUsers(out Id);
                if (msg == "Record Updated Successfully")
                {
                    msgbox.ShowSuccess(msg);
                    Clear();
                }
                else
                {
                    msgbox.ShowWarning(msg);
                }
            }
            else if (Event == 'D')
            {
                obj.EVENT           = Event;
                obj.ID              = Id;
                obj.STAFF_ID        = Convert.ToInt32((string)ddlStaffName.SelectedValue);
                obj.PWD             = EncryptDecrypt.base64Encode(txtPassword.Text);
                obj.ADDRESS         = txtAddress.Text;
                obj.CONTACT_NO      = txtContactNo.Text;
                obj.EMAIL_ID        = txtEmail.Text;
                obj.REGISTERED_BY   = Convert.ToInt32(BK_Session.GetSession().UserId);
                obj.REGISTERED_DATE = BK_Session.GetSession().OpDate;
                obj.USER_NAME       = txtUserName.Text;

                Id = 0;
                var msg = "";
                msg = obj.InsUpdDeleteUsers(out Id);
                if (msg == "Record Deleted Successfully")
                {
                    msgbox.ShowSuccess(msg);
                    Clear();
                }
                else
                {
                    msgbox.ShowWarning(msg);
                }
            }
            else
            {
                obj.EVENT    = Event;
                obj.ID       = Id;
                obj.STAFF_ID = Convert.ToInt32((string)ddlStaffName.SelectedValue);
                var pwd = (txtPassword.Text).ToLower();
                obj.PWD             = EncryptDecrypt.base64Encode(pwd);
                obj.ADDRESS         = txtAddress.Text;
                obj.CONTACT_NO      = txtContactNo.Text;
                obj.EMAIL_ID        = txtEmail.Text;
                obj.REGISTERED_BY   = Convert.ToInt32(BK_Session.GetSession().UserId);
                obj.REGISTERED_DATE = BK_Session.GetSession().OpDate;
                obj.USER_NAME       = txtUserName.Text;
                Id = 0;
                var msg = "";
                msg = obj.InsUpdDeleteUsers(out Id);
                if (msg == "Password Changed Successfully")
                {
                    msgbox.ShowSuccess(msg);
                    Clear();
                }
                else
                {
                    msgbox.ShowWarning(msg);
                }
            }

            FillgvUsers();
        }