/// <summary>
        /// Retrive work study details
        /// </summary>
        /// <returns></returns>
        #region WorkStudy
        public ActionResult WorkSutdyList()
        {
            _logger.Debug("WorkSutdyList");
            List <SelectListItem> studyTypes = null;
            List <SelectListItem> locations  = null;
            List <SelectListItem> status     = null;

            try
            {
                var client = GetHttpClient();
                var task   = client.GetAsync(Api + "api/workstudy?recID=0").ContinueWith((res) =>
                {
                    if (res.Result.IsSuccessStatusCode)
                    {
                        RNDWorkStudy workStudy = JsonConvert.DeserializeObject <RNDWorkStudy>(res.Result.Content.ReadAsStringAsync().Result);
                        if (workStudy != null)
                        {
                            studyTypes = workStudy.StudyTypes;
                            locations  = workStudy.Locations;
                            status     = workStudy.Status;
                        }
                    }
                });
                task.Wait();
                ViewBag.ddStatus     = status;
                ViewBag.ddStudyTypes = studyTypes;
                ViewBag.ddLocation   = locations;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(View());
        }
        public ActionResult SaveWorkStudy(RNDWorkStudy model)
        {
            var          client    = GetHttpClient();
            RNDWorkStudy workStudy = null;
            var          task      = client.PostAsJsonAsync(Api + "api/workstudy", model).ContinueWith((res) =>
            {
                if (res.Result.IsSuccessStatusCode)
                {
                    workStudy = JsonConvert.DeserializeObject <RNDWorkStudy>(res.Result.Content.ReadAsStringAsync().Result);
                }
            });

            task.Wait();
            if (workStudy != null && Request.Form["AssignMatterial"] != null)
            {
                return(RedirectToAction("AssignMaterialList", "AssignMaterial", new { recId = workStudy.RecId, workStudyID = workStudy.WorkStudyID }));
            }
            return(RedirectToAction("WorkSutdyList"));
        }
Esempio n. 3
0
        // POST: api/WorkStudylist
        public HttpResponseMessage Post(RNDWorkStudy workStudy)
        {
            string data = string.Empty;

            try
            {
                CurrentUser  user   = ApiUser;
                AdoHelper    ado    = new AdoHelper();
                SqlParameter param1 = new SqlParameter("@WorkStudyID", workStudy.WorkStudyID);
                SqlParameter param2 = new SqlParameter("@StudyType", workStudy.StudyType);
                //SqlParameter param3 = new SqlParameter("@StudyTitle", workStudy.StudyTitle);
                SqlParameter param4  = new SqlParameter("@StudyDesc", workStudy.StudyDesc);
                SqlParameter param5  = new SqlParameter("@PlanOSCost", workStudy.PlanOSCost);
                SqlParameter param6  = new SqlParameter("@AcctOSCost", workStudy.AcctOSCost);
                SqlParameter param7  = new SqlParameter("@StudyStatus", workStudy.StudyStatus);
                SqlParameter param8  = new SqlParameter("@StartDate", workStudy.StartDate);
                SqlParameter param9  = new SqlParameter("@DueDate", workStudy.DueDate);
                SqlParameter param10 = new SqlParameter("@CompleteDate", workStudy.CompleteDate);
                SqlParameter param11 = new SqlParameter("@Plant", workStudy.Plant);
                SqlParameter param12 = new SqlParameter("@EntryBy", user.UserId);
                SqlParameter param13 = new SqlParameter("@EntryDate", DateTime.Now);
                SqlParameter param14 = new SqlParameter("@TempID", workStudy.TempID);
                if (workStudy.RecId > 0)
                {
                    SqlParameter param15 = new SqlParameter("@RecId", workStudy.RecId);
                    ado.ExecScalarProc("RNDWorkStudy_Update", new object[] { param1, param2, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15 });
                }
                else
                {
                    ado.ExecScalarProc("RNDWorkStudy_Insert", new object[] { param1, param2, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14 });
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
            return(Serializer.ReturnContent(workStudy, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
        }
        /// <summary>
        /// Retrieve the Work study details
        /// </summary>
        /// <param name="recID"></param>
        /// <returns></returns>
        public HttpResponseMessage Get(int recID)
        {
            _logger.Debug("WorkStudy Get called");
            //SqlDataReader reader = null;
            RNDWorkStudy WS = null;

            try
            {
                CurrentUser user = ApiUser;
                WS = new RNDWorkStudy();
                AdoHelper ado = new AdoHelper();
                WS.Status = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                WS.StudyTypes = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                WS.Locations = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                if (recID > 0)
                {
                    SqlParameter param1 = new SqlParameter("@RecId", recID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDWorkStudy_ReadByID", "RND", new object[] { param1 }))
                    {
                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                WS.RecId           = Convert.ToInt32(reader["RecId"]);
                                WS.WorkStudyID     = Convert.ToString(reader["WorkStudyID"]);
                                WS.StudyType       = Convert.ToString(reader["StudyType"]);
                                WS.StudyTitle      = Convert.ToString(reader["StudyDesc"]);
                                WS.StudyDesc       = Convert.ToString(reader["StudyDesc"]);
                                WS.PlanOSCost      = Convert.ToDecimal(reader["PlanOSCost"]);
                                WS.AcctOSCost      = Convert.ToDecimal(reader["AcctOSCost"]);
                                WS.StudyStatus     = Convert.ToString(reader["StudyStatus"]);
                                WS.StartDate       = Convert.ToString(reader["StartDate"]);
                                WS.DueDate         = Convert.ToString(reader["DueDate"]);
                                WS.CompleteDate    = Convert.ToString(reader["CompleteDate"]);
                                WS.Plant           = Convert.ToString(reader["Plant"]);
                                WS.TempID          = Convert.ToString(reader["TempID"]);
                                WS.EntryBy         = Convert.ToString(reader["EntryBy"]);
                                WS.EntryDate       = (!string.IsNullOrEmpty(reader["EntryDate"].ToString())) ? Convert.ToDateTime(reader["EntryDate"]) : (DateTime?)null;
                                WS.StudyScope      = Convert.ToString(reader["StudyScope"]);
                                WS.Experimentation = Convert.ToString(reader["Experimentation"]);
                                WS.FinalSummary    = Convert.ToString(reader["FinalSummary"]);
                                WS.Uncertainty     = Convert.ToString(reader["Uncertainty"]);
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                }
                using (SqlDataReader reader = ado.ExecDataReaderProc("RNDStudyStatus_READ", "RND", null))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            WS.Status.Add(new SelectListItem
                            {
                                Value    = Convert.ToString(reader["StudyStatus"]),
                                Text     = Convert.ToString(reader["StatusDesc"]),
                                Selected = (WS.StudyStatus == Convert.ToString(reader["StudyStatus"])) ? true : false,
                            });
                        }
                    }
                    if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                    {
                        ado._conn.Close(); ado._conn.Dispose();
                    }
                }

                using (SqlDataReader reader = ado.ExecDataReaderProc("RNDStudyType_READ", "RND", null))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            WS.StudyTypes.Add(new SelectListItem
                            {
                                Value    = Convert.ToString(reader["TypeStudy"]),
                                Text     = Convert.ToString(reader["TypeDesc"]),
                                Selected = (WS.StudyType == Convert.ToString(reader["TypeStudy"])) ? true : false,
                            });
                        }
                    }
                    if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                    {
                        ado._conn.Close(); ado._conn.Dispose();
                    }
                }

                using (SqlDataReader reader = ado.ExecDataReaderProc("RNDLocation_READ", "RND", null))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            WS.Locations.Add(new SelectListItem
                            {
                                Value    = Convert.ToString(reader["Plant"]),
                                Text     = Convert.ToString(reader["PlantDesc"]),
                                Selected = (!string.IsNullOrEmpty(WS.Plant) && WS.Plant.Trim() == Convert.ToString(reader["Plant"])) ? true : false,
                            });
                        }
                    }
                    if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                    {
                        ado._conn.Close(); ado._conn.Dispose();
                    }
                }
                return(Serializer.ReturnContent(WS, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
        // POST: api/WorkStudy
        /// <summary>
        /// Save or Update the Work study details
        /// </summary>
        /// <param name="workStudy"></param>
        /// <returns></returns>
        public HttpResponseMessage Post(RNDWorkStudy workStudy)
        {
            string data = string.Empty;

            try
            {
                CurrentUser  user   = ApiUser;
                AdoHelper    ado    = new AdoHelper();
                SqlParameter param1 = new SqlParameter("@WorkStudyID", workStudy.WorkStudyID);
                SqlParameter param2 = new SqlParameter("@StudyType", workStudy.StudyType);
                //SqlParameter param3 = new SqlParameter("@StudyTitle", workStudy.StudyTitle);
                SqlParameter param4  = new SqlParameter("@StudyDesc", workStudy.StudyDesc);
                SqlParameter param5  = new SqlParameter("@PlanOSCost", workStudy.PlanOSCost);
                SqlParameter param6  = new SqlParameter("@AcctOSCost", workStudy.AcctOSCost);
                SqlParameter param7  = new SqlParameter("@StudyStatus", workStudy.StudyStatus);
                SqlParameter param8  = new SqlParameter("@StartDate", workStudy.StartDate);
                SqlParameter param9  = new SqlParameter("@DueDate", workStudy.DueDate);
                SqlParameter param10 = new SqlParameter("@CompleteDate", workStudy.CompleteDate);
                SqlParameter param11 = new SqlParameter("@Plant", workStudy.Plant);
                //  SqlParameter param12 = new SqlParameter("@EntryBy", user.UserId);
                SqlParameter param13 = new SqlParameter("@EntryDate", DateTime.Now);
                string       TempID  = Convert.ToString(DateTime.Now) + user.UserName;

                SqlParameter param14 = new SqlParameter("@TempID", workStudy.TempID);
                SqlParameter param15 = new SqlParameter("@StudyScope", workStudy.StudyScope);
                SqlParameter param17 = new SqlParameter("@Experimentation", workStudy.Experimentation);
                SqlParameter param18 = new SqlParameter("@FinalSummary", workStudy.FinalSummary);
                SqlParameter param19 = new SqlParameter("@Uncertainty", workStudy.Uncertainty);

                if (workStudy.RecId > 0)
                {
                    SqlParameter param20 = new SqlParameter("@EntryBy", workStudy.EntryBy);
                    SqlParameter param16 = new SqlParameter("@RecId", workStudy.RecId);
                    ado.ExecScalarProc("RNDWorkStudy_Update", "RND", new object[] { param1, param2, param4, param5, param6, param7, param8, param9, param10, param11, param20, param13, param14, param15, param16, param17, param18, param19 });
                }
                else
                {
                    SqlParameter param12 = new SqlParameter("@EntryBy", user.UserName);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDWorkStudy_Insert", "RND", new object[] { param1, param2, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param17, param18, param19 }))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                workStudy.RecId = Convert.ToInt32(reader["RecId"].ToString());
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
            return(Serializer.ReturnContent(workStudy, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
        }
Esempio n. 6
0
        public HttpResponseMessage Get(int recID)
        {
            _logger.Debug("WorkStudy Get called");
            SqlDataReader reader = null;
            RNDWorkStudy  WS     = null;

            try
            {
                CurrentUser user = ApiUser;
                WS = new RNDWorkStudy();
                AdoHelper ado = new AdoHelper();
                if (recID > 0)
                {
                    SqlParameter param1 = new SqlParameter("@RecId", recID);
                    using (reader = ado.ExecDataReaderProc("RNDWorkStudy_ReadByID", new object[] { param1 }))
                    {
                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                WS.RecId        = Convert.ToInt32(reader["RecId"]);
                                WS.WorkStudyID  = Convert.ToString(reader["WorkStudyID"]);
                                WS.StudyType    = Convert.ToString(reader["StudyType"]);
                                WS.StudyTitle   = Convert.ToString(reader["StudyDesc"]);
                                WS.StudyDesc    = Convert.ToString(reader["StudyDesc"]);
                                WS.PlanOSCost   = Convert.ToDecimal(reader["PlanOSCost"]);
                                WS.AcctOSCost   = Convert.ToDecimal(reader["AcctOSCost"]);
                                WS.StudyStatus  = Convert.ToString(reader["StudyStatus"]);
                                WS.StartDate    = Convert.ToString(reader["StartDate"]);
                                WS.DueDate      = Convert.ToString(reader["DueDate"]);
                                WS.CompleteDate = Convert.ToString(reader["CompleteDate"]);
                                WS.Plant        = Convert.ToInt32(reader["Plant"]);
                                WS.TempID       = Convert.ToString(reader["TempID"]);
                                WS.EntryBy      = Convert.ToString(reader["EntryBy"]);
                                WS.EntryDate    = (!string.IsNullOrEmpty(reader["EntryDate"].ToString())) ? Convert.ToDateTime(reader["EntryDate"]) : (DateTime?)null;

                                //check for [RNDStudyScope]
                            }
                        }
                    }
                }
                using (reader = ado.ExecDataReaderProc("RNDStudyStatus_READ", null))
                {
                    if (reader.HasRows)
                    {
                        WS.Status = new List <SelectListItem>();
                        while (reader.Read())
                        {
                            WS.Status.Add(new SelectListItem
                            {
                                Value = Convert.ToString(reader["StudyStatus"]),
                                Text  = Convert.ToString(reader["StatusDesc"]),
                            });
                        }
                    }
                }

                using (reader = ado.ExecDataReaderProc("RNDStudyType_READ", null))
                {
                    if (reader.HasRows)
                    {
                        WS.StudyTypes = new List <SelectListItem>();
                        while (reader.Read())
                        {
                            WS.StudyTypes.Add(new SelectListItem
                            {
                                Value = Convert.ToString(reader["TypeStudy"]),
                                Text  = Convert.ToString(reader["TypeDesc"]),
                            });
                        }
                    }
                }

                using (reader = ado.ExecDataReaderProc("RNDLocation_READ", null))
                {
                    if (reader.HasRows)
                    {
                        WS.Locations = new List <SelectListItem>();
                        while (reader.Read())
                        {
                            WS.Locations.Add(new SelectListItem
                            {
                                Value = Convert.ToString(reader["Plant"]),
                                Text  = Convert.ToString(reader["PlantDesc"]),
                            });
                        }
                    }
                }
                return(Serializer.ReturnContent(WS, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Retrieve the WorkStudy Details
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        private DataSearch <RNDWorkStudy> GetWorkStudies(DataGridoption option)
        {
            AdoHelper ado = new AdoHelper();
            //SqlDataReader reader = null;
            List <RNDWorkStudy> lstWorkStudy    = new List <RNDWorkStudy>();
            List <SqlParameter> lstSqlParameter = new List <SqlParameter>();

            lstSqlParameter.Add(new SqlParameter("@CurrentPage", option.pageIndex));
            lstSqlParameter.Add(new SqlParameter("@NoOfRecords", option.pageSize));
            AddSearchFilter(option, lstSqlParameter);
            try
            {
                using (SqlDataReader reader = ado.ExecDataReaderProc("RNDWorkStudy_Read", "RND", lstSqlParameter.Cast <object>().ToArray()))
                {
                    if (reader.HasRows)
                    {
                        RNDWorkStudy WS = null;
                        while (reader.Read())
                        {
                            WS                 = new RNDWorkStudy();
                            WS.total           = Convert.ToInt32(reader["total"]);
                            WS.RecId           = Convert.ToInt32(reader["RecId"]);
                            WS.WorkStudyID     = Convert.ToString(reader["WorkStudyID"]);
                            WS.StudyType       = Convert.ToString(reader["StudyType"]);
                            WS.StudyTypeDesc   = Convert.ToString(reader["StudyTypeDesc"]);
                            WS.StudyTitle      = Convert.ToString(reader["StudyDesc"]);
                            WS.StudyDesc       = Convert.ToString(reader["StudyDesc"]);
                            WS.PlanOSCost      = Convert.ToDecimal(reader["PlanOSCost"]);
                            WS.AcctOSCost      = Convert.ToDecimal(reader["AcctOSCost"]);
                            WS.StudyStatus     = Convert.ToString(reader["StudyStatus"]);
                            WS.StudyStatusDesc = Convert.ToString(reader["StudyStatusDesc"]);
                            WS.StartDate       = Convert.ToString(reader["StartDate"]);
                            WS.DueDate         = Convert.ToString(reader["DueDate"]);
                            //  WS.DueDate = (!string.IsNullOrEmpty(reader["DueDate"].ToString())) ? Convert.ToDateTime(reader["DueDate"]) : (DateTime?)null;
                            WS.CompleteDate    = Convert.ToString(reader["CompleteDate"]);
                            WS.Plant           = Convert.ToString(reader["Plant"]);
                            WS.PlantDesc       = Convert.ToString(reader["PlantDesc"]);
                            WS.TempID          = Convert.ToString(reader["TempID"]);
                            WS.EntryBy         = Convert.ToString(reader["EntryBy"]);
                            WS.EntryDate       = (!string.IsNullOrEmpty(reader["EntryDate"].ToString())) ? Convert.ToDateTime(reader["EntryDate"]) : (DateTime?)null;
                            WS.Experimentation = Convert.ToString(reader["Experimentation"]);
                            WS.FinalSummary    = Convert.ToString(reader["FinalSummary"]);
                            WS.Uncertainty     = Convert.ToString(reader["Uncertainty"]);
                            lstWorkStudy.Add(WS);
                        }
                    }
                    if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                    {
                        ado._conn.Close(); ado._conn.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
            }

            DataSearch <RNDWorkStudy> ds = new DataSearch <RNDWorkStudy>
            {
                items = lstWorkStudy,
                total = (lstWorkStudy != null && lstWorkStudy.Count > 0) ? lstWorkStudy[0].total : 0
            };

            return(ds);
        }