Ejemplo n.º 1
0
        /// <summary>
        /// 单击单元格(编辑、删除、缓存)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvSource_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            string id = this.dgvSource.Rows[e.RowIndex].Cells["ID"].Value.ToString();

            if (e.ColumnIndex == 0)//修改
            {
                OpenDetailWin(id);
            }
            else if (e.ColumnIndex == 1)//删除
            {
                DialogResult dr = MessageBox.Show("是否确定删除?", "提示", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    string msg;
                    bll.DeleteDBSet(id, out msg);
                    MessageBox.Show(msg, "提示", MessageBoxButtons.OK);
                    BindDBList();
                }
            }
            else if (e.ColumnIndex == 2)//缓存
            {
                DialogResult dr = MessageBox.Show("是否确定缓存数据源?", "提示", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    this.Enabled = false;
                    PgsBar   pgs    = new PgsBar(pgsDBList, lblShow);
                    TableBLL auxbll = new TableBLL();

                    string    filename = bll.GetFilePath(id, this.dgvSource.Rows[e.RowIndex].Cells["NAME"].Value.ToString());
                    DBSetting setmodel = new DBSetting();
                    setmodel.Flag           = CommonConfig.DataType.DB;
                    setmodel.DBAccount.DB   = this.dgvSource.Rows[e.RowIndex].Cells["DB"].Value.ToString();
                    setmodel.DBAccount.User = this.dgvSource.Rows[e.RowIndex].Cells["USER"].Value.ToString();
                    setmodel.DBAccount.Pwd  = this.dgvSource.Rows[e.RowIndex].Cells["PWD"].Value.ToString();

                    auxbll.IninDefinitionDAL(setmodel);
                    string retmsg;
                    if (auxbll.CacheTable(pgs, filename, out retmsg))
                    {
                        DataBaseModel model = new DataBaseModel();
                        model.ID   = id;
                        model.PATH = filename;
                        if (!bll.SetCache(model, out retmsg))
                        {
                            MessageBox.Show(retmsg, "提示", MessageBoxButtons.OK);
                        }
                    }
                    this.Enabled = true;
                    BindDBList();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 绑定数据源
        /// </summary>
        /// <param name="list"></param>
        private void BindDGV(List <WhereModel> list)
        {
            if (!SetSettingModel())
            {
                return;
            }
            this.Enabled = false;
            PgsBar    pgs = new PgsBar(pgsCompare, lblprogress);
            DataTable dt  = bll.GetDBList(list, pgs);

            this.Enabled       = true;
            dgvList.DataSource = dt;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 全部比对
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAllCompare_Click(object sender, EventArgs e)
        {
            if (!SetSettingModel())
            {
                return;
            }
            DialogResult dr = MessageBox.Show("是否比对数据库中所有表?", "提示", MessageBoxButtons.OKCancel);

            if (dr == DialogResult.OK)
            {
                this.Enabled = false;
                PgsBar pgs = new PgsBar(pgsCompare, lblprogress);
                bll.scc = SetSCC();
                string retmsg = bll.CompareTable(new List <WhereModel>(), CommonConfig.CompareAllTable, pgs);
                this.Enabled = true;
                MessageBox.Show(retmsg, "提示", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 部分比对
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCompare_Click(object sender, EventArgs e)
        {
            if (!SetSettingModel())
            {
                return;
            }
            StringBuilder            sb = new StringBuilder();
            DataGridViewCheckBoxCell checkCell;

            foreach (DataGridViewRow row in dgvList.Rows)
            {
                checkCell = (DataGridViewCheckBoxCell)row.Cells[0];
                Boolean flag = Convert.ToBoolean(checkCell.Value);

                if (flag)//选中
                {
                    sb.Append("'").Append(row.Cells[1].Value).Append("',");
                }
            }

            if (!string.IsNullOrEmpty(sb.ToString()))
            {
                wherelist = new List <WhereModel>();
                WhereModel model = new WhereModel();
                model.left   = "Tablename";
                model.symbol = "IN";
                model.right  = sb.ToString().TrimEnd(',');
                wherelist.Add(model);
                this.Enabled = false;
                PgsBar pgs = new PgsBar(pgsCompare, lblprogress);
                bll.scc = SetSCC();
                string retmsg = bll.CompareTable(wherelist, CommonConfig.ComparePartTable, pgs);
                this.Enabled = true;
                MessageBox.Show(retmsg, "提示", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("请先选择要比对的表", "提示", MessageBoxButtons.OK);
            }
        }