Exemple #1
0
        public bool ExistMandatoryFields(string reportCode)
        {
            ReportParametersListRequest req = new ReportParametersListRequest();

            req.ReportName = reportCode;
            ListResponse <ReportParameter> parameters = _systemService.ChildGetAll <ReportParameter>(req);

            if (!parameters.Success)
            {
                X.Msg.Alert("Error", "Error");
            }
            foreach (var item in parameters.Items)
            {
                if (item.mandatory)
                {
                    return(true);
                }
            }
            return(false);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest && !IsPostBack)
            {
                activeControls = new List <UserControl>();
                SetExtLanguage();
                if (string.IsNullOrEmpty(Request.QueryString["_reportName"]))
                {
                    X.Msg.Alert("Error", "Error");
                }
                bool fillValues = false;
                Dictionary <string, string> valuesDict = null;
                if (!string.IsNullOrEmpty(Request.QueryString["values"]))
                {
                    fillValues = true;
                    valuesDict = new Dictionary <string, string>();
                    string[] valsPairs = Request.QueryString["values"].Split('^');
                    foreach (var item in valsPairs)
                    {
                        string[] pair = item.Split('|');
                        valuesDict.Add(pair[0], pair[1]);
                    }
                }
                ReportParametersListRequest req = new ReportParametersListRequest();
                req.ReportName = Request.QueryString["_reportName"];
                ListResponse <ReportParameter> parameters = _systemService.ChildGetAll <ReportParameter>(req);
                if (!parameters.Success)
                {
                    X.Msg.Alert("Error", "Error");
                }
                int i = -1;

                string labels = "";
                foreach (var item in parameters.Items)
                {
                    i += 1;

                    switch (item.controlType)
                    {
                    case 1: TextField tf = new TextField()
                    {
                            ID = "tb_" + item.id, FieldLabel = item.caption
                    };
                        FormPanel1.Items.Add(tf);
                        if (valuesDict != null && valuesDict.ContainsKey(item.id))
                        {
                            tf.Text = valuesDict[item.id];
                        }
                        tf.AllowBlank = !item.mandatory;
                        break;

                    case 3:
                    case 2: NumberField nf = new NumberField()
                    {
                            ID = "nb_" + item.id, FieldLabel = item.caption
                    };
                        if (valuesDict != null && valuesDict.ContainsKey(item.id))
                        {
                            nf.Value = Convert.ToDouble(valuesDict[item.id]);
                        }
                        FormPanel1.Items.Add(nf);


                        break;

                    case 4: DateField d = new DateField()
                    {
                            ID = "date_" + item.id, FieldLabel = item.caption
                    }; FormPanel1.Items.Add(d);
                        if (valuesDict != null && valuesDict.ContainsKey(item.id))
                        {
                            d.SelectedDate = DateTime.ParseExact(valuesDict[item.id], "yyyyMMdd", new CultureInfo("en"));
                        }

                        d.AllowBlank = !item.mandatory;
                        break;

                    case 5:
                        if (item.classId == 0)
                        {
                            ComboBox             box  = new ComboBox();
                            List <XMLDictionary> dict = Common.XMLDictionaryList(_systemService, item.data);
                            box.Triggers.Add(new FieldTrigger()
                            {
                                Icon = TriggerIcon.Clear
                            });
                            box.Listeners.TriggerClick.Handler = "this.clearValue();";



                            foreach (var xml_elem in dict)
                            {
                                box.Items.Add(new Ext.Net.ListItem(Server.UrlDecode(xml_elem.value), xml_elem.key));
                            }
                            box.ID            = "control_" + item.id;
                            box.Name          = "control_" + item.id;
                            box.AnyMatch      = true;
                            box.CaseSensitive = false;
                            box.Editable      = false;

                            box.FieldLabel = item.caption;
                            if (valuesDict != null && valuesDict.ContainsKey(item.id))
                            {
                                box.Select(valuesDict[item.id]);
                            }
                            FormPanel1.Items.Add(box);
                            box.AllowBlank = !item.mandatory;

                            break;
                        }



                        Control       cont        = LoadControl("Reports/Controls/" + GetControlNameByClassId(item.classId));
                        IComboControl contAsCombo = cont as IComboControl;
                        if (contAsCombo != null)
                        {
                            contAsCombo.SetLabel(item.caption);
                        }
                        if (item.classId == 31201)
                        {
                            ((EmployeeFilter)cont).SetLabel(item.caption);
                            ((EmployeeFilter)cont).EmployeeComboBox.EmptyText = "";
                        }
                        if (item.classId == 31107)
                        {
                            ((EmploymentStatusFilter)cont).Filter.FieldLabel = ((EmploymentStatusFilter)cont).Filter.EmptyText;
                            ((EmploymentStatusFilter)cont).Filter.EmptyText  = "";
                        }
                        cont.ID = "control_" + item.id;
                        contAsCombo.GetComboBox().AllowBlank = !item.mandatory;
                        if (valuesDict != null && valuesDict.ContainsKey(item.id))
                        {
                            if (contAsCombo != null)
                            {
                                contAsCombo.Select(valuesDict[item.id]);
                            }
                            contAsCombo.GetComboBox().Select(0);
                        }

                        Container c = new Container()
                        {
                            Layout = "FitLayout"
                        };
                        c.ContentControls.Add(cont);
                        FormPanel1.Items.Add(c);
                        break;

                    case 6: Checkbox cb = new Checkbox()
                    {
                            ID = "control_" + item.id, FieldLabel = item.caption
                    }; cb.InputValue = "true"; if (valuesDict != null && valuesDict.ContainsKey(item.id))
                        {
                            cb.Checked
                                = valuesDict[item.id] == "true";
                        }
                        break;

                    default: X.Msg.Alert("Error", "unknown control"); break;
                    }
                    labels += item.caption + "^";
                }
                labels.TrimEnd('^');
                X.Call("parent.setLabels", labels);
                this.labels.Text = labels;
            }
        }