コード例 #1
0
        public ActionResult DangKyUser(FormCollection f)
        {
            /*  User usr = new User();
             * usr.IDUser = f["User"].ToString();
             * usr.PassUser = f["Pass"].ToString();
             * usr.HoTenUser = f["Fullname"].ToString();
             * usr.Email = f["Email"].ToString();
             * usr.DiaChi = f["DiaChi"].ToString();
             * // string s =;
             * // decimal d = decimal.Parse(s);
             * usr.SoDienThoai = f["Dienthoai"].ToString();
             *
             * usr.Ngaysinh = f["Ngaysinh"].ToString();
             * int a = 1;
             * usr.Quyen = a;
             * if (ModelState.IsValid)*/
            // {
            //  using (KLShopEntities7 entities = new KLShopEntities7())
            // {
            //-----------------------------------------

            /*  string name = f["User"];
             * // bool userInValid = entities.Users.Any(user => user.IDUser == name);
             * bool userInValid = svuser.KTraUser(name);
             * if (userInValid)
             * {
             *
             *    //ViewBag.Error = "<script language=javascript>alert('Đăng kí không thành công Ten đăng nhập bị trùng');</script>";
             *    ViewBag.Mess = "Tên đăng nhập đã tồn tại!";
             * }
             * else
             * {
             *
             *    //User us = db.Users.Find(name);
             *    //  db.Users.Remove(us);
             *
             *    //ViewBag.success = "<script language=javascript>alert('Đăng kí thành công!');</script>";
             *   svuser.AddUser(f["User"], f["Pass"], f["Fullname"], f["Email"], f["DiaChi"], f["Dienthoai"], f["Ngaysinh"]);
             *   // db.Users.Add(usr);
             *   // db.SaveChanges();
             *    return RedirectToAction("Index", "SanPham");
             *
             * }*/
            //---------------------------------
            //  }

            // }
            // ViewBag.ThongTinUsr = usr;
            //return View();
            svuser.AddUser(f["User"], f["Pass"], f["Fullname"], f["Email"], f["DiaChi"], f["Dienthoai"], f["Ngaysinh"], 0);
            return(RedirectToAction("Index", "SanPham"));
        }
コード例 #2
0
        public static bool AddUser(User user)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();

            try
            {
                return serviceUser.AddUser(user);
            }
            catch (Exception)
            {
                return false;
            }
        }
コード例 #3
0
        private void btnthem_Click(object sender, EventArgs e)
        {
            string user     = txtUser.Text.ToString();
            string pass     = txtPass.Text.ToString();
            string fullname = txtFullname.Text.ToString();
            string email    = txtemail.Text.ToString();
            string diachi   = txtDiaChi.Text.ToString();
            string sdt      = txtsdt.Text.ToString();
            string ngaysinh = txtngay.Text.ToString();
            int    quyen    = 1;

            svuser.AddUser(user, pass, fullname, email, diachi, sdt, ngaysinh, quyen);

            dvUser.DataSource = null;
            dvUser.DataSource = svuser.All();
        }
コード例 #4
0
        private void addUser()
        {
            if (!string.IsNullOrEmpty(FirstnameInput) && !string.IsNullOrEmpty(NameInput) &&
                !string.IsNullOrEmpty(RoleInput) && !string.IsNullOrEmpty(LoginInput) &&
                !string.IsNullOrEmpty(PasswordInput) && !string.IsNullOrEmpty(PasswordConfirmInput))
            {
                if (string.Compare(PasswordInput, PasswordConfirmInput) == 0)
                {
                    ServiceUserClient service = new ServiceUserClient();
                    User     new_user         = new User();
                    string[] roleTab          = this._roleInput.Split(' ');

                    new_user.Connected = false;
                    new_user.Firstname = _firstNameInput;
                    new_user.Name      = _nameInput;
                    new_user.Role      = roleTab[roleTab.Length - 1];
                    new_user.Pwd       = _passwordInput;
                    new_user.Login     = _loginInput;
                    new_user.Picture   = Pict;

                    if (service.AddUser(new_user))
                    {
                        View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow;

                        View.Personnel view             = new colle_tMedecine.View.Personnel();
                        ViewModel.PersonnelViewModel vm = new colle_tMedecine.ViewModel.PersonnelViewModel();
                        view.DataContext = vm;
                        mainwindow.contentcontrol.Content = view;
                    }
                }
                else
                {
                    ErrorMessage     = "Les mots de passe sont différents.";
                    ShowConnectError = 1;
                    ShowConnectError = 0;
                }
            }
            else
            {
                ErrorMessage     = "Veuillez remplir tous les champs.";
                ShowConnectError = 1;
                ShowConnectError = 0;
            }
        }
コード例 #5
0
ファイル: Users.cs プロジェクト: J0bba/WPF-Medecine
        public static bool CreateUser(Model.User user)
        {
            ServiceUserClient serviceUser = new ServiceUserClient();
            bool result = false;

            try
            {
                result = serviceUser.AddUser(new ServiceUser.User()
                {
                    Login     = user.login + i.ToString(),
                    Pwd       = user.pwd,
                    Name      = user.name,
                    Firstname = user.firstname,
                    Picture   = user.picture,
                    Role      = user.role
                });
            }
            catch (Exception) { }
            finally { serviceUser.Close(); }
            return(result);
        }
コード例 #6
0
        private void addUser()
        {
            if (!string.IsNullOrEmpty(FirstnameInput) && !string.IsNullOrEmpty(NameInput) &&
                !string.IsNullOrEmpty(RoleInput) && !string.IsNullOrEmpty(LoginInput) &&
                !string.IsNullOrEmpty(PasswordInput) && !string.IsNullOrEmpty(PasswordConfirmInput))
            {
                if (string.Compare(PasswordInput, PasswordConfirmInput) == 0)
                {
                    ServiceUserClient service = new ServiceUserClient();
                    User new_user = new User();
                    string[] roleTab = this._roleInput.Split(' ');

                    new_user.Connected = false;
                    new_user.Firstname = _firstNameInput;
                    new_user.Name = _nameInput;
                    new_user.Role = roleTab[roleTab.Length - 1];
                    new_user.Pwd = _passwordInput;
                    new_user.Login = _loginInput;
                    new_user.Picture = Pict;

                    if (service.AddUser(new_user))
                    {
                        View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow;

                        View.Personnel view = new colle_tMedecine.View.Personnel();
                        ViewModel.PersonnelViewModel vm = new colle_tMedecine.ViewModel.PersonnelViewModel();
                        view.DataContext = vm;
                        mainwindow.contentcontrol.Content = view;
                    }
                }
                else
                {
                    ErrorMessage = "Les mots de passe sont différents.";
                    ShowConnectError = 1;
                    ShowConnectError = 0;
                }
            }
            else
            {
                ErrorMessage = "Veuillez remplir tous les champs.";
                ShowConnectError = 1;
                ShowConnectError = 0;
            }
        }
コード例 #7
0
 /// <summary>
 /// Call WCF AddUser function
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool AddUser(User user)
 {
     return(_service.AddUser(user));
 }