public ActionResult RegisterUser(UserModel usermodel)
        {
            var Employee = new UserEmployee()
            {
                Name     = usermodel.Name,
                Username = usermodel.UserName,
                Password = usermodel.Password,
                BranchId = usermodel.BranchId
            };

            var EmployeeAddress = new Address()
            {
                UserTypeId    = usermodel.UserTypeId,
                ContactNo     = usermodel.ContactNo,
                Email         = usermodel.Email,
                GenderId      = usermodel.GenderId,
                Qualification = usermodel.Qualification,
                AddressDetail = usermodel.AddressDetails,
                CNIC          = usermodel.CNIC
            };

            UserServices.RegisterUser(Employee, EmployeeAddress);
            //jo view call krna hai registration k baad wo view bna kr oska name paramter m yha pass krdena
            return(View());
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            UserEmployee userEmployee = db
                                        .UserEmployees
                                        .Find(id);

            var userid = db
                         .Users
                         .Find(userEmployee.RegistrationID);

            if (id == null)
            {
                return(HttpNotFound());
            }
            if (userid == null)
            {
                return(HttpNotFound());
            }
            db.Users
            .Remove(userid);
            db.UserEmployees
            .Remove(userEmployee);
            db.SaveChanges();


            return(RedirectToAction("Index"));
        }
 /// <summary>
 /// Initializes a new instance of the class BillFrom and opens the specified XML document.
 /// </summary>
 public PatientReport(string path, List <PatientReportModel> model, Refer ReferDoc, Patient PatientInfo, UserEmployee PatientDoctor, string branch)
 {
     this.model         = model;
     this.path          = path;
     this.ReferDoc      = ReferDoc;
     this.PatientInfo   = PatientInfo;
     this.Branch        = branch;
     this.PatientDoctor = PatientDoctor;
 }
Beispiel #4
0
        /// <summary>
        /// 登录
        /// </summary>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string       loginName = Request["loginName"].ToString().Trim();
            string       passwords = Request["passWord"].ToString().Trim();
            bool         IsCheck   = ChkLoginState.Checked;
            Sys_Employee m_emp     = _empService.GetByLoginName(loginName);

            if (m_emp != null)
            {
                if (m_emp.PassWord != passwords.MD5Hash())
                {
                    JavaScriptTools.AlertWindow("密码输入错误", Page);
                    return;
                }
            }
            else
            {
                JavaScriptTools.AlertWindow("帐号不存在", Page);
                return;
            }

            #region 利用方法 获取帐号 密码

            var form = System.Web.HttpContext.Current.Request.Form;

            string name     = CommonTools.GetKeyValue(form, "loginName");
            string password = CommonTools.GetKeyValue(form, "passWord");

            #endregion

            //保存个人登录信息
            FormsAuthentication.RedirectFromLoginPage(m_emp.EmployeeID.ToString(), false);

            //写入登录日志
            LoginLog(m_emp);

            //保存Session
            UserEmployee user = new UserEmployee();
            user.EmployeeId   = m_emp.EmployeeID;
            user.LoginName    = m_emp.LoginName;
            user.EmployeeName = m_emp.EmployeeName;

            Session["UserInfo"] = user;

            //html页面验证Cookie是否已经登录(/Script/PublicCommon.js)
            StringControl.DeleteCookie("Login");

            HttpCookie cookie = new HttpCookie("Login");
            cookie.Values.Add("EmpId", user.EmployeeId.ToString());
            cookie.Expires = System.DateTime.Now.AddDays(7);
            HttpContext.Current.Response.Cookies.Add(cookie);

            WebService.Login login = new WebService.Login();
            login.SaveLoginCookie(loginName, passwords, IsCheck);
        }
        public ActionResult UpdateKendoGridEmp(string models)
        {
            IList <UserModel> objName = new JavaScriptSerializer().Deserialize <IList <UserModel> >(models);
            UserEmployee      uemp    = new UserEmployee();

            uemp.Id       = objName[0].Id;
            uemp.Username = objName[0].UserName;

            UserServices.Update(uemp, uemp.Id);
            return(Json(uemp));
        }
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserEmployee userEmployee = db.UserEmployees.Find(id);

            if (userEmployee == null)
            {
                return(HttpNotFound());
            }
            return(View(userEmployee));
        }
Beispiel #7
0
        public async Task <Quiz> CreateNewQuiz(int empId, int userId)
        {
            UserEmployee userEmployee = await _context.UserEmployee.FirstOrDefaultAsync(x => x.EmployeeId == empId && x.UserId == userId);

            if (userEmployee == null)
            {
                throw ExceptionFactory.SoftException(ExceptionEnum.EmployeeIsNotYours, "Employee is not yours");
            }

            DateTime     currentTime  = DateTime.Now;
            Subscription subscription = await _context.Subscription.Include(x => x.Type).FirstOrDefaultAsync(x =>
                                                                                                             x.BeginDateTime <= currentTime && x.EndDateTime >= currentTime && x.UserId == userId);

            if (subscription == null)
            {
                throw ExceptionFactory.SoftException(ExceptionEnum.SubscriptionNotFound, "Subscription not found");
            }

            int quizzesFromThisSubscriptionCount = await _context.UserQuiz.Include(x => x.Quiz)
                                                   .Where(x => x.UserId == userId).Select(x => x.Quiz).Where(x =>
                                                                                                             x.CreateDateTime >= subscription.BeginDateTime && x.CreateDateTime <= subscription.EndDateTime)
                                                   .CountAsync();

            if (quizzesFromThisSubscriptionCount >= subscription.Type.AvailableTestAmount)
            {
                throw ExceptionFactory.SoftException(ExceptionEnum.ExceededMaximumTests,
                                                     $"Exceeded the maximum number of tests for the current subscription, SubscriptionId={subscription.Id}");
            }

            string quizId = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

            Quiz newQuiz = new Quiz {
                StatusId = 1, CreateDateTime = currentTime, AddressKey = quizId
            };
            await _context.Quiz.AddAsync(newQuiz);

            await _context.SaveChangesAsync();

            await _context.UserQuiz.AddAsync(new UserQuiz
            {
                QuizId     = newQuiz.Id,
                UserId     = userId,
                EmployeeId = empId,
            });

            await _context.SaveChangesAsync();

            return(await _context.Quiz.Include(x => x.Status).FirstOrDefaultAsync(x => x.Id == newQuiz.Id));
        }
        public async Task <Employee?> GetEmployee(int empId, int userId)
        {
            UserEmployee userEmployee = await _context.UserEmployee.FirstOrDefaultAsync(x => x.EmployeeId == empId && x.UserId == userId);

            if (userEmployee != null)
            {
                return(await _context.Employee.Include(x => x.UserQuizzes).ThenInclude(x => x.Quiz)
                       .ThenInclude(x => x.Status).Include(x => x.UserQuizzes).ThenInclude(x => x.Quiz)
                       .ThenInclude(x => x.Questions).ThenInclude(x => x.UserAnswers)
                       .Include(x => x.Avatar)
                       .Include(x => x.Resume)
                       .FirstOrDefaultAsync(x => x.Id == empId));
            }
            return(null);
        }
        public async Task <Employee> EditEmployee(Employee editEmp, int empId, int userId)
        {
            UserEmployee userEmployee = await _context.UserEmployee.FirstOrDefaultAsync(x => x.EmployeeId == empId && x.UserId == userId);

            if (userEmployee == null)
            {
                throw ExceptionFactory.SoftException(ExceptionEnum.EditedUserIsNotYours, "Edited user is not yours");
            }

            if (editEmp.AvatarId != null)
            {
                var avatar = await _context.Avatar.FirstOrDefaultAsync(x => x.Id == editEmp.AvatarId);

                if (avatar == null)
                {
                    throw ExceptionFactory.SoftException(ExceptionEnum.AvatarRecordDoesntExist, "");
                }
            }

            if (editEmp.ResumeId != null)
            {
                var resume = await _context.Resume.FirstOrDefaultAsync(x => x.Id == editEmp.ResumeId);

                if (resume == null)
                {
                    throw ExceptionFactory.SoftException(ExceptionEnum.ResumeRecordDoesntExist, "");
                }
            }

            Employee emp = await _context.Employee
                           .FirstOrDefaultAsync(x => x.Id == empId);

            _mapper.Map(editEmp, emp);

            emp.UserEmployees = new List <UserEmployee> {
                userEmployee
            };
            emp.Avatar = await _context.Avatar.FirstOrDefaultAsync(x => x.Id == editEmp.AvatarId);

            emp.Resume = await _context.Resume.FirstOrDefaultAsync(x => x.Id == editEmp.ResumeId);

            await _context.SaveChangesAsync();

            return(await _context.Employee
                   .Include(x => x.Avatar)
                   .Include(x => x.Resume)
                   .FirstOrDefaultAsync(x => x.Id == empId));
        }
 public ActionResult Edit(UserEmployee userEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userEmployee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag
     .EducationQualificationID = new SelectList(db.EducationQualifications, "ID", "Level", userEmployee.EducationQualificationID);
     ViewBag
     .GenderID = new SelectList(db.Genders, "ID", "GenderType", userEmployee.GenderID);
     ViewBag
     .MaritalStatusID = new SelectList(db.MaritalStatuss, "ID", "Status", userEmployee.MaritalStatusID);
     return(View(userEmployee));
 }
Beispiel #11
0
        //public async Task<ActionResult> Edit([Bind(Include = "UserID,Name,UserName,Email,Password,PhoneNumber,RoleID,Status,Image,TimeStamp")] User user)
        public async Task <ActionResult> Edit([Bind(Include = "user,employee")] UserEmployee ue)
        {
            if (ModelState.IsValid)
            {
                //putting RoleID of accountant in User
                var role = db.Roles.Where(x => x.RoleName == "Accountant").FirstOrDefault();
                ue.user.RoleID              = role.RoleID;
                ue.employee.UserID          = ue.user.UserID;
                db.Entry(ue.employee).State = EntityState.Modified;
                db.Entry(ue.user).State     = EntityState.Modified;

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.RoleID = new SelectList(db.Roles.Where(x => x.RoleID == 2), "RoleID", "RoleName", ue.user.RoleID);
            return(View(ue));
        }
Beispiel #12
0
        public async Task <ActionResult> Create([Bind(Include = "user,employee")] UserEmployee ue)
        {
            if (ModelState.IsValid)
            {
                //putting RoleID of Teacher in User
                var role = db.Roles.Where(x => x.RoleName == "Teacher").FirstOrDefault();
                ue.user.RoleID = role.RoleID;
                //
                ue.employee.UserID = ue.user.UserID;
                db.Users.Add(ue.user);
                db.Employees.Add(ue.employee);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.RoleID = new SelectList(db.Roles.Where(x => x.RoleID == 3), "RoleID", "RoleName", ue.user.RoleID);
            return(View(ue));
        }
        public async Task <Employee> AddEmployee(Employee newEmp, int userId)
        {
            if (newEmp.AvatarId != null)
            {
                var avatar = await _context.Avatar.FirstOrDefaultAsync(x => x.Id == newEmp.AvatarId);

                if (avatar == null)
                {
                    throw ExceptionFactory.SoftException(ExceptionEnum.AvatarRecordDoesntExist, "");
                }

                newEmp.Avatar = avatar;
            }

            if (newEmp.ResumeId != null)
            {
                var resume = await _context.Resume.FirstOrDefaultAsync(x => x.Id == newEmp.ResumeId);

                if (resume == null)
                {
                    throw ExceptionFactory.SoftException(ExceptionEnum.ResumeRecordDoesntExist, "");
                }

                newEmp.Resume = resume;
            }

            await _context.Employee.AddAsync(newEmp);

            await _context.SaveChangesAsync();

            UserEmployee ue = new UserEmployee()
            {
                UserId     = userId,
                EmployeeId = newEmp.Id,
            };

            await _context.UserEmployee.AddAsync(ue);

            await _context.SaveChangesAsync();


            return(newEmp);
        }
Beispiel #14
0
        // GET: Accountants/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User user = await db.Users.FindAsync(id);

            Employee emp = await db.Employees.SingleOrDefaultAsync(x => x.UserID == id);

            UserEmployee ue = new UserEmployee();

            ue.user     = user;
            ue.employee = emp;
            if (user == null && emp == null)
            {
                return(HttpNotFound());
            }
            return(View(ue));
        }
Beispiel #15
0
        // GET: Accountants/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User user = await db.Users.FindAsync(id);

            Employee emp = await db.Employees.Where(x => x.UserID == id).FirstOrDefaultAsync();

            if (user == null)
            {
                return(HttpNotFound());
            }
            UserEmployee ue = new UserEmployee();

            ue.user        = user;
            ue.employee    = emp;
            ViewBag.RoleID = new SelectList(db.Roles.Where(x => x.RoleID == 2), "RoleID", "RoleName", ue.user.RoleID);
            return(View(ue));
        }
        // GET: UserEmployees/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserEmployee userEmployee = db
                                        .UserEmployees
                                        .Find(id);

            if (userEmployee == null)
            {
                return(HttpNotFound());
            }
            ViewBag
            .EducationQualificationID = new SelectList(db.EducationQualifications, "ID", "Level", userEmployee.EducationQualificationID);
            ViewBag
            .GenderID = new SelectList(db.Genders, "ID", "GenderType", userEmployee.GenderID);
            ViewBag
            .MaritalStatusID = new SelectList(db.MaritalStatuss, "ID", "Status", userEmployee.MaritalStatusID);
            return(View(userEmployee));
        }
Beispiel #17
0
        public void AddUser()
        {
            var useremp = new UserEmployee()
            {
                Name     = "Test Receiptionist",
                Username = "******",
                Password = "******",
                BranchId = 1
            };

            UserEmp.Insert(useremp);
            UserAddresses.Insert(new Address
            {
                UserEmployeeId = useremp.Id,
                UserTypeId     = 3,
                ContactNo      = "0300-689654",
                Email          = "*****@*****.**",
                GenderId       = 1,
                Qualification  = "MBA",
                AddressDetail  = "H block test address karachi",
                CNIC           = "42101-testreceiptionist"
            });
        }
        public static string AssignUserIdToEmpId(int empId, string userId)
        {
            string        isSaved = "true";
            SetupEntities db      = new SetupEntities();
            UserEmployee  userEmp = new UserEmployee()
            {
                EmpId  = empId,
                UserId = userId
            };

            db.UserEmployees.Add(userEmp);

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                isSaved = "false" + ex.Message;
                throw;
            }

            return(isSaved);
        }
Beispiel #19
0
        public void GeneratePatientReport(List <PatientReportModel> model, Refer ReferDoctor, Patient PatientInfo, UserEmployee PatientDoctor, string BranchName)
        {
            //StreamWriter sq = new StreamWriter(Server.MapPath("/images/") + "log.txt");
            //sq.Close();
            //StreamWriter sw = new StreamWriter(Server.MapPath("/images/") + "log.txt");
            //sw.WriteLine("patient report method start....");
            string filename = "Report-" + PatientInfo.Id + ".pdf";

            if (!System.IO.File.Exists(Request.MapPath("/PatientsReport/") + filename))
            {
                var path = Server.MapPath("/images/");
                // sw.WriteLine("condition true of patient report. file doesn't exist..");
                // sw.WriteLine("class going to instantiate report.");
                PatientReport Report = new PatientReport(path, model, ReferDoctor, PatientInfo, PatientDoctor, BranchName);
                //sw.WriteLine("report class instantiated");
                PdfDocument pdf = Report.CreateDocument();
                //sw.WriteLine("report is created.");

                pdf.Save(Server.MapPath("/PatientsReport/") + filename);
                //sw.WriteLine("report saved successfully");
                //    System.IO.FileInfo fi=new System.IO.FileInfo(Request.MapPath("/PatientsReport/") + filename);
                //    fi.Delete();
            }
            // ...and start a viewer.
            //sw.WriteLine("report process start.");
            Process.Start(Server.MapPath("/PatientsReport/") + filename);
            //sw.WriteLine("report PROCESS END");
            //sw.Close();
        }
Beispiel #20
0
 public void Update(UserEmployee Emp, int id)
 {
     UserEmp.Update(Emp, id);
 }
Beispiel #21
0
        public void GeneratePatientReport(List <PatientReportModel> model, Refer ReferDoctor, Patient PatientInfo, UserEmployee PatientDoctor, string BranchName)
        {
            string filename = "Report-" + PatientInfo.Id + ".pdf";

            if (!System.IO.File.Exists(Request.MapPath("/PatientsReport/") + filename))
            {
                var Path = Server.MapPath("/images/");

                PatientReport Report = new PatientReport(Path, model, ReferDoctor, PatientInfo, PatientDoctor, BranchName);

                PdfDocument pdf = Report.CreateDocument();


                pdf.Save(Server.MapPath("/PatientsReport/") + filename);
                //    System.IO.FileInfo fi=new System.IO.FileInfo(Request.MapPath("/PatientsReport/") + filename);
                //    fi.Delete();
            }
            // ...and start a viewer.
            Process.Start(Server.MapPath("/PatientsReport/") + filename);
        }
Beispiel #22
0
        //use this register method for every user registeration
        //example
        // UserEmployee emp=new UserEmployee()
        //{
        //    Name = "Hassan Reciptionist",
        //    Username = "******",
        //    Password = "******",
        //    BranchId = 1                          //Note:: branchId should be get from Form Ui
        //};
        // Address addr = new Address()
        //{
        //    UserTypeId = 4,                       //Note:: userTypeId should be obtained from UI Form
        //    ContactNo = "0345-6789654",
        //    Email = "*****@*****.**",
        //    GenderId = 1,                         //Note:: GenderId should be obtained from UI Form
        //    Qualification = "MBA",
        //    AddressDetail = "H block test address karachi",
        //    CNIC = "42101-test"
        //});
        #endregion

        public void RegisterUser(UserEmployee emp, Address empAddr)
        {
            UserEmp.Insert(emp);
            empAddr.UserEmployeeId = emp.Id;
            UserAddresses.Insert(empAddr);
        }
        public ActionResult Create(UserEmployeeViewModel userVM)
        {
            UserEmployee employee = new UserEmployee();

            if (ModelState.IsValid)
            {
                employee.ID = Guid.NewGuid();

                employee.FirstName = userVM.FirstName;

                employee.LastName = userVM.LastName;

                employee.Email = userVM.Email;

                employee.DOB = userVM.DOB;

                employee.NumberOfChildren = userVM.NumberOfChildren;

                employee.AnnualSalary = 0;

                employee.GenderID = userVM.GenderID;

                employee.EducationQualificationID = db
                                                    .EducationQualifications
                                                    .Where(r => r.Level.Contains("B.Sc"))
                                                    .Single().ID;

                employee.MaritalStatusID = userVM.MaritalStatusID;

                employee.Active = false;

                employee.DateOfEmployment = DateTime.Now;

                employee.NameOfInstitution = userVM.NameOfInstitution;

                employee.Position = userVM.Position;

                employee.PromotedAt = DateTime.Now;
                try
                {
                    //Create a user account in the AspNetUser table
                    var userid = Register(new RegisterViewModel()
                    {
                        Email           = userVM.Email,
                        Password        = userVM.Password,
                        ConfirmPassword = userVM.ConfirmPassword
                    });


                    if (!string.IsNullOrWhiteSpace(userid))
                    {
                        employee.RegistrationID = userid;
                        db.UserEmployees.Add(employee);
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ModelState
                    .AddModelError("", "Unable to create user. Please contact administrator" + e.Message);
                }

                return(RedirectToAction("Welcome"));
            }


            ViewBag
            .GenderID = new SelectList(db.Genders, "ID", "GenderType");
            ViewBag
            .MaritalStatusID = new SelectList(db.MaritalStatuss, "ID", "Status");
            ViewBag
            .EductionQualificationID = new SelectList(db.EducationQualifications, "ID", "Level");
            return(View(employee));
        }