예제 #1
0
        public KeyValuePair <int, String> WSID_Delete(WSID model)
        {
            var param = new SqlParameter[] {
                new SqlParameter("@WSIDID", SqlDbType.UniqueIdentifier)
                {
                    Value = model.WSIDID
                },
                new SqlParameter("@ModifiedBy", SqlDbType.UniqueIdentifier)
                {
                    Value = model.ModifiedBy
                },
                new SqlParameter("@RetVal", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@Message", SqlDbType.NVarChar, 100)
                {
                    Direction = ParameterDirection.Output
                }
            };

            int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [CRM].[WSID_Delete] @WSIDID, @ModifiedBy, @RetVal out, @Message out", param);

            int    retVal   = (int)param[2].Value;
            string valueRes = param[3].Value.ToString();

            return(new KeyValuePair <int, string>(retVal, valueRes));
        }
예제 #2
0
        public ActionResult formSubmit(WSID model, string actionType)
        {
            List <string> errorMessage   = new List <string>();
            string        successMessage = Resources.NotifResource.RequestSuccess;
            SessionForSP  sessionParam   = new SessionForSP();

            sessionParam.OrganizationID = new Guid(Session["OrganizationID"].ToString());

            if (ModelState.IsValid)
            {
                KeyValuePair <int, string> results = new KeyValuePair <int, string>(1, "");
                model.ModifiedBy = new Guid(Session["CurrentUserID"].ToString());
                if (actionType == "Create")
                {
                    model.WSIDID = Guid.NewGuid();
                    results      = db.WSID_Insert(model, sessionParam);
                }
                else if (actionType == "Edit")
                {
                    results = db.WSID_Update(model);
                }
                else if (actionType == "ChangeStatus")
                {
                    results = db.WSID_ChangeStatus(model);
                }
                else if (actionType == "Delete")
                {
                    results = db.WSID_Delete(model);
                }

                if (results.Key == 0 || results.Key == 16 || results.Key == 6)
                {
                    UrlHelper u      = new UrlHelper(this.ControllerContext.RequestContext);
                    string    url    = u.Action("Edit", "WSID", new { id = model.WSIDID, success = successMessage });
                    string    urlNew = u.Action("Create", "WSID");

                    var jsonData = new { flag = true, Message = url, urlNew = urlNew };
                    return(Json(jsonData));
                }
                else
                {
                    var jsonData = new { flag = false, Message = results.Value.ToString() };
                    return(Json(jsonData));
                }
            }
            else
            {
                foreach (var key in ModelState.Keys)
                {
                    var error = ModelState[key].Errors.FirstOrDefault();
                    if (error != null)
                    {
                        errorMessage.Add(error.ErrorMessage);
                    }
                }
                var jsonData = new { flag = false, Message = errorMessage.First() };
                return(Json(jsonData));
            }
        }
예제 #3
0
 public ActionResult Delete(WSID model)
 {
     return(formSubmit(model, "Delete"));
 }
예제 #4
0
 public ActionResult ChangeStatus(WSID model)
 {
     return(formSubmit(model, "ChangeStatus"));
 }
예제 #5
0
 public ActionResult Edit(WSID model)
 {
     return(formSubmit(model, "Edit"));
 }
예제 #6
0
        public ActionResult Edit(Guid id)
        {
            WSID model = db.wsid.Find(id);

            return(View(model));
        }
예제 #7
0
 public ActionResult Create(WSID model)
 {
     return(formSubmit(model, "Create"));
 }
예제 #8
0
        public ActionResult Create()
        {
            WSID model = new WSID();

            return(View(model));
        }
예제 #9
0
        public KeyValuePair <int, String> WSID_Update(WSID model)
        {
            var param = new SqlParameter[] {
                new SqlParameter("@WSIDID", SqlDbType.UniqueIdentifier)
                {
                    Value = model.WSIDID
                },
                new SqlParameter("@ModifiedBy", SqlDbType.UniqueIdentifier)
                {
                    Value = model.ModifiedBy
                },
                new SqlParameter("@Name", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.Name)
                },
                new SqlParameter("@Address", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.Address)
                },
                new SqlParameter("@Camera", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.Camera)
                },
                new SqlParameter("@City", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.City)
                },
                new SqlParameter("@Coordinator", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.Coordinator)
                },
                new SqlParameter("@DescKU", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.DescKU)
                },
                new SqlParameter("@DescKW", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.DescKW)
                },
                new SqlParameter("@InstallDate", SqlDbType.DateTime)
                {
                    Value = CheckForDbNull(model.InstallDate)
                },
                new SqlParameter("@Island", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.Island)
                },
                new SqlParameter("@Location", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.Location)
                },
                new SqlParameter("@Lok", SqlDbType.NVarChar, 100)
                {
                    Value = CheckForDbNull(model.Lok)
                },
                new SqlParameter("@RetVal", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@Message", SqlDbType.NVarChar, 100)
                {
                    Direction = ParameterDirection.Output
                }
            };

            int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [CRM].[WSID_Update] @WSIDID, @ModifiedBy, @Name, @Address, @Camera, @City, @Coordinator, @DescKU, @DescKW, @InstallDate, @Island, @Location, @Lok, @RetVal out, @Message out", param);

            int    retVal   = (int)param[13].Value;
            string valueRes = param[14].Value.ToString();

            return(new KeyValuePair <int, string>(retVal, valueRes));
        }