Beispiel #1
0
 public ActionResult ChangePassword(ViewModels.changePassword data)
 {
     if (data.Password != null)
     {
         if (data.Password == data.confirmPassword)
         {
             String username = "";
             if (!AccountManager.IsUserInRole("student"))
             {
                 int id = Int16.Parse(AccountManager.getId());
                 username = db.Teachers.Find(id).username;
             }
             else
             {
                 String rollNo = AccountManager.getId();
                 username = db.Students.Find(rollNo).username;
             }
             Userinfo user = db.Userinfoes.Find(username);
             user.passwordHash = Cryptography.getMD5(data.Password);
             db.Set <Userinfo>().AddOrUpdate(user);
             db.SaveChanges();
             return(RedirectToAction("index"));
         }
         else
         {
             ViewBag.warning = "Password Not Matched";
             return(View());
         }
     }
     else
     {
         ViewBag.warning = "Password can not be null";
         return(View());
     }
 }
        //
        // GET: /AutoUI/TaskNoticeChang

        protected override void AfterGetData(DataTable dt, bool isNew, string upperVersionID)
        {
            if (isNew)
            {
                string ProjectInfoID = GetQueryString("ProjectInfoID");
                if (!string.IsNullOrEmpty(ProjectInfoID))
                {
                    int             maxNumber   = 0;
                    ProjectEntities epcentity   = FormulaHelper.GetEntities <ProjectEntities>();
                    var             ProjectInfo = epcentity.Set <T_CP_TaskNotice>().FirstOrDefault(a => a.ID == ProjectInfoID);
                    var             Projects    = epcentity.Set <T_CP_TaskNoticeChange>().Where(c => c.ProjectInfoID == ProjectInfoID);

                    if (Projects != null && Projects.Count() > 0)
                    {
                        maxNumber = Projects.ToList().Max(c => Convert.ToInt32(c.VersionNumber));
                    }
                    maxNumber++;

                    if (ProjectInfo != null)
                    {
                        Type    tp  = ProjectInfo.GetType();
                        var     ps  = tp.GetProperties();
                        DataRow dtr = dt.Rows[0];
                        foreach (PropertyInfo item in ps)
                        {
                            string cname = item.Name;
                            string type  = item.PropertyType.Name;
                            if (type != "ICollection`1" && cname != "ProjectInfoID" && cname != "VersionNumber" && dt.Columns.Contains(cname))
                            {
                                object value = item.GetValue(ProjectInfo, null);
                                if (cname == "ID")
                                {
                                    dtr.SetField("ProjectInfoID", value);
                                }
                                else
                                {
                                    dtr.SetField(cname, value);
                                }
                            }
                        }
                        dtr.SetField("VersionNumber", maxNumber);
                    }
                }
            }
        }
Beispiel #3
0
        //supplementary method (not declared in interface)
        private void SaveDisbursementDetailsIntoDB(List <DisbursementDetail> tempDisbursementDetailList)
        {
            var q = tempDisbursementDetailList
                    .GroupBy(ac => new
            {
                ac.DisbursementListId,
                ac.ItemNo,
            })
                    .Select(ac => new DisbursementDetail
            {
                DisbursementListId = (int)ac.Key.DisbursementListId,
                ItemNo             = ac.Key.ItemNo,
                PreparedQuantity   = ac.Sum(acs => acs.PreparedQuantity),
                DeliveredQuantity  = ac.Sum(acs => acs.DeliveredQuantity)
            });


            foreach (DisbursementDetail newDisbursementDetail in q.ToList())
            {
                db.Set(typeof(DisbursementDetail)).Attach(newDisbursementDetail);
                db.DisbursementDetails.Add(newDisbursementDetail);
                db.SaveChanges();
            }
        }
Beispiel #4
0
        public virtual List <S_W_Activity> StartAuditFlow(T_AE_Audit auditForm, string auditFormUrl, List <S_E_Product> products, string wbsID)
        {
            var wbs = instanceEnitites.S_W_WBS.SingleOrDefault(d => d.ID == wbsID);

            if (wbs == null)
            {
                throw new Exception("未能找到ID为【" + wbsID + "】的WBS对象,无法执行校审");
            }

            var project = instanceEnitites.S_I_ProjectInfo.SingleOrDefault(d => d.ID == wbs.ProjectInfoID);

            if (project == null)
            {
                throw new Exception("未能找到ID为【" + wbs.ProjectInfoID + "】的项目,无法执行校审");
            }

            //为校审单设置默认值
            SetAuditFormInfo(auditForm, wbs, project);

            //生成流程步骤及启动参数
            var startParam = GetAuditFlowStartParam(auditForm, auditFormUrl, products, wbs, project);

            var service = AuditFlowServiceGenretor.CreateService();
            List <S_W_Activity> list = service.StartAuditFlow(startParam);

            //设置校审单状态
            auditForm.State = list[0].ActivityKey;
            var taskWork = wbs.S_W_TaskWork.FirstOrDefault();

            //设置校审人员到表单
            this.SetAuditUsers(auditForm, startParam.DefSteps, taskWork.DesignerUserID, taskWork.DesignerUserName);
            //设置成果属性
            this.SetProductProperty(products, auditForm.ID, auditForm.State);
            instanceEnitites.T_AE_Audit.Add(auditForm);
            var designAct = list[0];

            if (startParam.ExecNext)
            {
                var actType = ActivityType.Design.ToString();
                designAct = instanceEnitites.Set <S_W_Activity>().FirstOrDefault(c => c.ActivityKey == actType && c.BusniessID == designAct.BusniessID);
            }
            SetAuditSignUser(designAct, products);

            return(list);
        }
Beispiel #5
0
        public ActionResult Create(GuardianViewModel guardian)
        {
            if (ModelState.IsValid)
            {
                Guardian obj = new Guardian();
                obj.guardianName = guardian.name;
                obj.mobileNumber = guardian.mobileNumber;
                obj.relationship = guardian.relationship;
                db.Guardians.Add(obj);
                db.SaveChanges();
                int     GuardianID = db.Guardians.Max(o => o.guardianID);
                Student std        = db.Students.Find(guardian.rollNo);
                std.guardianID = GuardianID;
                db.Set <Student>().AddOrUpdate(std);
                db.SaveChanges();
                return(RedirectToAction("index", "Students"));
            }

            return(View(guardian));
        }
        protected override void OnFlowEnd(T_CP_TaskNoticeChange ProjectInof, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing)
        {
            ProjectEntities epcentity     = FormulaHelper.GetEntities <ProjectEntities>();
            string          ProjectInfoID = ProjectInof.ProjectInfoID;
            var             model         = epcentity.Set <T_CP_TaskNotice>().FirstOrDefault(a => a.ID == ProjectInfoID);

            if (model != null)
            {
                model.FirstDesignManager         = ProjectInof.FirstDesignManager;
                model.FirstDesignManagerName     = ProjectInof.FirstDesignManagerName;
                model.FirstDesignManagerDept     = ProjectInof.FirstDesignManagerDept;
                model.FirstDesignManagerDeptName = ProjectInof.FirstDesignManagerDeptName;
                model.SecondDesignManager        = ProjectInof.SecondDesignManager;
                model.SecondDesignManagerName    = ProjectInof.SecondDesignManagerName;
                model.ThirdDesignManager         = ProjectInof.ThirdDesignManager;
                model.ThirdDesignManagerName     = ProjectInof.ThirdDesignManagerName;
                model.DesignManagerAssistant     = ProjectInof.DesignManagerAssistant;
                model.DesignManagerAssistantName = ProjectInof.DesignManagerAssistantName;
                epcentity.SaveChanges();
            }
        }
Beispiel #7
0
        public async Task <ActionResult> Edit(StudentViewModel student, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                string  un  = "";
                Student std = db.Students.Find(student.rollNo);
                if (std == null)
                {
                    Userinfo user = new Userinfo();

                    if (db.Userinfoes.Find(student.username) != null)
                    {
                        ViewBag.userMsg   = "Username already exist.";
                        ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);

                        return(View(student));
                    }
                    else if (student.password == null)
                    {
                        ViewBag.pswMsg    = "Password can not be null";
                        ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);

                        return(View(student));
                    }
                    else if (student.password != student.confirmPassword)
                    {
                        ViewBag.pswMsg    = "Password are not same";
                        ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);

                        return(View(student));
                    }
                    user.username     = student.username;
                    user.passwordHash = Cryptography.getMD5(student.password);
                    user.token        = Cryptography.getMD5(student.username) + Cryptography.getMD5(student.password);
                    user.role         = "student";
                    user.email        = student.email;

                    if (upload != null && upload.ContentLength > 0)
                    {
                        string path = Path.Combine(Server.MapPath("~/Images"),
                                                   Path.GetFileName(student.rollNo + ".jpg"));
                        upload.SaveAs(path);
                        user.imagePath = "~/Images/" + student.rollNo + ".jpg";
                    }

                    db.Userinfoes.Add(user);
                    un = user.username;
                }
                else
                {
                    Userinfo user = db.Userinfoes.Find(db.Students.Find(student.rollNo).username);
                    if (student.password != null)
                    {
                        if (student.password != student.confirmPassword)
                        {
                            ViewBag.pswMsg    = "Password are not same";
                            ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);

                            return(View(student));
                        }
                        user.passwordHash = Cryptography.getMD5(student.password);
                        user.token        = Cryptography.getMD5(user.username) + Cryptography.getMD5(student.password);
                    }
                    user.email = student.email;

                    if (upload != null && upload.ContentLength > 0)
                    {
                        string path = Path.Combine(Server.MapPath("~/Images"),
                                                   Path.GetFileName(student.rollNo + ".jpg"));
                        upload.SaveAs(path);
                        user.imagePath = "~/Images/" + student.rollNo + ".jpg";
                    }
                    un = user.username;

                    db.Set <Userinfo>().AddOrUpdate(user);

                    db.SaveChanges();
                    //  db.Entry(user).State = EntityState.Modified;
                }
                std.rollNo     = student.rollNo;
                std.fullName   = student.firstName;
                std.username   = un;
                std.fatherName = student.fatherName;
                std.sessionID  = student.sessionID;
                db.Set <Student>().AddOrUpdate(std);
                //db.Entry(std).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.sessionID = new SelectList(db.Sessions, "sessionID", "name", student.sessionID);
            ViewBag.username  = new SelectList(db.Userinfoes, "username", "password", student.username);
            return(View(student));
        }
Beispiel #8
0
 public GenericRepository(ProjectEntities context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
Beispiel #9
0
 public void Add(T entityToAdd)
 {
     _context.Set <T>().Add(entityToAdd);
 }