Exemplo n.º 1
0
        public ActionResult Create(Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Designation,Salary")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employee.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
Exemplo n.º 3
0
        public ActionResult Create(IECA_AuditOffice ieca_auditoffice)
        {
            if (ModelState.IsValid)
            {
                db.IECA_AuditOffice.AddObject(ieca_auditoffice);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AuditOfficeID = new SelectList(db.Office_Office, "OfficeID", "Name", ieca_auditoffice.AuditOfficeID);
            return(View(ieca_auditoffice));
        }
        public ActionResult Index(Homemodel ob)
        {
            var Q = obj.EmployeeDetails.Where(M => M.empid == ob.empdt.empid).FirstOrDefault();

            Q.Name = ob.empdt.Name;
            Q.Addr = ob.empdt.Addr;
            Q.Phno = ob.empdt.Phno;
            Q.Sal  = ob.empdt.Sal;
            Q.City = ob.empdt.City;
            Q.Gen  = ob.empdt.Gen;
            Q.Dep  = ob.empdt.Dep;
            Q.Cmp  = ob.empdt.Cmp;
            obj.SaveChanges();
            ViewBag.list = obj.EmployeeDetails.ToList();
            return(View());
        }
Exemplo n.º 5
0
        public ActionResult ForgotPassword(string EmailID)
        {
            //Verify Email ID
            //Generate Reset password link
            //Send Email
            string message = "";
            bool   status  = false;

            using (OfficeEntities dc = new OfficeEntities())
            {
                var account = dc.Users.Where(a => a.Email == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.Email, resetCode, "ResetPassword");
                    account.ResetPassword = resetCode;
                    //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property
                    //in our model class in part 1
                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset password link has been sent to your email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
Exemplo n.º 6
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (OfficeEntities dc = new OfficeEntities())
                {
                    var user = dc.Users.Where(a => a.ResetPassword == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.Password      = Crypto.Hash(model.NewPassword);
                        user.ResetPassword = "";
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New password updated successfully";
                    }
                }
            }
            else
            {
                message = "Something invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
Exemplo n.º 7
0
        public ActionResult CreateEmployee(Employee employee)
        {
            //Employee employee = new Employee();
            //employee.Name = formCollection["name"];
            //employee.Age = int.Parse(string.IsNullOrEmpty(formCollection["age"]) ? "0" : formCollection["age"]);
            //employee.Gender = formCollection["gender"];
            //employee.DepartmentId = int.Parse(string.IsNullOrEmpty(formCollection["departmentId"]) ? "0" : formCollection["departmentId"]);
            //employee.Designation = formCollection["designation"];
            //employee.Address = formCollection["address"];

            try
            {
                OfficeEntities oe = new OfficeEntities();
                //oe.Employees.Add(employee);
                oe.Entry(employee).State = System.Data.Entity.EntityState.Added;
                oe.SaveChanges();

                TempData["success"] = "Record inserted.";
            }
            catch (Exception ex)
            {
                Response.StatusCode = 500;
                TempData["success"] = "Something went wrong.";
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
 public JsonResult SaveRegistration(string Empide, string Nm, string Addr, string Ph, string Sal, string City, string Gen, string Dept, string Cmp)
 {
     int salary = Convert.ToInt32(Sal);
     obj.EmployeeDetails.Add(new EmployeeDetails { empid=Empide,Name=Nm,Addr=Addr,Phno=Ph,Sal=salary,City=City,Gen=Gen,Dep=Dept,Cmp=Cmp});
     obj.SaveChanges();
     return Json("Success", JsonRequestBehavior.AllowGet);
 }
 public ActionResult Signup(User model)
 {
     using (var context = new OfficeEntities())
     {
         context.User.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("Login"));
 }
Exemplo n.º 10
0
        public ActionResult Register(User Acc)
        {
            using (var c = new OfficeEntities())
            {
                c.Users.Add(Acc);
                c.SaveChanges();
            }

            return(RedirectToAction("Login"));
        }
Exemplo n.º 11
0
        public ActionResult EditEmployee(Employee model)
        {
            OfficeEntities oe = new OfficeEntities();

            oe.Entry(model).State = System.Data.Entity.EntityState.Modified;
            oe.SaveChanges();

            TempData["msg"] = "Successfully updated";

            return(RedirectToAction("Index"));
        }
Exemplo n.º 12
0
        public ActionResult DeleteEmployee(int id)
        {
            OfficeEntities oe    = new OfficeEntities();
            Employee       model = oe.Employees.Single(emp => emp.Id == id);

            oe.Entry(model).State = System.Data.Entity.EntityState.Deleted;
            oe.SaveChanges();

            TempData["msg"] = "Successfully updated";

            return(RedirectToAction("Index"));
        }
        public JsonResult UpdateUserDetails(string Mailid, string Nm, string Adr, string Ph, string Pin, string City, string Gen)
        {
            var Q = ob.Registration.Where(M => M.Mailid == Mailid).FirstOrDefault();

            Q.Name = Nm;
            Q.Adr  = Adr;
            Q.Phno = Ph;
            Q.Pin  = Pin;
            Q.City = City;
            Q.Gen  = Gen;
            ob.SaveChanges();
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
 public ActionResult Signup(Users model)
 {
     using (var context = new OfficeEntities())
     {
         if (model.Username == null && model.Password == null)
         {
             return(View());
         }
         else
         {
             context.Users.Add(model);
             context.SaveChanges();
         }
     }
     return(RedirectToAction("login"));
 }
Exemplo n.º 15
0
 public ActionResult Index(Homemodel ob)
 {
     try
     {
         obj.EmployeeDetails.Add(new EmployeeDetails {
             empid = ob.empdt.empid, Name = ob.empdt.Name, Addr = ob.empdt.Addr, Phno = ob.empdt.Phno, Sal = ob.empdt.Sal, City = ob.empdt.City, Gen = ob.empdt.Gen, Dep = ob.empdt.Dep, Cmp = ob.empdt.Cmp
         });
         obj.SaveChanges();
         ViewBag.msg = "Data Inert Successfull";
         ModelState.Clear();
     }
     catch (Exception ex)
     {
         ViewBag.msg = ex.Message;
     }
     return(View());
 }
Exemplo n.º 16
0
        public ActionResult EditEmployee(Employee employee)
        {
            //Employee employee = new Employee();
            //employee.Name = formCollection["name"];
            //employee.Age = int.Parse(string.IsNullOrEmpty(formCollection["age"]) ? "0" : formCollection["age"]);
            //employee.Gender = formCollection["gender"];
            //employee.DepartmentId = int.Parse(string.IsNullOrEmpty(formCollection["departmentId"]) ? "0" : formCollection["departmentId"]);
            //employee.Designation = formCollection["designation"];
            //employee.Address = formCollection["address"];

            OfficeEntities oe = new OfficeEntities();

            oe.Entry(employee).State = System.Data.Entity.EntityState.Modified;

            oe.SaveChanges();

            TempData["success"] = "Record updated.";

            return(RedirectToAction("Index"));
        }
Exemplo n.º 17
0
        public ActionResult CreateEmployee(CreateEmployeeModel model)
        {
            OfficeEntities oe = new OfficeEntities();

            if (model.employee.DepartmentId == null || model.employee.DepartmentId == 0)
            {
                ModelState.AddModelError("employee.DepartmentId", "Please select department");
            }

            if (ModelState.IsValid)
            {
                oe.Entry(model.employee).State = System.Data.Entity.EntityState.Added;
                oe.SaveChanges();

                TempData["msg"] = "Successfully added";

                return(RedirectToAction("Index"));
            }

            model.departments = oe.Departments.ToList();
            return(View(model));
        }
 public ActionResult SignUp(User model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             db.Users.Add(model);
             db.SaveChanges();
             FormsAuthentication.SetAuthCookie(model.Username, false);
             return(RedirectToAction("Index", "Employees"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError(string.Empty, ex.Message);
             return(View(model));
         }
     }
     else
     {
         ModelState.AddModelError("", "Error occurred");
         return(View(model));
     }
 }
Exemplo n.º 19
0
        public ActionResult Create([Bind(Include = "ID,leibie,shunxuhao,shouwenriqi,wenjianzihao,laiwendanwei,wenjianbiaoti,wenjianyaoqiu,banjieriqi,guidangjuanbie,banjietime")] BaowenMainTable baowenMainTable, string action)
        {
            ViewBag.leibie    = new SelectList(db.BaowenFileType, "类别", "说明");
            ViewBag.shunxuhao = baowenMainTable.shunxuhao;
            ViewBag.ID        = baowenMainTable.ID;
            List <SelectListItem> list = new List <SelectListItem> {
                new SelectListItem {
                    Text = "", Value = " "
                },
                new SelectListItem {
                    Text = "10:00", Value = "10:00"
                },
                new SelectListItem {
                    Text = "11:00", Value = "11:00"
                },
                new SelectListItem {
                    Text = "11:30", Value = "11:30"
                },
                new SelectListItem {
                    Text = "12:00", Value = "12:00"
                },
                new SelectListItem {
                    Text = "13:00", Value = "13:00"
                },
                new SelectListItem {
                    Text = "14:00", Value = "14:00"
                },
                new SelectListItem {
                    Text = "15:00", Value = "15:00"
                },
                new SelectListItem {
                    Text = "16:00", Value = "16:00"
                },
                new SelectListItem {
                    Text = "17:00", Value = "17:00"
                },
                new SelectListItem {
                    Text = "17:30", Value = "17:30"
                },
            };

            if (baowenMainTable.banjietime == "")
            {
                ViewBag.banjietime = new SelectList(list, "Value", "Text");
            }
            else
            {
                ViewBag.banjietime = new SelectList(list, "Value", "Text", baowenMainTable.banjietime.Trim());
            }
            if (action == "保存")
            {
                if (ModelState.IsValid)
                {
                    db.BaowenMainTable.Add(baowenMainTable);
                    db.SaveChanges();
                    Response.Write("<script>alert('已成功保存!');</script>");
                    ViewData["next"]     = false;
                    ViewData["chulidan"] = false;
                }
            }
            if (action == "添加下一条")
            {
                int Id = int.Parse(Request.Form["ID"]);
                var ds = from ad in db.BaowenMainTable
                         where ad.ID == Id
                         select ad;
                if (ds.Count() == 0)
                {
                    Response.Write("<script>alert('请先提交保存!');</script>");
                }
                else
                {
                    return(RedirectToAction("Create"));
                }
            }
            if (action == "处理单")
            {
                int Id = int.Parse(Request.Form["ID"]);
                var ds = from ad in db.BaowenMainTable
                         where ad.ID == Id
                         select ad;
                if (ds.Count() == 0)
                {
                    Response.Write("<script>alert('请先提交保存!');</script>");
                }
                else
                {
                    return(RedirectToAction("chulidan", new { format = "PDF", id = Id }));
                }
            }
            return(View(baowenMainTable));
        }
Exemplo n.º 20
0
        public ActionResult HeJuFeiYongEdit(string action, [Bind(Include = "ID,twoCentiCnt,thrCentiCnt,fourCentiCnt,fiveCentiCnt,coverCnt,catalogueCnt,proformaCnt,DepartName,submitDate,submitPerson,archiveBoxFee,archiveCataLogFee,singleBoxFee,singleCatalogFee,seqNo")] ArchivesContainer archivesContainer, Charger charger)
        {
            long id     = long.Parse(Request.Form["ID"]);
            var  charge = from ad in ab.Charger
                          where ad.searchNo == id
                          select ad;
            var charge1 = charge.First();

            ViewBag.total    = charge1.totalExpense;
            ViewBag.Selected = new SelectList(ab.DepartmentCode, "value", "Text", charge1.fromDepartment);
            List <SelectListItem> list3 = new List <SelectListItem> {
                new SelectListItem {
                    Text = "转向财务科", Value = "1"
                },
                new SelectListItem {
                    Text = "转向复印室", Value = "0"
                },
            };

            ViewBag.Selected1 = new SelectList(list3, "Value", "Text", charge1.whereTransfer);
            //Charger charger = new Charger();
            long   max_chargerID = ab.Charger.Max(d => d.ID);
            long   newchargerID  = max_chargerID + 1;
            string totle         = Request.Form["total"];
            string zhuanxiang    = Request.Form["Selected1"];
            string data          = Request.Form["submitDate"];
            string no            = data.Replace("-", "");

            if (action == "生成最大收费编号")
            {
                if (data.Contains("-"))
                {
                    if (ModelState.IsValid)
                    {
                        var list1 = from ad in db.ArchivesContainer
                                    where ad.seqNo.Contains(no)
                                    orderby ad.ID descending
                                    select ad;
                        if (list1.Count() != 0)
                        {
                            var  list      = list1.First();
                            long max_seqno = long.Parse(list.seqNo);
                            long seqno     = max_seqno + 1;
                            archivesContainer.seqNo = seqno.ToString();
                            ViewBag.seqNo           = archivesContainer.seqNo;
                            ViewBag.totle           = charge1.totalExpense;
                            ViewBag.twoCentiCnt     = archivesContainer.twoCentiCnt;
                            ViewBag.thrCentiCnt     = archivesContainer.thrCentiCnt;
                            ViewBag.fourCentiCnt    = archivesContainer.fourCentiCnt;
                            ViewBag.fiveCentiCnt    = archivesContainer.fiveCentiCnt;
                            ViewBag.coverCnt        = archivesContainer.coverCnt;
                            ViewBag.catalogueCnt    = archivesContainer.catalogueCnt;
                            ViewBag.proformaCnt     = archivesContainer.proformaCnt;
                        }
                        else
                        {
                            archivesContainer.seqNo = no + "001";
                            ViewBag.seqNo           = archivesContainer.seqNo;
                            ViewBag.totle           = charge1.totalExpense;
                            ViewBag.twoCentiCnt     = archivesContainer.twoCentiCnt;
                            ViewBag.thrCentiCnt     = archivesContainer.thrCentiCnt;
                            ViewBag.fourCentiCnt    = archivesContainer.fourCentiCnt;
                            ViewBag.fiveCentiCnt    = archivesContainer.fiveCentiCnt;
                            ViewBag.coverCnt        = archivesContainer.coverCnt;
                            ViewBag.catalogueCnt    = archivesContainer.catalogueCnt;
                            ViewBag.proformaCnt     = archivesContainer.proformaCnt;
                        }
                    }
                }
                else
                {
                    Response.Write("<script >alert('请选择提交时间');window.history.back();</script >");
                }
            }
            if (action == "保存")
            {
                if (ModelState.IsValid)
                {
                    string NO = Request.Form["seqNo"];
                    archivesContainer.seqNo = NO;
                    string person = Request.Form["Selected"];
                    archivesContainer.submitPerson    = person;
                    db.Entry(archivesContainer).State = EntityState.Modified;
                    db.SaveChanges();
                    charge1.searchNo        = archivesContainer.ID;
                    charge1.totalExpense    = decimal.Parse(totle);
                    charge1.unitName        = archivesContainer.DepartName;
                    charge1.chargeTime      = archivesContainer.submitDate;
                    charge1.seqNo           = archivesContainer.seqNo;
                    charge1.theoryExpense   = decimal.Parse(totle);
                    charge1.whereTransfer   = int.Parse(zhuanxiang);
                    ab.Entry(charge1).State = EntityState.Modified;
                    ab.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(archivesContainer));
        }
Exemplo n.º 21
0
 // کد ثبت کاربر
 public static int Insert(TblUser user)
 {
     db.TblUsers.Add(user);
     return(db.SaveChanges());
 }