コード例 #1
0
ファイル: GridController.cs プロジェクト: jacupan/mgmtdashb
        public ActionResult AddAssyOutsComments1(AssemblyOutputRemarks assyRemarks)
        {
            var isExistAssyRemarks = (from assyRemarks1 in pdDBContext.AssemblyRemarks
                                      where assyRemarks1.AssemblyOutsID == assyRemarks.AssemblyOutsID
                                      select new
            {
                Remarks = assyRemarks1.Remarks
            }).ToList();



            if (ModelState.IsValid)
            {
                if (isExistAssyRemarks.Count == 0)
                {
                    AssemblyOutputRemarks addAssyRemarks = new AssemblyOutputRemarks();

                    addAssyRemarks.AssemblyOutsID = assyRemarks.AssemblyOutsID;
                    addAssyRemarks.Remarks        = assyRemarks.Remarks;
                    addAssyRemarks.Operation      = assyRemarks.Operation;
                    addAssyRemarks.CreatedBy      = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                    addAssyRemarks.DateCreated    = DateTime.Now;
                    addAssyRemarks.ModifiedBy     = null;
                    addAssyRemarks.DateModified   = null;

                    pdDBContext.AssemblyRemarks.Attach(addAssyRemarks);
                    pdDBContext.AssemblyRemarks.Add(addAssyRemarks);
                    pdDBContext.SaveChanges();
                }

                else
                {
                    AssemblyOutputRemarks updateAssyRemarks = pdDBContext.AssemblyRemarks.FirstOrDefault(assy => assy.AssemblyOutsID == assyRemarks.AssemblyOutsID);

                    updateAssyRemarks.Remarks      = assyRemarks.Remarks;
                    updateAssyRemarks.Operation    = assyRemarks.Operation;
                    updateAssyRemarks.ModifiedBy   = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                    updateAssyRemarks.DateModified = DateTime.Now;

                    pdDBContext.Entry(updateAssyRemarks).State = System.Data.EntityState.Modified;
                    pdDBContext.SaveChanges();
                }
            }


            //if (addAssyRemarks == null)
            //{

            //}

            //else
            //{

            //   // return RedirectToAction("UpdateComments", details);
            //}


            return(View());
        }
コード例 #2
0
ファイル: GridController.cs プロジェクト: jacupan/mgmtdashb
        public ActionResult AddAssyOutComments(AssemblyOutputRemarks detailsAssy)
        {
            AssemblyOutputRemarks saveAssyComments = pdDBContext.AssemblyRemarks.FirstOrDefault(d => d.AssemblyOutsID == detailsAssy.AssemblyOutsID && d.Operation == detailsAssy.Operation);


            if (saveAssyComments == null)
            {
                HistoricalRemarks addAssyRemarksLogs = new HistoricalRemarks();

                if (detailsAssy.Remarks != null)
                {
                    addAssyRemarksLogs.GUID            = System.Guid.NewGuid().ToString().ToUpper();
                    addAssyRemarksLogs.Department      = "ASSEMBLY";
                    addAssyRemarksLogs.Operation       = detailsAssy.Operation;
                    addAssyRemarksLogs.ConnectorID     = detailsAssy.AssemblyOutsID;
                    addAssyRemarksLogs.OriginalRemarks = detailsAssy.Remarks;
                    addAssyRemarksLogs.UpdatedRemarks  = null;
                    addAssyRemarksLogs.CreatedBy       = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                    addAssyRemarksLogs.DateAdded       = DateTime.Now;

                    pdDBContext.RemarksLogs.Attach(addAssyRemarksLogs);
                    pdDBContext.RemarksLogs.Add(addAssyRemarksLogs);
                    pdDBContext.SaveChanges();
                }



                detailsAssy.GUID = System.Guid.NewGuid().ToString().ToUpper();

                if (ModelState.IsValid)
                {
                    pdDBContext.AssemblyRemarks.Attach(detailsAssy);
                    pdDBContext.AssemblyRemarks.Add(detailsAssy);
                    pdDBContext.SaveChanges();
                }

                return(Json("addSuccess", JsonRequestBehavior.AllowGet));
            }

            else
            {
                HistoricalRemarks addAssyUpdateRemarksLogs = new HistoricalRemarks();

                //HistoricalRemarks checkAssyUpdateRemarksLogs = pdDBContext.RemarksLogs.FirstOrDefault(d => d.ConnectorID == detailsAssy.AssemblyOutsID && d.Department == "ASSEMBLY");

                //if (checkAssyUpdateRemarksLogs == null)
                //{
                //    addAssyUpdateRemarksLogs.OriginalRemarks = saveAssyComments.Remarks;

                //}
                //else {

                //    addAssyUpdateRemarksLogs.OriginalRemarks = saveAssyComments.Remarks;
                //}



                if (detailsAssy.Remarks != null)
                {
                    addAssyUpdateRemarksLogs.GUID            = System.Guid.NewGuid().ToString().ToUpper();
                    addAssyUpdateRemarksLogs.Department      = "ASSEMBLY";
                    addAssyUpdateRemarksLogs.Operation       = detailsAssy.Operation;
                    addAssyUpdateRemarksLogs.ConnectorID     = detailsAssy.AssemblyOutsID;
                    addAssyUpdateRemarksLogs.UpdatedRemarks  = detailsAssy.Remarks;
                    addAssyUpdateRemarksLogs.OriginalRemarks = saveAssyComments.Remarks;
                    addAssyUpdateRemarksLogs.CreatedBy       = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                    addAssyUpdateRemarksLogs.DateAdded       = DateTime.Now;

                    pdDBContext.RemarksLogs.Attach(addAssyUpdateRemarksLogs);
                    pdDBContext.RemarksLogs.Add(addAssyUpdateRemarksLogs);
                    pdDBContext.SaveChanges();
                }


                saveAssyComments.Remarks      = detailsAssy.Remarks;
                saveAssyComments.ModifiedBy   = detailsAssy.CreatedBy;
                saveAssyComments.DateModified = DateTime.Now;
                saveAssyComments.Operation    = detailsAssy.Operation;

                pdDBContext.Entry(saveAssyComments).State = System.Data.EntityState.Modified;
                pdDBContext.SaveChanges();

                return(Json("updateSuccess", JsonRequestBehavior.AllowGet));
            }


            // return View();
        }