Esempio n. 1
0
        protected override bool ValidateFormWithAlert()
        {
            var errors = ComponentValidationHelper.Validate(tbxName, tbxAddress, tbxPhone);

            if (errors.Count > 0)
            {
                MessageBox.Show(string.Join("\n", errors));
                return(false);
            }

            var duplicate = DataManager.GetFirst <ConsigneeModel>(WhereTerm.Default(tbxName.Text, "name"));

            if (duplicate != null && duplicate.Id != CurrentModel.Id)
            {
                MessageBox.Show(@"Nama consignee ini tidak dapat digunakan!");
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public ReportGenericFilterForm()
        {
            InitializeComponent();

            Parameters = new Dictionary <string, ReportParameter>();

            Load += (sender, args) =>
            {
                Parameters.First().Value.Control.Focus();

                Report.RequestParameters = false;

                foreach (var t in Report.Parameters)
                {
                    t.Visible = false;
                }

                foreach (var key in Parameters.Keys)
                {
                    var i       = AddTableRow();
                    var control = Parameters[key].Control;

                    //if (control is BaseEdit) ((BaseEdit)control).Properties.BeginInit();

                    control.Margin = new Padding(0);

                    tableLayoutPanel1.Controls.Add(new Label
                    {
                        Text      = Parameters[key].Label,
                        Margin    = new Padding(0),
                        ForeColor = Color.Black
                    }, 0, i);

                    tableLayoutPanel1.Controls.Add(control, 1, i);

                    //if (control is BaseEdit) ((BaseEdit)control).Properties.EndInit();

                    if (Parameters[key].DefaultValue != null)
                    {
                        Parameters[key].Value = Parameters[key].DefaultValue;
                    }

                    if (control.GetType() == typeof(dLookupC))
                    {
                        ((dLookupC)control).Properties.ButtonClick += (o, eventArgs) =>
                        {
                            var dlookup = o as dLookupC;

                            if (dlookup != null && dlookup.Enabled)
                            {
                                dlookup.OpenLookupPopup();
                            }
                        };
                    }

                    if (control.GetType() == typeof(CheckedListBox))
                    {
                        for (var ix = 0; ix < ((CheckedListBox)control).Items.Count; ix++)
                        {
                            ((CheckedListBox)control).SetItemChecked(ix, true);
                        }
                    }
                }
            };

            btnPrint.Click += (sender, args) =>
            {
                var errors = ComponentValidationHelper.Validate(Parameters.Values.OfType <IValidatableComponent>().ToArray());

                if (errors.Count > 0)
                {
                    MessageBox.Show(string.Join("\n", errors));
                    return;
                }

                using (var printTool = new ReportPrintTool(Report))
                {
                    _fillDataSource();
                    printTool.PrintDialog();
                }
            };

            btnPrintPreview.Click += (sender, args) =>
            {
                var errors = ComponentValidationHelper.Validate(Parameters.Values.OfType <IValidatableComponent>().ToArray());

                if (errors.Count > 0)
                {
                    MessageBox.Show(string.Join("\n", errors));
                    return;
                }

                using (var printTool = new ReportPrintTool(Report))
                {
                    _fillDataSource();
                    printTool.ShowPreviewDialog();
                }
            };

            btnExport.Click += (sender, args) => ExportToExcel();
        }