Ejemplo n.º 1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     //XData.UniversityTransfer();
     //XData.FacultyTransfer();
     //XData.DepartmentTransfer();
     //XData.CityTransfer();
     SqlEdit.DepartmentScore();
 }
Ejemplo n.º 2
0
        private void tcd_DoubleClick(object sender, EventArgs e)
        {
            DataRowView dr = (DataRowView)tcd.GetDataRecordByNode(tcd.FocusedNode);

            if (TopSql == null)
            {
                TopSql = rtfSql_Select;
            }
            TopSql.Insert(dr.Row["Snippet_Script"].ToStringEx());
        }
Ejemplo n.º 3
0
 private void Bsi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     DevExpress.XtraBars.BarButtonItem bsi = (DevExpress.XtraBars.BarButtonItem)e.Item;
     if (TopSql == null)
     {
         TopSql = rtfSql_Select;
     }
     TopSql.Script = bsi.Tag.ToStringEx();
     lstVer.HidePopup();
 }
Ejemplo n.º 4
0
 private void listBox1_DoubleClick(object sender, EventArgs e)
 {
     if (Apq.Convert.HasMean(listBox1.SelectedValue))
     {
         SqlEdit Editor = GlobalObject.MainForm.ActiveMdiChild as SqlEdit;
         if (Editor != null)
         {
             Editor.SqlEditDoc.LoadFile(listBox1.SelectedValue.ToString());
         }
     }
 }
Ejemplo n.º 5
0
Archivo: DBIs.cs Proyecto: 15831944/Apq
 private void treeListView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (treeListView1.FocusedItem != null)
     {
         // 显示相应结果
         string  ServerName = treeListView1.FocusedItem.Text;
         SqlEdit Editor     = GlobalObject.MainForm.ActiveMdiChild as SqlEdit;
         if (Editor != null)
         {
             Editor.SqlOut.ShowTabPage(ServerName);
         }
     }
 }
Ejemplo n.º 6
0
        private void gpb_CustomButtonChecked(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
        {
            try
            {
                switch (e.Button.Properties.Caption)
                {
                case "Insert":
                    ChkBtn(e.Button.Properties.Caption);
                    rtfSql_Insert.BringToFront();
                    TopSql = rtfSql_Insert;
                    break;

                case "Update":
                    ChkBtn(e.Button.Properties.Caption);
                    rtfSql_Update.BringToFront();
                    TopSql = rtfSql_Update;
                    break;

                case "Delete":
                    ChkBtn(e.Button.Properties.Caption);
                    rtfSql_Delete.BringToFront();
                    TopSql = rtfSql_Delete;
                    break;

                case "Select":
                    ChkBtn(e.Button.Properties.Caption);
                    rtfSql_Select.BringToFront();
                    TopSql = rtfSql_Select;
                    break;

                case "Generate":
                    e.Button.Properties.Checked = false;
                    TopSql = TopSql == null ? rtfSql_Select : TopSql;
                    if (gvt.FocusedRowHandle >= 0)
                    {
                        string             conn     = gvt.GetFocusedRowCellValue("WorkSet_Connection").ToStringEx();
                        List <MyParameter> connPara = new List <MyParameter>();
                        //切换到当前连接
                        try
                        {
                            connPara.Add("@WorkSet_Name", DbType.String, "SystemWorkSet_Schema", null);
                            connPara.Add("@WorkSet_Connection", DbType.String, conn, null);
                            BaseService.Execute("SystemWorkSet_SchemaClear", connPara);
                        }
                        catch (Exception ex)
                        {
                            SharedFunc.RaiseError(ex);
                        }
                        List <Sys_Schema> sys_Schemas = new List <Sys_Schema>();
                        string            TableName   = gvt.GetFocusedRowCellValue("WorkSet_Table").ToStringEx();
                        try
                        {
                            //执行生成语句
                            List <MyParameter> myParameters = new List <MyParameter>();
                            myParameters.Add("@TableName", DbType.String, TableName, null);
                            DataTable dt = BaseService.Open("SystemWorkSet_Schema", myParameters);
                            sys_Schemas = EntityHelper.GetEntities <Sys_Schema>(dt);
                        }
                        catch (Exception ex)
                        {
                            SharedFunc.RaiseError(ex);
                        }
                        //切换到默认连接
                        connPara.Clear();
                        try
                        {
                            connPara.Add("@WorkSet_Name", DbType.String, "SystemWorkSet_Schema", null);
                            connPara.Add("@WorkSet_Connection", DbType.String, null, null);
                            BaseService.Execute("SystemWorkSet_SchemaClear", connPara);
                        }
                        catch (Exception ex)
                        {
                            SharedFunc.RaiseError(ex);
                        }
                        if (sys_Schemas != null)
                        {
                            if (!string.IsNullOrEmpty(TableName))
                            {
                                string IsPagination = gvt.GetFocusedRowCellValue("WorkSet_Pagination").ToStringEx();
                                if (!string.IsNullOrEmpty(IsPagination) && CurBtn.Equals("Select"))
                                {
                                    TopSql.Text = ScriptHelper.GenerateSql(TableName, sys_Schemas, "SelectPage");
                                }
                                else
                                {
                                    TopSql.Text = ScriptHelper.GenerateSql(TableName, sys_Schemas, CurBtn);
                                }
                            }
                        }
                    }
                    break;

                case "Parameter":
                    e.Button.Properties.Checked = false;
                    try
                    {
                        if (gvt.FocusedRowHandle >= 0)
                        {
                            string WorkSet_Name = gvt.GetFocusedRowCellValue("WorkSet_Name").ToStringEx();
                            if (string.IsNullOrEmpty(WorkSet_Name.Trim()))
                            {
                                return;
                            }
                            DataTable          fdt         = (DataTable)gdf.DataSource;
                            List <MyParameter> myParameter = new List <MyParameter>();
                            if (string.IsNullOrEmpty(rtfSql_Select.Text))
                            {
                                return;
                            }
                            string tmpSql = rtfSql_Select.Text;
                            Regex  decRgx = new Regex("DECLARE( )*@(([A-Za-z0-9_])* )( )*([A-Za-z0-9_,])*( )*(,|\r)", RegexOptions.IgnoreCase);
                            foreach (Match m in decRgx.Matches(tmpSql))
                            {
                                Regex eRgx = new Regex("@(([A-Za-z0-9_])*)", RegexOptions.IgnoreCase);
                                foreach (Match em in eRgx.Matches(m.Value))
                                {
                                    tmpSql = tmpSql.Replace(em.Value, "");
                                }
                            }
                            //tmpSql = decRgx.Replace(tmpSql, "");
                            Regex rgxOne = new Regex("@(([A-Za-z0-9_])*)", RegexOptions.IgnoreCase);
                            foreach (Match OneMth in rgxOne.Matches(tmpSql))
                            {
                                if (myParameter.Find(p => p.Name.Equals(OneMth.Value)) == null)
                                {
                                    string Bind_Name = "Bind_Name='{0}'";
                                    Bind_Name = string.Format(Bind_Name, OneMth.Value);
                                    if (fdt.Select(Bind_Name).Length.Equals(0))
                                    {
                                        DataRow dr = fdt.NewRow();
                                        dr["Bind_WorkSet"]   = gvt.GetFocusedRowCellValue("WorkSet_Id").ToStringEx();
                                        dr["Bind_Name"]      = OneMth.Value;
                                        dr["Bind_Nick"]      = OneMth.Value;
                                        dr["Bind_Field"]     = OneMth.Value.Trim('@');
                                        dr["Bind_Width"]     = 25;
                                        dr["Bind_ToolTip"]   = OneMth.Value;
                                        dr["Bind_Sort"]      = fdt.Rows.Count * 10 + 100;
                                        dr["Bind_Visible"]   = true;
                                        dr["Bind_ReadOnly"]  = false;
                                        dr["Bind_SqlDbType"] = (int)DbType.String;
                                        dr["Bind_Summary"]   = 6;
                                        dr["IsDelete"]       = 0;
                                        //分页
                                        if (OneMth.Value == "@PageSize" || OneMth.Value == "@PageIndex")
                                        {
                                            dr["Bind_Sort"]      = 999999;
                                            dr["Bind_SqlDbType"] = DbType.Int32;
                                            dr["Bind_Field"]     = gvt.GetFocusedRowCellValue("WorkSet_Pagination").ToStringEx();
                                            dr["Bind_Property"]  = OneMth.Value.Trim('@');
                                        }
                                        fdt.Rows.Add(dr);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SharedFunc.RaiseError(ex);
                    }
                    break;

                case "Debug":
                    e.Button.Properties.Checked = false;
                    try
                    {
                        if (gvt.FocusedRowHandle >= 0)
                        {
                            string WorkSet_Name = gvt.GetFocusedRowCellValue("WorkSet_Name").ToStringEx();
                            if (string.IsNullOrEmpty(WorkSet_Name.Trim()))
                            {
                                return;
                            }
                            DataTable          fdt         = (DataTable)gdf.DataSource;
                            List <MyParameter> myParameter = new List <MyParameter>();
                            if (string.IsNullOrEmpty(rtfSql_Select.Text))
                            {
                                return;
                            }
                            List <Sys_Bind> sys_Binds = EntityHelper.GetEntities <Sys_Bind>(fdt);
                            foreach (Sys_Bind sys_Bind in sys_Binds)
                            {
                                myParameter.Add(sys_Bind.Bind_Name, (DbType)sys_Bind.Bind_SqlDbType, null, null);
                            }
                            DataTable dt = BaseService.Open(WorkSet_Name, myParameter);
                            if (dt == null)
                            {
                                throw new ArgumentNullException(WorkSet_Name);
                            }
                            string             TableName  = gvt.GetFocusedRowCellValue("WorkSet_Table").ToStringEx();
                            List <MyParameter> SchemaPara = new List <MyParameter>();
                            SchemaPara.Add("@TableName", DbType.String, TableName, null);
                            List <Sys_Schema> sys_Schemas = EntityHelper.GetEntities <Sys_Schema>(BaseService.Open("SystemWorkSet_Schema", SchemaPara));
                            foreach (DataColumn col in dt.Columns)
                            {
                                string Bind_Name = "Bind_Name='{0}'";
                                Bind_Name = string.Format(Bind_Name, col.ColumnName);
                                if (fdt.Select(Bind_Name).Length.Equals(0))
                                {
                                    DataRow dr = fdt.NewRow();
                                    dr["Bind_WorkSet"] = gvt.GetFocusedRowCellValue("WorkSet_Id").ToStringEx();
                                    dr["Bind_Name"]    = col.ColumnName;
                                    Sys_Schema sys_Schema = sys_Schemas.Find(s => s.FieldName == col.ColumnName);
                                    dr["Bind_Nick"]     = sys_Schema != null && !string.IsNullOrEmpty(sys_Schema.Description) ? sys_Schema.Description : col.ColumnName;
                                    dr["Bind_Field"]    = col.ColumnName;
                                    dr["Bind_ToolTip"]  = col.ColumnName;
                                    dr["Bind_Sort"]     = (col.Ordinal + 10) * 10 + 1000;
                                    dr["Bind_Visible"]  = true;
                                    dr["Bind_ReadOnly"] = false;
                                    if (ReservedHelper.GridAutoField.Contains(col.ColumnName))
                                    {
                                        dr["Bind_Visible"] = false;
                                    }
                                    dr["Bind_SqlDbType"] = (int)ConvertHelper.GetDbType(col.DataType);
                                    dr["Bind_Summary"]   = 6;
                                    dr["IsDelete"]       = 0;
                                    if (col.DataType.Equals(typeof(DateTime)))
                                    {
                                        dr["Bind_Width"] = 128;
                                    }
                                    else if (col.DataType.Equals(typeof(bool)))
                                    {
                                        dr["Bind_Width"] = 40;
                                    }
                                    else if (col.DataType.Equals(typeof(int)))
                                    {
                                        dr["Bind_Width"] = 60;
                                    }
                                    else
                                    {
                                        dr["Bind_Width"] = 100;
                                    }
                                    string submit = gvt.GetFocusedRowCellValue("WorkSet_Type").ToStringEx();
                                    if (submit.Equals("7"))
                                    {
                                        dr["Bind_FormWidth"] = 25;
                                        dr["Bind_FormSort"]  = (col.Ordinal + 10) * 10 + 1000;
                                        dr["Bind_Push"]      = "edit_" + col.ColumnName;
                                        dr["Bind_Property"]  = "EditValue";
                                    }
                                    //IsEditable
                                    if (col.ColumnName == "IsEditable")
                                    {
                                        dr["Bind_Default"] = "True";
                                    }
                                    //IsEditable
                                    if (col.ColumnName == "IsEnabled")
                                    {
                                        dr["Bind_Default"] = "True";
                                    }
                                    if (col.ColumnName == "PageCount")
                                    {
                                        dr["Bind_Property"] = col.ColumnName;
                                        dr["Bind_Push"]     = gvt.GetFocusedRowCellValue("WorkSet_Pagination").ToStringEx();
                                        dr["Bind_Sort"]     = 999999;
                                    }
                                    fdt.Rows.Add(dr);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SharedFunc.RaiseError(ex);
                    }
                    break;

                case "Design":
                    e.Button.Properties.Checked = false;
                    break;

                case "Subversion":
                    e.Button.Properties.Checked = false;
                    List <MyParameter> mps = new List <MyParameter>();
                    mps.Add("@cSubversion_Table", DbType.String, "Sys_WorkSet", null);
                    mps.Add("@cSubversion_Field", DbType.String, "WorkSet_" + CurBtn, null);
                    mps.Add("@cSubversion_Key", DbType.String, gvt.GetFocusedRowCellValue("WorkSet_Id").ToStringEx(), null);
                    lstVer.Manager.Items.Clear();
                    DataTable             sdt             = BaseService.Open("SystemWorkSet_Subversion", mps);
                    List <Sys_Subversion> sys_Subversions = EntityHelper.GetEntities <Sys_Subversion>(sdt);
                    foreach (Sys_Subversion sys_Subversion in sys_Subversions)
                    {
                        string cat = sys_Subversion.Subversion_Version.ToString("yyyy-MM-dd");
                        DevExpress.XtraBars.BarSubItem subItem;
                        if (lstVer.Manager.Items[cat] == null)
                        {
                            subItem         = new DevExpress.XtraBars.BarSubItem();
                            subItem.Name    = cat;
                            subItem.Caption = cat;
                            lstVer.AddItem(subItem);
                        }
                        subItem = (DevExpress.XtraBars.BarSubItem)lstVer.Manager.Items[cat];
                        DevExpress.XtraBars.BarButtonItem bsi = new DevExpress.XtraBars.BarButtonItem();
                        bsi.Name        = sys_Subversion.Subversion_Id.ToString();
                        bsi.Hint        = sys_Subversion.Subversion_Value;
                        bsi.Description = sys_Subversion.Subversion_Value;
                        bsi.Caption     = sys_Subversion.Subversion_Version.ToString("HH:mm:ss");
                        bsi.Tag         = sys_Subversion.Subversion_Value;
                        bsi.ItemClick  += Bsi_ItemClick;
                        subItem.AddItem(bsi);
                    }
                    lstVer.ShowPopup(Control.MousePosition);
                    break;

                case "Reset":
                    e.Button.Properties.Checked = false;
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                SharedFunc.RaiseError(ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取数据库连接传回的消息并显示到界面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void sc_InfoMessage(object sender, SqlInfoMessageEventArgs e)
        {
            Apq.Windows.Delegates.Action_UI <TabPage>(this, tpInfo, delegate(TabPage ctrl)
            {
                foreach (SqlError r in e.Errors)
                {
                    if (r.Class > 0)
                    {
                        TextBox txtMsg       = new TextBox();
                        txtMsg.Multiline     = true;
                        txtMsg.ReadOnly      = true;
                        txtMsg.ScrollBars    = ScrollBars.Vertical;
                        txtMsg.WordWrap      = false;
                        txtMsg.AcceptsTab    = true;
                        txtMsg.AcceptsReturn = true;

                        txtMsg.BorderStyle = BorderStyle.None;
                        txtMsg.BackColor   = System.Drawing.SystemColors.Control;
                        txtMsg.Font        = new System.Drawing.Font("新宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        txtMsg.Size        = new System.Drawing.Size(tc.Width - 30, 20);

                        int nY = 9;
                        foreach (Control c in tpInfo.Controls)
                        {
                            nY += c.Size.Height;
                            nY += 6;
                        }
                        txtMsg.Location = new System.Drawing.Point(3, nY);

                        if (r.Class > 10)
                        {
                            txtMsg.Size = new System.Drawing.Size(this.Parent.Parent.Width - 40, 140);                            //7行
                            //meMsg.Properties.ScrollBars = System.Windows.Forms.ScrollBars.Both;
                            txtMsg.ForeColor = System.Drawing.Color.Red;
                            txtMsg.Text     += string.Format("消息 {0}, 级别 {1}, 状态 {2}, 第 {3} 行\r\n", r.Number, r.Class, r.State, r.LineNumber);
                        }

                        txtMsg.Text += r.Message;

                        tpInfo.Controls.Add(txtMsg);

                        // 将错误记录到 SqlEdit 的 dsServers 和 dsUI
                        SqlEdit se      = null;
                        Control ctrlTmp = this;
                        int ServerID    = 0;
                        while (ctrlTmp != null)
                        {
                            ctrlTmp = ctrlTmp.Parent;
                            se      = ctrlTmp as SqlEdit;
                            if (se != null)
                            {
                                break;
                            }

                            TabPage xtp = ctrlTmp as TabPage;
                            if (xtp != null)
                            {
                                ServerID = Apq.Convert.ChangeType <int>(xtp.Tag);
                            }
                        }

                        DataView dvErr  = new DataView(se.SqlEditDoc.dsDBC.DBI);
                        dvErr.RowFilter = "DBIID = " + ServerID;
                        // 标记本服执行出错
                        if (dvErr.Count > 0)
                        {
                            object rtLock = se.SqlEditDoc.GetLock(ServerID.ToString());
                            lock (rtLock)
                            {
                                ErrList_XSD.ErrListRow drErrList = se.SqlEditDoc.dsErr.ErrList.NewErrListRow();
                                drErrList.DBIID        = ServerID;
                                drErrList["__DBIName"] = dvErr[0]["SqlName"];
                                drErrList.s            = r.Message;
                                se.SqlEditDoc.dsErr.ErrList.Rows.Add(drErrList);

                                dvErr[0]["Err"] = true;
                            }
                        }
                    }
                }
            });
        }