Пример #1
0
        private void IReportForm_SetupData()
        {
            foreach (JkFormParameter param in Parameters)
            {
                param.Value = IAppHandler.ConvertMaskValue(param.Value).ToString();
            }

            CreateReportParameters();
        }
Пример #2
0
        //This will update the value on MasterColumns and DataTables before performing Save or Edit
        private void SetColumnsValue()
        {
            DataRow row = null;

            if (FormState == FormStates.fsNew)
            {
                row = VMasterDataTable.NewRow();
            }
            else
            {
                row = VMasterDataTable.Rows.Find(IAppHandler.ConvertMaskValue(Parameters[0].Value));
                row.BeginEdit();
            }

            foreach (JkMasterColumn col in MasterColumns)
            {
                if (String.IsNullOrWhiteSpace(col.ControlName))
                {
                    if (!String.IsNullOrWhiteSpace(col.DefaultValue))
                    {
                        if ((col.Name == "CreatedById" || col.Name == "DateCreated") && FormState == FormStates.fsEdit)
                        {
                            col.Value = col.Value;
                        }
                        else
                        {
                            col.Value = IAppHandler.ConvertMaskValue(col.DefaultValue);
                        }
                    }
                }
                else
                {
                    col.Value = IAppHandler.GetControlsValue(Controls.Find(col.ControlName, true).First());
                }

                row[col.Name] = col.Value ?? DBNull.Value;
            }

            if (FormState == FormStates.fsNew)
            {
                VMasterDataTable.Rows.Add(row);
            }
            else
            {
                row.EndEdit();
            }
        }
        private void AssignMaskedParameters()
        {
            JkDataSet dataset = null;

            foreach (Control control in Controls)
            {
                if (control.GetType().Name == "JkDataSet")
                {
                    dataset = (control as JkDataSet);
                    foreach (JkDataSetParameter param in dataset.Parameters)
                    {
                        param.Value = IAppHandler.ConvertMaskValue(param.Value).ToString();
                    }
                    dataset.Open();
                }
            }
        }
Пример #4
0
        //Gets the default value set from MasterColumn then assign it to controls upon creating new transaction
        private void AssignControlsDefaultValue()
        {
            Control control;

            foreach (JkMasterColumn column in MasterColumns)
            {
                column.Value = null;
                if (!String.IsNullOrWhiteSpace(column.ControlName))
                {
                    control = Controls.Find(column.ControlName, true).First();

                    if (String.IsNullOrWhiteSpace(column.DefaultValue))
                    {
                        IAppHandler.ClearControlsValue(control);
                    }
                    else
                    {
                        IAppHandler.SetControlsValue(control, IAppHandler.ConvertMaskValue(column.DefaultValue));
                    }
                }
            }
        }
Пример #5
0
        private void CreateReportParameters()
        {
            if (toolStripReportParam.Items.Count == 0)
            {
                if (Parameters.Find(p => p.Name == "FromDate") != null && Parameters.Find(p => p.Name == "ToDate") != null)
                {
                    ToolStripLabel labelFrom             = new ToolStripLabel();
                    ToolStripLabel labelTo               = new ToolStripLabel();
                    DateTimePicker dateTimePickerFrom    = new DateTimePicker();
                    DateTimePicker dateTimePickerTo      = new DateTimePicker();
                    Button         btnDateRangeSelection = new Button();
                    String         FromDateDefault       = Parameters.Find(p => p.Name == "FromDate").Value;
                    String         ToDateDefault         = Parameters.Find(p => p.Name == "ToDate").Value;

                    if (!String.IsNullOrWhiteSpace(FromDateDefault))
                    {
                        dateTimePickerFrom.Value = IDateHandler.Parse(IAppHandler.ConvertMaskValue(FromDateDefault).ToString());
                    }

                    if (!String.IsNullOrWhiteSpace(ToDateDefault))
                    {
                        dateTimePickerTo.Value = IDateHandler.Parse(IAppHandler.ConvertMaskValue(ToDateDefault).ToString());
                    }

                    labelFrom.Name = "ControlLabelFromDate";
                    labelFrom.Text = "From:";

                    dateTimePickerFrom.Name         = "ControlFromDate";
                    dateTimePickerFrom.Format       = DateTimePickerFormat.Custom;
                    dateTimePickerFrom.CustomFormat = "MM/dd/yyyy";
                    dateTimePickerFrom.Width        = 100;

                    labelTo.Name = "ControlLabelToDate";
                    labelTo.Text = "To:";

                    dateTimePickerTo.Name         = "ControlToDate";
                    dateTimePickerTo.Format       = DateTimePickerFormat.Custom;
                    dateTimePickerTo.CustomFormat = "MM/dd/yyyy";
                    dateTimePickerTo.Width        = 100;

                    btnDateRangeSelection.Name      = "ControlDateRangeSelection";
                    btnDateRangeSelection.Text      = "...";
                    btnDateRangeSelection.Width     = 30;
                    btnDateRangeSelection.BackColor = Color.Gainsboro;
                    btnDateRangeSelection.Click    += btnDateRangeSelection_Click;

                    toolStripReportParam.Items.Add(labelFrom);
                    toolStripReportParam.Items.Add(new ToolStripControlHost(dateTimePickerFrom));
                    toolStripReportParam.Items.Add(labelTo);
                    toolStripReportParam.Items.Add(new ToolStripControlHost(dateTimePickerTo));
                    toolStripReportParam.Items.Add(new ToolStripControlHost(btnDateRangeSelection));
                }

                foreach (JkFormParameter param in this.Parameters)
                {
                    if (param.Visible)
                    {
                        if (toolStripReportParam.Items.Count > 0)
                        {
                            ToolStripSeparator separator = new ToolStripSeparator();

                            separator.Name = "Separator" + param.Name;
                            toolStripReportParam.Items.Add(separator);
                        }

                        //not lookup
                        if (String.IsNullOrWhiteSpace(param.ControlName))
                        {
                            if (param.Name != "FromDate" && param.Name != "ToDate")
                            {
                                if (param.Type == SqlDbType.DateTime)
                                {
                                    ToolStripLabel label          = new ToolStripLabel();
                                    DateTimePicker dateTimePicker = new DateTimePicker();

                                    label.Name = "ControlLabel" + param.Name;
                                    label.Text = param.Caption + ":";

                                    dateTimePicker.Name         = "Control" + param.Name;
                                    dateTimePicker.Format       = DateTimePickerFormat.Custom;
                                    dateTimePicker.CustomFormat = "MM/dd/yyyy";
                                    dateTimePicker.Width        = 100;

                                    toolStripReportParam.Items.Add(label);
                                    toolStripReportParam.Items.Add(new ToolStripControlHost(dateTimePicker));
                                }
                                else if (param.Type == SqlDbType.Bit)
                                {
                                    ToolStripLabel label    = new ToolStripLabel();
                                    CheckBox       checkBox = new CheckBox();

                                    label.Name = "ControlLabel" + param.Name;
                                    label.Text = param.Caption + ":";

                                    checkBox.Name    = "Control" + param.Name;
                                    checkBox.Checked = Boolean.Parse(param.Value);

                                    toolStripReportParam.Items.Add(label);
                                    toolStripReportParam.Items.Add(new ToolStripControlHost(checkBox));
                                }
                            }
                        }
                        else
                        {
                            JkLookUpComboBox lookUp   = (Controls.Find(param.ControlName, true).First() as JkLookUpComboBox);
                            ToolStripLabel   label    = new ToolStripLabel();
                            ComboBox         comboBox = new ComboBox();

                            if (lookUp.Items.Count == 0)
                            {
                                lookUp.LoadData();
                            }

                            label.Name = "ControlLabel" + param.Name;
                            label.Text = param.Caption + ":";

                            comboBox.Name          = "Control" + param.Name;
                            comboBox.DataSource    = lookUp.Items;
                            comboBox.DisplayMember = lookUp.DisplayText;
                            comboBox.ValueMember   = lookUp.Key;
                            comboBox.Width         = param.Width;

                            toolStripReportParam.Items.Add(label);
                            toolStripReportParam.Items.Add(new ToolStripControlHost(comboBox));
                        }
                    }
                }

                if (toolStripReportParam.Items.Count > 0)
                {
                    ToolStripButton    button       = new ToolStripButton();
                    ToolStripSeparator btnSeparator = new ToolStripSeparator();

                    btnSeparator.Name = "SeparatorButtonGo";

                    button.Name         = "ControlButtonGo";
                    button.DisplayStyle = ToolStripItemDisplayStyle.Text;
                    button.Text         = "  GO  ";
                    button.BackColor    = Color.SteelBlue;
                    button.Click       += delegate(object s, EventArgs ea)
                    {
                        GenerateReport();
                    };

                    toolStripReportParam.Items.Add(btnSeparator);
                    toolStripReportParam.Items.Add(button);
                }
            }
        }