Esempio n. 1
0
        public bool ShowDesign(ApplySearchDesign applySearchDesign, IWin32Window owner, IDBQuery dbQuery)
        {
            _applySearchDesign = applySearchDesign;
            _dbQuery           = dbQuery;
            this.ShowDialog(owner);

            return(_isOk);
        }
Esempio n. 2
0
        private bool ValidConfig()
        {
            int rowCount;
            int colCount;
            ApplySearchDesign asDesign = new ApplySearchDesign();

            try
            {
                //判断控件类型,控件名称是否为空
                if (cbxControlType.Text == "")
                {
                    MsgBox.ShowInf("请选择控件类型后,重新添加。");
                    cbxControlType.Focus();
                    return(false);
                }
                if (cbxControlName.Text == "")
                {
                    MsgBox.ShowInf("请选择控件名称后,重新添加。");
                    cbxControlName.Focus();
                    return(false);
                }

                if (txtRowStart.Text.Trim() == "" || Int32.Parse(txtRowStart.Text) == 0)
                {
                    MsgBox.ShowInf("请输入行位置后,重新添加。");
                    txtRowStart.Focus();
                    return(false);
                }

                if (txtColStart.Text.Trim() == "" || Int32.Parse(txtColStart.Text) == 0)
                {
                    MsgBox.ShowInf("请输入列位置后,重新添加。");
                    txtColStart.Focus();
                    return(false);
                }

                //判断是否有同名的控件,复合时间条件,只需要添加一个
                foreach (ListViewItem lvi in listView.Items)
                {
                    asDesign.ApplySearchCfg.Add(lvi.Tag as ApplySearchItemConfig);
                    if (asDesign.ApplySearchCfg[asDesign.ApplySearchCfg.Count - 1].控件名称 == cbxControlName.Text)
                    {
                        MsgBox.ShowInf("控件“" + cbxControlName.Text + "”已存在,请不要重复添加。");
                        return(false);
                    }
                    if ((cbxControlName.Text == "两个日期" && asDesign.ApplySearchCfg[asDesign.ApplySearchCfg.Count - 1].控件名称 == "单个日期") ||
                        (cbxControlName.Text == "单个日期" && asDesign.ApplySearchCfg[asDesign.ApplySearchCfg.Count - 1].控件名称 == "两个日期"))
                    {
                        MsgBox.ShowInf("复合日期条件,只需要添加一个就足够了,请不要重复添加。");
                        return(false);
                    }
                }

                //复合条件,需要控制列数,两个时间和三个时间,只需要添加一个
                if (cbxControlType.Text == "复合条件")
                {
                    if (cbxControlName.Text == "两个日期")
                    {
                        if (Int32.Parse(txtColCount.Text) % 3 != 0)
                        {
                            txtColCount.Text = "3";
                            MsgBox.ShowInf("两个日期的复合条件,最少需要占用3列,或者3的倍数,请重新添加。");
                            txtColCount.Focus();
                            return(false);
                        }
                    }
                    else
                    {
                        if (Int32.Parse(txtColCount.Text) % 2 != 0)
                        {
                            txtColCount.Text = "2";
                            MsgBox.ShowInf("复合条件最少需要占用2列,或者2的倍数,请重新添加。");
                            txtColCount.Focus();
                            return(false);
                        }
                    }
                }

                if (txtColCount.Text.Trim() == "" || Int32.Parse(txtColCount.Text) == 0)
                {
                    txtColCount.Text = "1";
                }
                if (txtRowCount.Text.Trim() == "" || Int32.Parse(txtRowCount.Text) == 0)
                {
                    txtRowCount.Text = "1";
                }

                //判断是否存在位置互相覆盖的控件
                ApplySearchItemConfig oneConfig = new ApplySearchItemConfig();
                oneConfig.起始行  = Int32.Parse(txtRowStart.Text);
                oneConfig.起始列  = Int32.Parse(txtColStart.Text);
                oneConfig.占用行数 = Int32.Parse(txtRowCount.Text);
                oneConfig.占用列数 = Int32.Parse(txtColCount.Text);
                oneConfig.控件名称 = cbxControlName.Text;
                oneConfig.控件类型 = (ASControlType)cbxControlType.SelectedIndex;

                asDesign.ApplySearchCfg.Add(oneConfig);
                asDesign.GetControlRC(out rowCount, out colCount);
                int[, ] intTable = new int[rowCount + 1, colCount + 1];

                foreach (ApplySearchItemConfig asic in asDesign.ApplySearchCfg)
                {
                    intTable[asic.起始行, asic.起始列] = intTable[asic.起始行, asic.起始列] + 1;
                    if (intTable[asic.起始行, asic.起始列] > 1)
                    {
                        MsgBox.ShowInf("控件位置有重叠,请重新调整后再添加。");
                        return(false);
                    }
                    if (asic.占用列数 > 1)
                    {
                        for (int i = 1; i < asic.占用列数; i++)
                        {
                            intTable[asic.起始行, asic.起始列 + i] = intTable[asic.起始行, asic.起始列 + i] + 1;
                            if (intTable[asic.起始行, asic.起始列 + i] > 1)
                            {
                                MsgBox.ShowInf("控件位置有重叠,请重新调整后再添加。");
                                return(false);
                            }
                        }
                    }
                    if (asic.占用行数 > 1)
                    {
                        for (int i = 1; i < asic.占用行数; i++)
                        {
                            intTable[asic.起始行 + i, asic.起始列] = intTable[asic.起始行 + i, asic.起始列] + 1;
                            if (intTable[asic.起始行 + i, asic.起始列] > 1)
                            {
                                MsgBox.ShowInf("控件位置有重叠,请重新调整后再添加。");
                                return(false);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
                return(false);
            }
        }