Beispiel #1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _qs = new QSManager(Page.Request);

            KeyFormMode = VSID + "_FormMode";
            btnNew.Text = NewButtonText;
            btnSubmit.Text = SubmitButtonText;
            btnDelete.Text = DeleteButtonText;
            btnCancel.Text = CancelButtonText;

            btnNew.ID = string.Format("{0}_{1}", ID, "btnCreate");
            btnNew.CausesValidation = false;
            btnNew.Click += BtnCreate_Click;

            btnSubmit.ID = string.Format("{0}_{1}", ID, "btnSave");
            btnSubmit.Click += btnSubmit_Click;

            btnDelete.ID = string.Format("{0}_{1}", ID, "btnDelete");
            btnDelete.Click += btnSubmit_Click;

            btnCancel.ID = string.Format("{0}_{1}", ID, "btnCancel");
            btnCancel.CausesValidation = false;
            btnCancel.Click += BtnCancel_Click;

            if (SwitchMode == ECRUDFormSwitchMode.QueryString)
            {
                if (_qs.Contains(DataQueryStringNewField))
                    FormMode = ECRUDPanelType.Create;
                if (_qs.Contains(DataQueryStringEditField))
                {
                    DataId = _qs[DataQueryStringEditField];
                    FormMode = ECRUDPanelType.Update;
                }
                if (_qs.Contains(DataQueryStringDeleteField))
                {
                    DataId = _qs[DataQueryStringDeleteField];
                    FormMode = ECRUDPanelType.Delete;
                }
            }

            FormMode = ViewState[KeyFormMode] == null ? FormMode : (ECRUDPanelType)ViewState[KeyFormMode];
            ViewState[KeyFormMode] = FormMode;

            foreach (QubeCRUDFormPanel p in GetAllPanels())
            {
                p.Visible = false;
                p.IsCurrent = false;
            }

            GetPanel(FormMode).Visible = true;
            GetPanel(FormMode).IsCurrent = true;
        }
Beispiel #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _qs = new QSManager(Page.Request);
            if (!String.IsNullOrEmpty(DataQuerystringField))
            {
                if (_qs.Contains(DataQuerystringField))
                {
                    DataId = _qs[DataQuerystringField];
                    FormMode = EPanelType.Update;
                }
                if (_qs.Contains(DataQuerystringDeleteField))
                    FormMode = EPanelType.Delete;
            }

            FormMode = ViewState[VSID + "_FormMode"] == null ? FormMode : (EPanelType)ViewState[VSID + "_FormMode"];

            InvokeFirstLoad();
        }
Beispiel #3
0
        public object Run(string fnName, QSManager qs)
        {
            List<object> args = new List<object>();
            MethodInfo fn = this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name.ToLowerInvariant().Trim() == fnName.ToLowerInvariant().Trim()).SingleOrDefault();
            if (fn == null)
                throw new Exception("Invalid function name");

            foreach (ParameterInfo pi in fn.GetParameters())
            {
                if (!qs.Contains(pi.Name))
                    throw new Exception("The parameter " + pi.Name + " does not exist");
                args.Add(Convert.ChangeType(qs[pi.Name], pi.ParameterType));
            }

            return fn.Invoke(this, args.ToArray());
        }
Beispiel #4
0
 protected override void OnInit(EventArgs e)
 {
     qs = new QSManager(Request);
     base.OnInit(e);
 }
Beispiel #5
0
        public void ProcessRequest(HttpContext cx)
        {
            Context = cx;
            if (cx.Request.HttpMethod == "GET")
                qs = new QSManager(cx.Request.QueryString);
            else if (cx.Request.HttpMethod == "POST")
                qs = new QSManager(cx.Request.Form);

            cx.Response.ContentEncoding = Encoding.UTF8;

            if (!qs.Contains("op"))
            {
                WriteJSON(cx, new { Result = -1 });
                cx.Response.End();
            }
            else
            {
                string op = qs["op"];
                qs.Remove("op");
                Request = cx.Request;
                using (Post = new StreamReader(cx.Request.InputStream))
                    try
                    {
                        object rv = Run(op, qs);
                        if (!isCustomResponse)
                            WriteJSON(cx, rv);
                    }
                    catch (Exception e)
                    {
                        WriteJSON(cx, new
                        {
                            StatusCode = -999,
                            Message = e.Message + (e.InnerException != null ? (", " + e.InnerException.Message) : string.Empty)
                        });
                    }
            }
        }