public void Insert(User user) {
     user.CreatedDate = DateTime.Now;
     user.LastUpdatedDate = DateTime.Now;
     user.Version = 0;
     this.Context.Users.Add(user);
     this.Context.SaveChanges();
 }
 private void grdPatient_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     this.SelectedUser = (User) this.bdgUser.List[e.RowIndex];
     if (this.SelectedUser == null) return;
     this.DialogResult = DialogResult.Yes;
     this.Close();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangePassword"/> class.
 /// </summary>
 public ChangePassword(User user)
 {
     InitializeComponent();
     this.User = user;
     this.bdsUser.DataSource = User;
     this.txtUser.Text = User.UserName;
     this._userRepository = new UserRepository();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PatientRegister"/> class.
        /// </summary>
        public UserRegister(User patient)
        {
            InitializeComponent();
          

            this.User = patient;
            this.bdsUser.DataSource = User;
            this._isAddNew = false;
            this._userRepository = new UserRepository();
        }
 public void Update(User user) {
     var oldUsr = this.Context.Users.FirstOrDefault(x => x.Id == user.Id);
     if (oldUsr == null) return;
     oldUsr.Name = user.Name;
     oldUsr.UserName = user.UserName;
     oldUsr.Password = user.Password;
     oldUsr.Active = user.Active;
     oldUsr.Role = user.Role;
     oldUsr.ClinicId = user.ClinicId;
     oldUsr.LastUpdatedDate = DateTime.Now;
     oldUsr.Version++;
     this.Context.SaveChanges();
 }
Example #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         User user = new User();
         user.Name = this.TxtName.Text;
         user.UserName = this.TxtUserName.Text;
         user.Password = this.TxtPassword.Text;
         user.Active = CboActive.Checked;
         userRepository.Insert(user);
         MessageBox.Show("Inserted");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PatientRegister"/> class.
        /// </summary>
        public UserRegister(User patient)
        {
            InitializeComponent();
            var roles = new List<Item>()
                            {
                                new Item(Role.Administrator, "System admin"),
                                new Item(Role.Doctor, "Doctor"),
                                new Item(Role.Manager, "Supervisor"),
                                new Item(Role.Pharmacist, "Pharmacist")
                            };
            bdsRole.DataSource = roles;

            this.User = patient;
            this.bdsUser.DataSource = User;
            this._isAddNew = false;
            this._userRepository = new UserRepository();

            this.txtCode.ReadOnly = true;
            this.txtPhone.ReadOnly = true;
        }