Esempio n. 1
0
        public JsonResult DeleteFromGrid(int CodeID, int acid)
        {
            bool bReturn         = false;
            bool statusFlag      = false;
            var  ErrorDictionary = new Dictionary <string, string>();

            LoginUserDetails objLoginUserDetails = null;

            try
            {
                objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);

                using (ComCodeSL objComCodeSL = new ComCodeSL())
                {
                    bReturn    = objComCodeSL.Delete(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, CodeID);
                    statusFlag = true;
                    ErrorDictionary.Add("success", "Record deleted");
                }
            }
            catch (Exception exp)
            {
                ModelState.Remove("KEY");
                ModelState.Add("KEY", new ModelState());
                ModelState.Clear();
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());
                ModelState.AddModelError("error", sErrMessage);
                ErrorDictionary = GetModelStateErrorsAsString();
            }
            finally
            {
                objLoginUserDetails = null;
            }

            return(Json(new
            {
                status = statusFlag,
                Message = ErrorDictionary
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult DeleteCode(ComCodeModel objComCodeModel, int acid)//int CodeID, int ParentCodeId, string CodeGroupId, int acid)
        {
            bool bReturn = false;
            //int CodeID = 0;

            LoginUserDetails objLoginUserDetails = null;

            //  ComCodeModel objComCodeModel = null;
            PopulateComboDTO objPopulateComboDTO = null;
            ComCodeDTO       objComCodeDTO       = null;

            List <PopulateComboDTO> lstParentCodeGroup = null;
            List <PopulateComboDTO> lstLabelForParent  = null;
            List <PopulateComboDTO> lstCodeGroup       = null;

            try
            {
                objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails);
                string msg = "";

                using (ComCodeSL objComCodeSL = new ComCodeSL())
                {
                    bReturn = objComCodeSL.Delete(objLoginUserDetails.CompanyDBConnectionString, objLoginUserDetails.LoggedInUserID, Convert.ToInt32(objComCodeModel.CodeID));
                    ArrayList lst = new ArrayList();
                    msg = Common.Common.getResource("mst_msg_10048");
                }

                return(RedirectToAction("Index", "ComCode", new { acid = Common.ConstEnum.UserActions.OTHERMASTER_COMCODE_VIEW, CodeGroupId = objComCodeModel.CodeGroupId, ParentCodeId = objComCodeModel.ParentCodeId }).Success(msg));
            }
            catch (Exception exp)
            {
                string sErrMessage = Common.Common.getResource(exp.InnerException.Data[0].ToString());

                ModelState.AddModelError("Error", sErrMessage);
                string ParentLabel = "";

                objComCodeDTO = new ComCodeDTO();
                // objComCodeModel = new ComCodeModel();

                objPopulateComboDTO       = new PopulateComboDTO();
                objPopulateComboDTO.Key   = "0";
                objPopulateComboDTO.Value = "Select";

                ViewBag.GridType = ConstEnum.GridType.ComCodeList;


                string[] arr = new String[2];

                objLoginUserDetails = (LoginUserDetails)Common.Common.GetSessionValue(ConstEnum.SessionValue.UserDetails);

                //objComCodeDTO.CodeGroupId = CodeGroupId;
                arr = objComCodeModel.CodeGroupId.Split(new string[] { "-" }, StringSplitOptions.None);
                if (arr[1] != "0")
                {
                    // objComCodeModel.ParentCodeId = ParentCodeId;
                    //objComCodeDTO.ParentCodeId = ParentCodeId;
                    ViewBag.ParentCodeId = objComCodeModel.ParentCodeId;

                    objPopulateComboDTO.Key   = "0";
                    objPopulateComboDTO.Value = "Select";

                    lstParentCodeGroup = new List <PopulateComboDTO>();
                    lstParentCodeGroup.Add(objPopulateComboDTO);
                    lstParentCodeGroup.AddRange(Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.ListOfCode,
                                                                               arr[1], null, null, null, null, sLookUpPrefix));

                    lstLabelForParent = new List <PopulateComboDTO>();
                    lstLabelForParent.AddRange(Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.CodeParentList,
                                                                              null, arr[1], null, null, null, sLookUpPrefix));

                    ParentLabel = lstLabelForParent.ElementAt <PopulateComboDTO>(0).Value;
                    if (ParentLabel.Contains("Master"))
                    {
                        ParentLabel = ParentLabel.Substring(0, (ParentLabel.Length - 7));
                    }

                    ViewBag.ParentCodeName      = lstParentCodeGroup;
                    objComCodeModel.CodeGroupId = arr[0];
                }
                else
                {
                    //objComCodeDTO.CodeGroupId = CodeGroupId;
                    // objComCodeDTO.ParentCodeId = ParentCodeId;
                    ViewBag.ParentCodeName = null;
                }

                ViewBag.ParentLabel = ParentLabel;
                lstCodeGroup        = new List <PopulateComboDTO>();
                lstCodeGroup.Add(objPopulateComboDTO);
                lstCodeGroup.AddRange(Common.Common.GetPopulateCombo(objLoginUserDetails.CompanyDBConnectionString, ConstEnum.ComboType.CodeParentList,
                                                                     null, null, null, null, null, sLookUpPrefix));


                //objComCodeModel.CodeGroupId = CodeGroupId;
                // objComCodeModel.ParentCodeId = ParentCodeId;
                if (objComCodeModel.ParentCodeId == null || objComCodeModel.ParentCodeId == 0)
                {
                    objComCodeModel.ParentCodeId = 0;
                }
                ViewBag.CodeGroupDropDown = lstCodeGroup;
                ViewBag.UserAction        = acid;
                return(View("Create", objComCodeModel));
            }
            finally
            {
                objLoginUserDetails = null;

                objComCodeModel     = null;
                objPopulateComboDTO = null;
                objComCodeDTO       = null;

                lstParentCodeGroup = null;
                lstLabelForParent  = null;
                lstCodeGroup       = null;
            }
        }