コード例 #1
0
        public ActionResult Create(ProcessStep processstep)
        {
            if (ModelState.IsValid)
            {
                db.ProcessSteps.Add(processstep);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(processstep));
        }
コード例 #2
0
        public ActionResult Create(CustomerName customername)
        {
            if (ModelState.IsValid)
            {
                db.CustomerNames.Add(customername);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customername));
        }
コード例 #3
0
        public ActionResult Create(RoleMenu rolemenu)
        {
            if (ModelState.IsValid)
            {
                db.RoleMenu.Add(rolemenu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rolemenu));
        }
コード例 #4
0
        public ActionResult Create(ReturnType returntype)
        {
            if (ModelState.IsValid)
            {
                db.ReturnTypes.Add(returntype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(returntype));
        }
コード例 #5
0
        public ActionResult Create(IssueSource issuesource)
        {
            if (ModelState.IsValid)
            {
                db.IssueSources.Add(issuesource);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(issuesource));
        }
コード例 #6
0
        public ActionResult Create(PCBVendor pcbvendor)
        {
            if (ModelState.IsValid)
            {
                db.PCBVendor.Add(pcbvendor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pcbvendor));
        }
コード例 #7
0
        public ActionResult Create(TestPurpose testpurpose)
        {
            if (ModelState.IsValid)
            {
                db.TestPurposes.Add(testpurpose);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(testpurpose));
        }
コード例 #8
0
        public ActionResult Create(ProductStage productstage)
        {
            if (ModelState.IsValid)
            {
                db.ProductStage.Add(productstage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productstage));
        }
コード例 #9
0
        public ActionResult Create(TestItemMenu testitemmenu)
        {
            if (ModelState.IsValid)
            {
                db.TestItemMenu.Add(testitemmenu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(testitemmenu));
        }
コード例 #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            CERLDBContext  db             = new CERLDBContext();
            LabInformation labinformation = db.LabInformation.Find(id);

            db.LabInformation.Remove(labinformation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #11
0
        public ActionResult Create(CERLMenu cerlmenu)
        {
            string UserId = Method.GetLogonUserId(Session, this, User.Identity.Name.ToUpper());

            cerlmenu.cdt    = DateTime.Now;
            cerlmenu.udt    = DateTime.Now;
            cerlmenu.editor = UserId;
            ModelState.Remove("cdt");
            ModelState.Remove("udt");
            ModelState.Remove("editor");
            if (TryUpdateModel(cerlmenu, null, null, new string[] { "udt", "cdt", "editor" }))
            {
                db.CERLMenu.Add(cerlmenu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            InitDDLShow(null, "");
            return(View(cerlmenu));
        }
コード例 #12
0
 public ActionResult AddRoleMenu(int?RoleId, int?menuId)
 {
     if (RoleId.HasValue && menuId.HasValue)
     {
         int rId          = int.Parse(RoleId.ToString());
         int mId          = int.Parse(menuId.ToString());
         var currrolemenu = db.RoleMenu.Where(x => x.RoleId == rId && x.menuId == mId).Select(x => x.id);
         if (currrolemenu == null || currrolemenu.Count() == 0)
         {
             db.RoleMenu.Add(new RoleMenu()
             {
                 RoleId = int.Parse(RoleId.ToString()),
                 menuId = int.Parse(menuId.ToString())
             });
             db.SaveChanges();
         }
     }
     return(Redirect(Request.UrlReferrer.ToString()));
 }
コード例 #13
0
        public ActionResult Create(FormCollection fc, f_cerl f_cerl)
        {
            StringBuilder vchSet   = new StringBuilder();
            string        Editor   = Method.GetLogonUserId(Session, User.Identity.Name);
            string        State    = "10";
            int           FlowCode = 1001001;
            string        FormId   = System.Guid.NewGuid().ToString().ToUpper();

            vchSet.Append(Method.BuildXML(f_cerl.TestItem.ToString(), "TestItem"));
            vchSet.Append(Method.BuildXML(f_cerl.CustomerID.ToString(), "CustomerID"));
            vchSet.Append(Method.BuildXML(f_cerl.ProjectName, "ProjectName"));
            string CaseId = edb.FnGetCaseID(vchSet.ToString()).FirstOrDefault().CaseID;
            string UID    = edb.FnGetCaseID(vchSet.ToString()).FirstOrDefault().UID;

            f_cerl.fID       = FormId;
            f_cerl.FlowCode  = FlowCode;
            f_cerl.FormCode  = int.Parse(f_cerl.TestItem.ToString());
            f_cerl.CaseID    = CaseId;
            f_cerl.UID       = UID;
            f_cerl.State     = int.Parse(State);
            f_cerl.editor    = Editor;
            f_cerl.Applicant = Editor;
            f_cerl.cdt       = DateTime.Now;
            f_cerl.udt       = DateTime.Now;
            if (TryUpdateModel(f_cerl, "", fc.AllKeys, new string[] { "fID", "Manager", "FlowCode", "FormCode", "Applicant", "editor", "State", "udt", "cdt" }))
            {
                if (ModelState.IsValid)
                {
                    if (f_cerl.Manager == null)
                    {
                        f_cerl.Manager = "IEC970209"; // test Manager
                    }

                    var r = new List <attachFile>();
                    int i = 0;


                    foreach (string file in Request.Files)
                    {
                        HttpPostedFileBase hpf = Request.Files[i] as HttpPostedFileBase;
                        if (hpf.ContentLength == 0)
                        {
                            continue;
                        }

                        string   formId        = FormId;
                        string   state         = State;
                        string   filePath0     = Constant.UserFileDirectory + formId + @"\";
                        string   filePath      = Constant.UserFileDirectory + formId + @"\" + state + @"\";
                        FileInfo newinfo       = new FileInfo(hpf.FileName);
                        string   savedFileName = Path.Combine(filePath, Path.GetFileName(newinfo.Name));
                        if (!Directory.Exists(filePath0))
                        {
                            Directory.CreateDirectory(filePath0);
                        }

                        if (!Directory.Exists(filePath))
                        {
                            Directory.CreateDirectory(filePath);
                        }
                        hpf.SaveAs(savedFileName);

                        r.Add(new attachFile()
                        {
                            fID         = formId,
                            displayname = newinfo.Name,
                            fileName    = newinfo.Name,
                            Length      = hpf.ContentLength,
                            Type        = hpf.ContentType,
                            folderId    = state,
                            editor      = Editor,
                            filePath    = filePath,

                            cdt = DateTime.Now,
                            udt = DateTime.Now
                        });

                        i++;
                    }
                    foreach (attachFile a in r)
                    {
                        db.attachFiles.Add(a);
                    }

                    f_cerl = CheckAndPushTask(fc, f_cerl);

                    db.f_cerl.Add(f_cerl);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            return(View(f_cerl));
        }
コード例 #14
0
        public ActionResult Edit(FormCollection labInfo, LabInformation labinformation)
        {
            CERLDBContext db       = new CERLDBContext();
            string        UserId   = Method.GetLogonUserId(Session, this, User.Identity.Name.ToUpper());
            string        FolderId = "LabInformation";

            if (ModelState.IsValid)
            {
                labinformation.udt    = DateTime.Now;
                labinformation.editor = UserId;
                labinformation.Width  = (labinformation.Width == null || labinformation.Width.Trim() == "") ? "100%" : labinformation.Width;
                labinformation.Height = (labinformation.Height == null || labinformation.Height.Trim() == "") ? "100%" : labinformation.Height;

                var r = new List <attachFile>();
                int i = 0;

                foreach (string file in Request.Files)
                {
                    HttpPostedFileBase hpf = Request.Files[i] as HttpPostedFileBase;
                    if (hpf.ContentLength == 0)
                    {
                        continue;
                    }

                    string   formId        = labinformation.fID;
                    string   filePath      = Constant.UserFileDirectory + FolderId + @"\" + formId + @"\";
                    FileInfo newinfo       = new FileInfo(hpf.FileName);
                    string   savedFileName = Path.Combine(filePath, Path.GetFileName(newinfo.Name));

                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }
                    hpf.SaveAs(savedFileName);
                    int count = db.attachFiles.Where(x => x.fID == formId && x.fileName == newinfo.Name).Count();

                    if (count == 0)
                    {
                        r.Add(new attachFile()
                        {
                            fID         = formId,
                            displayname = newinfo.Name,
                            fileName    = newinfo.Name,
                            Length      = hpf.ContentLength,
                            Type        = hpf.ContentType,
                            folderId    = FolderId,
                            editor      = UserId,
                            filePath    = filePath,

                            cdt = DateTime.Now,
                            udt = DateTime.Now
                        });
                    }
                    i++;
                }
                foreach (attachFile a in r)
                {
                    db.attachFiles.Add(a);
                }

                db.Entry(labinformation).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(labinformation));
        }
コード例 #15
0
        public ActionResult Create(FormCollection labInfo, LabInformation labinformation)
        {
            CERLDBContext db       = new CERLDBContext();
            string        FolderId = "LabInformation";
            string        Editor   = Method.GetLogonUserId(Session, this, User.Identity.Name.ToUpper());
            string        FormId   = System.Guid.NewGuid().ToString().ToUpper();

            labinformation.fID    = FormId;
            labinformation.editor = Editor;
            labinformation.cdt    = DateTime.Now;
            labinformation.udt    = DateTime.Now;

            if (ModelState.IsValid)
            {
                var r = new List <attachFile>();
                int i = 0;

                foreach (string file in Request.Files)
                {
                    HttpPostedFileBase hpf = Request.Files[i] as HttpPostedFileBase;
                    if (hpf.ContentLength == 0)
                    {
                        continue;
                    }

                    string   formId        = FormId;
                    string   filePath      = Constant.UserFileDirectory + FolderId + @"\" + formId + @"\";
                    FileInfo newinfo       = new FileInfo(hpf.FileName);
                    string   savedFileName = Path.Combine(filePath, Path.GetFileName(newinfo.Name));

                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }
                    hpf.SaveAs(savedFileName);

                    r.Add(new attachFile()
                    {
                        fID         = formId,
                        displayname = newinfo.Name,
                        fileName    = newinfo.Name,
                        Length      = hpf.ContentLength,
                        Type        = hpf.ContentType,
                        folderId    = FolderId,
                        editor      = Editor,
                        filePath    = filePath,

                        cdt = DateTime.Now,
                        udt = DateTime.Now
                    });

                    i++;
                }
                foreach (attachFile a in r)
                {
                    db.attachFiles.Add(a);
                }

                db.LabInformation.Add(labinformation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(labinformation));
        }
コード例 #16
0
        public f_cerl CheckAndPushTask(FormCollection fc, f_cerl f_cerl)
        {
            string fnCheckAndPushTask = "RouteWork_CheckAndPushTask";
            string UserId             = f_cerl.editor;
            string strAction          = f_cerl.Action;
            string ListAssignTo       = "";
            int    errorline          = 233;

            try
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                StringBuilder       vchSet   = new StringBuilder();
                errorline = 238;
                FlowPath fp = GetFlowPath(f_cerl.fID, f_cerl.FlowCode, f_cerl.State, f_cerl.Action); // 取得下一關的State
                errorline = 240;
                if (fp == null)
                {
                    return(f_cerl);
                }

                if (f_cerl.State >= 1000)
                {
                    strAction = "";
                    return(f_cerl);
                }
                errorline = 249;
                if (fp != null)
                {
                    if (f_cerl.LocalSupervisor == null)
                    {
                        f_cerl.LocalSupervisor = db.vUsers.Where(u => u.RoleId == 20).Select(v => v.BadgeCode).FirstOrDefault();//"IEC970209";
                    }
                    errorline = 254;
                    if (f_cerl.Manager == null)
                    {
                        f_cerl.Manager = f_cerl.Applicant;
                    }
                    errorline = 257;
                    vchSet.Append(Method.BuildXML(fp.outState.ToString(), "outState"));
                    vchSet.Append(Method.BuildXML(f_cerl.TestItem.ToString(), "TestItem"));
                    vchSet.Append(Method.BuildXML(f_cerl.Supervisor, "Supervisor"));
                    vchSet.Append(Method.BuildXML(f_cerl.LocalSupervisor, "LocalSupervisor"));
                    vchSet.Append(Method.BuildXML(f_cerl.LabMember, "LabMember"));
                    vchSet.Append(Method.BuildXML(f_cerl.Applicant, "Applicant"));
                    vchSet.Append(Method.BuildXML(f_cerl.Manager, "Manager"));
                    vchSet.Append(Method.BuildXML(f_cerl.Action, ""));
                    errorline = 266;
                    GetListAssignTo(fp.outState, vchSet.ToString(), out ListAssignTo); //取得下一關的收件人
                    f_cerl.ListAssignTo = ListAssignTo;
                    errorline           = 269;
                    if (ListAssignTo != "")
                    {
                        errorline = 272;
                        response  = PostFormDataToRoute(fc, f_cerl); //Push Task, Send Task mail by AssignTo

                        f_cerl.State           = int.Parse(fp.outState.ToString());
                        db.Entry(f_cerl).State = EntityState.Modified;
                        db.SaveChanges();
                        errorline = 278;
                        SendMail(fp, f_cerl.fID);
                        errorline = 280;
                    }
                    errorline = 282;
                }
                f_cerl.Comment = "";
            }
            catch (Exception ex)
            {
                string        msg     = ex.Message;
                string        newLine = "\r\n";
                StringBuilder sb      = new StringBuilder();
                sb.Append("Issue at line 291: occur error after line " + errorline.ToString() + msg);
                sb.Append(newLine);
                sb.Append(f_cerl.ID + " " + f_cerl.State);
                syserrdb.InitErrorData(Src: fnCheckAndPushTask, content: sb.ToString(), editor: UserId);
            }
            return(f_cerl);
        }