Exemplo n.º 1
0
        /// <summary>
        /// Delete DropDown
        /// </summary>
        /// <param name="objViewDropDownModel"></param>
        /// <returns></returns>
        public ViewDropDownModel DeleteDropDown(ViewDropDownModel objViewDropDownModel)
        {
            try
            {
                SqlParameter pErrorCode = new SqlParameter("@ErrorCode", objViewDropDownModel.ErrorCode);
                pErrorCode.Direction = ParameterDirection.Output;
                SqlParameter pErrorMessage = new SqlParameter("@ErrorMessage", objViewDropDownModel.Message);
                pErrorMessage.Direction = ParameterDirection.Output;

                SqlParameter[] parmList =
                {
                    new SqlParameter("@DropDownID", objViewDropDownModel.DeletedDropDownID)
                    ,                               new SqlParameter("@CreatedBy", objViewDropDownModel.DeletedBy)
                    ,                               pErrorCode
                    ,                               pErrorMessage
                };
                //Call delete stored procedure to delete  DropDown
                SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_DeleteDropDown, parmList);
                //set output parameter error code and error message
                objViewDropDownModel.ErrorCode = Convert.ToInt32(pErrorCode.Value);
                objViewDropDownModel.Message   = Convert.ToString(pErrorMessage.Value);
                return(objViewDropDownModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get  DropDown List  with paging, sorting and searching parameter
        /// </summary>
        /// <param name="objViewDropDownModel">object of Model ViewDropDownModel </param>
        /// <returns></returns>
        public DataTable GetDropDownList(ViewDropDownModel objViewDropDownModel)
        {
            try
            {
                SqlParameter[] parmList =
                {
                    new SqlParameter("DropDownName", objViewDropDownModel.FilterDropDownName)
                    ,                                new SqlParameter("CurrentPage", objViewDropDownModel.CurrentPage)
                    ,                                new SqlParameter("PageSize", objViewDropDownModel.PageSize)
                    ,                                new SqlParameter("SortBy", objViewDropDownModel.SortBy)
                    ,                                new SqlParameter("SortOrder", objViewDropDownModel.SortOrder)
                };

                DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_GetDropDownList, parmList);

                if (ds != null && ds.Tables.Count > 0)
                {
                    return(ds.Tables[0]);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public ActionResult ViewDropDown()
        {
            ViewDropDownModel ObjViewDropDownModel = new ViewDropDownModel();

            try
            {
                //initial set of current page, pageSize , Total pages
                ObjViewDropDownModel.CurrentPage = 1;
                ObjViewDropDownModel.PageSize    = CommonUtils.PageSize;
                ObjViewDropDownModel.TotalPages  = 0;

                //Get  DropDown List
                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.DropDown + "/GetDropDownList", ObjViewDropDownModel);

                ObjViewDropDownModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDropDownModel>().Result : null;
                //ObjViewDropDownModel = objBLDropDown.GetDropDownList(ObjViewDropDownModel);

                //Set Success Message if comes from save  page after click on save button
                if (!String.IsNullOrEmpty(Convert.ToString(TempData["SucessMessage"])))
                {
                    ObjViewDropDownModel.Message     = Convert.ToString(TempData["SucessMessage"]);
                    ObjViewDropDownModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower();
                    TempData["SucessMessage"]        = null;
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "DropDown", "View GET");
            }
            return(View("ViewDropDown", ObjViewDropDownModel));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get  DropDown List based on paging, searching and sorting parameter
        /// </summary>
        /// <param name="objViewDropDownModel">object of Model ViewDropDownModel</param>
        /// <returns></returns>
        public ViewDropDownModel GetDropDownList(ViewDropDownModel objViewDropDownModel)
        {
            List <DropDownModel> lstDropDownModel = new List <DropDownModel>();

            //if FilterDropDownName is NULL than set to empty
            objViewDropDownModel.FilterDropDownName = objViewDropDownModel.FilterDropDownName ?? String.Empty;

            //if SortBy is NULL than set to empty
            objViewDropDownModel.SortBy = objViewDropDownModel.SortBy ?? String.Empty;

            //call GetDropDownList Method which will retrun datatable of  DropDown
            DataTable dtDropDown = objDLDropDown.GetDropDownList(objViewDropDownModel);

            //fetch each row of datable
            foreach (DataRow dr in dtDropDown.Rows)
            {
                //Convert datarow into Model object and set Model object property
                DropDownModel itemDropDownModel = GetDataRowToEntity <DropDownModel>(dr);
                //Add  DropDown in List
                lstDropDownModel.Add(itemDropDownModel);
            }

            //set DropDown List of Model ViewDropDownModel
            objViewDropDownModel.DropDownList = lstDropDownModel;
            //if  DropDown List count is not null and greater than 0 Than set Total Pages for Paging.
            if (objViewDropDownModel != null && objViewDropDownModel.DropDownList != null && objViewDropDownModel.DropDownList.Count > 0)
            {
                objViewDropDownModel.CurrentPage = objViewDropDownModel.DropDownList[0].CurrentPage;
                int totalRecord = objViewDropDownModel.DropDownList[0].TotalCount;

                if (decimal.Remainder(totalRecord, objViewDropDownModel.PageSize) > 0)
                {
                    objViewDropDownModel.TotalPages = (totalRecord / objViewDropDownModel.PageSize + 1);
                }
                else
                {
                    objViewDropDownModel.TotalPages = totalRecord / objViewDropDownModel.PageSize;
                }
            }
            else
            {
                objViewDropDownModel.TotalPages  = 0;
                objViewDropDownModel.CurrentPage = 1;
            }
            return(objViewDropDownModel);
        }
Exemplo n.º 5
0
        public ActionResult ViewDropDown(ViewDropDownModel objViewDropDownModel)
        {
            try
            {
                int    ErrorCode    = 0;
                String ErrorMessage = "";
                objViewDropDownModel.Message = objViewDropDownModel.MessageType = String.Empty;

                if (objViewDropDownModel.ActionType == "delete")
                {
                    //delete
                    serviceResponse      = objUtilityWeb.PostAsJsonAsync(WebApiURL.DropDown + "/DeleteDropDown", objViewDropDownModel);
                    objViewDropDownModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDropDownModel>().Result : null;

                    if (Convert.ToInt32(ErrorCode).Equals(0))
                    {
                        //if error code 0 means delete successfully than set Delete success message.
                        objViewDropDownModel.Message     = "DropDown Deleted Successfully";
                        objViewDropDownModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower();
                    }
                    else
                    {
                        //if error code is not 0 means delete error  than set Delete error message.
                        objViewDropDownModel.Message     = "Error while deleting record";
                        objViewDropDownModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();;
                    }
                }
                //Get  DropDown List based on searching , sorting and paging parameter.

                serviceResponse      = objUtilityWeb.PostAsJsonAsync(WebApiURL.DropDown + "/GetDropDownList", objViewDropDownModel);
                objViewDropDownModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDropDownModel>().Result : null;
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "DropDown", "View POST");
            }
            return(PartialView("_DropDownList", objViewDropDownModel));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Delete  DropDown by  DropDown ID
 /// </summary>
 /// <param name="objViewDropDownModel"></param>
 /// <param name="createdBy"></param>
 /// <param name="errorCode"></param>
 /// <param name="errorMessage"></param>
 public ViewDropDownModel DeleteDropDown(ViewDropDownModel objViewDropDownModel)
 {
     return(objDLDropDown.DeleteDropDown(objViewDropDownModel));
 }
Exemplo n.º 7
0
 public ViewDropDownModel GetDropDownList(ViewDropDownModel objViewDropDownModel)
 {
     return(objBLDropDown.GetDropDownList(objViewDropDownModel));
 }