C#学习



SQLServer

刷新缓存,代码提示
级联在外键后面添加   on  delete  cascade

vs快捷键
  • 恢复默认设置 工具 - 导入和导出设置 - 重置所有设置
  • ctrl+j      ==       alt+/
  • 打try-catch        tab tab 两次

必备头文件:
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

FormMain.cs

控件: MenuStrip  
属性:IsMdiContainer : True

using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormMain  :  Form
    {
         public  FormMain()
        {
            InitializeComponent();
        }
         private  void  信息查询ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormSearch  fs =  new  FormSearch ();
            fs.MdiParent =  this ;
            fs.Show();
        }
         private  void  信息统计ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormStatistics  fss =  new  FormStatistics ();
            fss.MdiParent =  this ;
            fss.Show();
        }
         private  void  病人信息表维护ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormPatient  fp =  new  FormPatient ();
            fp.MdiParent =  this ;
            fp.Show();
        }
         private  void  小科室表维护ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormGroup  fg =  new  FormGroup ();
            fg.MdiParent =  this ;
            fg.Show();
        }
         private  void  退出程序ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             Application .Exit();
        }
    }
}




DBHelperSQL.cs
@"server = admin-THINK; database = my2017; Trusted_Connection = SSPI;" ;
using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Text;
using  System.Data;
using  System.Data.SqlClient;
using  System.Windows.Forms;
namespace  my2017
{
     class  DBHelperSQL
    {
         ///  <summary>
         ///  连接字符串
         ///  </summary>
         public  static  string  connStr =  @"server = admin-THINK; database = my2017; integrated security = true;" ;
       
         ///  <summary>
         ///  连接实例初始值为空
         ///  </summary>
         public  static  SqlConnection  conn =  null ;
         ///  <summary>
         ///  查询
         ///  </summary>
         ///  <param name="sql"></param>
         ///  <param name="para"></param>
         ///  <returns></returns>
         public  static  DataTable  tableSelect( string  sql,  SqlParameter [] para =  null )
        {
             try
            {
                 SqlCommand  cmd =  new  SqlCommand (sql, conn);
                 if  (para !=  null )
                    cmd.Parameters.AddRange(para);
                 DataTable  dt =  new  DataTable ();
                 SqlDataAdapter  da =  new  SqlDataAdapter (cmd);
                da.Fill(dt);
                 return  dt;
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
                 return  null ;
            }
        }
       
         ///  <summary>
         ///  增删改
         ///  </summary>
         ///  <param name="sql"></param>
         ///  <param name="para"></param>
         public  static  void  tableChange( string  sql,  SqlParameter [] para =  null )
        {
             try
            {
                 SqlCommand  cmd =  new  SqlCommand (sql, conn);
                 if  (para !=  null )
                    cmd.Parameters.AddRange(para);
                 if  (cmd.ExecuteNonQuery() > 0)
                {
                     MessageBox .Show( "操作成功!" );
                }
                 else
                {
                     MessageBox .Show( "操作失败! \n请检查数据库是否存在此数据!" );
                }
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
            }
        }
    }
}

Program.cs
using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Windows.Forms;
using  System.Data;
using  System.Data.SqlClient;
namespace  my2017
{
     static  class  Program
    {
         ///  <summary>
         ///  应用程序的主入口点。
         ///  </summary>
        [ STAThread ]
         static  void  Main()
        {
             Application .EnableVisualStyles();
             Application .SetCompatibleTextRenderingDefault( false );
             try
            {
                 DBHelperSQL .conn =  new  SqlConnection ( DBHelperSQL .connStr);
                 DBHelperSQL .conn.Open();
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
            }
             Application .Run( new  FormMain ());
             DBHelperSQL .conn.Close();
        }
    }
}

FormPatient.cs
控件: DataGridView 
属性:AutoSizeColumnsMode : Fill

using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Data;
using  System.Data.SqlClient;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormPatient  :  Form
    {
         public  FormPatient()
        {
            InitializeComponent();
        }
         private  void  btnAdd_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"INSERT INTO [my2017].[dbo].[Patient]
                               ([PID]
                               ,[PName]
                               ,[Date]
                               ,[GroupNo])
                         VALUES(@PID,@PName,@Date,@GroupNo)" ;
             SqlParameter [] para = {  new  SqlParameter ( "@PID" , txtPID.Text),
                                   new  SqlParameter ( "@PName" , txtPName.Text),
                                   new  SqlParameter ( "@Date" , txtDate.Text),
                                   new  SqlParameter ( "@GroupNo" , cboGroupNo.SelectedValue.ToString())};
             DBHelperSQL .tableChange(sql, para);
            myShow();
           
        }
         private  void  btnDel_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"DELETE FROM [my2017].[dbo].[Patient]
                           WHERE [PID] = @PID" ;
             SqlParameter [] para = {  new  SqlParameter ( "@PID" , txtPID.Text) };
             DBHelperSQL .tableChange(sql, para);
            myShow();
        }
         private  void  btnAlt_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"UPDATE [my2017].[dbo].[Patient]
                           SET [PName] = @PName
                              ,[Date] = @Date
                              ,[GroupNo] = @GroupNo
                         WHERE [PID] = @PID" ;
             SqlParameter [] para = {  new  SqlParameter ( "@PID" , txtPID.Text),
                                   new  SqlParameter ( "@PName" , txtPName.Text),
                                   new  SqlParameter ( "@Date" , txtDate.Text),
                                   new  SqlParameter ( "@GroupNo" , cboGroupNo.SelectedValue.ToString())};
             DBHelperSQL .tableChange(sql, para);
            myShow();
        }
         private  void  btnSelect_Click( object  sender,  EventArgs  e)
        {
            myShow();
        }
         private  void  myShow()
        {
             string  sql =  @"SELECT [PID]
                              ,[PName]
                              ,[Date]
                              ,[GroupNo]
                          FROM [my2017].[dbo].[Patient]" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
         private  void  FormPatient_Load( object  sender,  EventArgs  e)
        {
             string  sqlG =  @"SELECT [GroupNo]
                              ,[GroupName]
                              ,[DeptNo]
                              ,[Month]
                              ,[Number]
                          FROM [my2017].[dbo].[Group]" ;
             DataTable  dtG =  DBHelperSQL .tableSelect(sqlG);
            cboGroupNo.DataSource = dtG;
            cboGroupNo.DisplayMember = dtG.Columns[ "GroupNo" ].ToString();
            cboGroupNo.ValueMember = dtG.Columns[ "GroupNo" ].ToString();
            cboGroupNo.SelectedIndex = 0;
        }
    }
}

FormSearch.cs     

控件: DataGridView 
属性:AutoSizeColumnsMode : Fill
using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormSearch  :  Form
    {
         public  FormSearch()
        {
            InitializeComponent();
        }
         private  void  FormSearch_Load( object  sender,  EventArgs  e)
        {
             string  sqlD =  @"SELECT [DeptNo]
                              ,[DeptName]
                          FROM [my2017].[dbo].[Department]" ;
             DataTable  dtD =  DBHelperSQL .tableSelect(sqlD);
            cboDeptName.DataSource = dtD;
            cboDeptName.DisplayMember = dtD.Columns[ "DeptName" ].ToString();
            cboDeptName.ValueMember = dtD.Columns[ "DeptName" ].ToString();
            cboDeptName.SelectedIndex = 0;
             string  sqlG =  @"SELECT [GroupNo]
                              ,[GroupName]
                              ,[DeptNo]
                              ,[Month]
                              ,[Number]
                          FROM [my2017].[dbo].[Group]" ;
             DataTable  dtG =  DBHelperSQL .tableSelect(sqlG);
            cboGroupName.DataSource = dtG;
            cboGroupName.DisplayMember = dtG.Columns[ "GroupName" ].ToString();
            cboGroupName.ValueMember = dtG.Columns[ "GroupName" ].ToString();
            cboGroupName.SelectedIndex = 0;
        }
         private  void  btnSelect_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"select d.DeptName, g.GroupName, p.PName
                        from Patient p, [Group] g, Department d
                        where p.GroupNo = g.GroupNo and g.DeptNo = d.DeptNo " ;
             if  (chbDeptName.CheckState ==  CheckState .Checked)
            {
                sql +=  string .Format( @"and d.DeptName = '{0}'" , cboDeptName.SelectedValue.ToString());
            }
             if  (chbGroupName.CheckState ==  CheckState .Checked)
            {
                sql +=  string .Format( @"and g.GroupName = '{0}'" , cboGroupName.SelectedValue.ToString());
            }
             if  (chbPName.CheckState ==  CheckState .Checked)
            {
                sql +=  string .Format( @"and p.PName like '%{0}%'" , txtPName.Text);
            }
            sql +=  @" order by d.DeptNo desc, g.GroupNo, p.PID desc" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
    }
}

FormStatistics.cs
控件: DataGridView 
属性:AutoSizeColumnsMode : Fill
using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormStatistics  :  Form
    {
         public  FormStatistics()
        {
            InitializeComponent();
        }
         private  void  btn1_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"select g.DeptNo 大科室编号, d.DeptName 大科室名, SUM(g.Number) 病人总数
                        from [Group] g join Department d on g.DeptNo = d.DeptNo
                        group by g.DeptNo, d.DeptName" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
         private  void  btn2_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"select g.[Month] 月份, SUM(Number) 病人总数
                        from [Group] g
                        group by g.[Month]" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
    }
}



使用Text显示 返回一行数据:
using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
using  System.Data;
using  System.Data.SqlClient;
namespace  my2017
{
     public  partial  class  FormMaxMin  :  Form
    {
         public  FormMaxMin()
        {
            InitializeComponent();
        }
         private  void  FormMaxMin_Load( object  sender,  EventArgs  e)
        {
             string  sqlMax =  @"select GroupNo, GroupName, Number
                        from [Group]
                        where Number in (select Max(Number) from [Group])" ;
             string  sqlMin=  @"select GroupNo, GroupName, Number
                        from [Group]
                        where Number in (select Min(Number) from [Group])" ;
             try
            {
                 //最??大???值??
                 SqlCommand  cmd =  new  SqlCommand (sqlMax,  DBHelperSQL .conn);
                txtMaxMin.AppendText( "最大值:\n" );
                 SqlDataReader  rdr = cmd.ExecuteReader();
                 while  (rdr.Read())
                {
                    txtMaxMin.AppendText( "GroupNo: "  + rdr.GetValue(0) +  " "  +
                             "GroupName: "  + rdr.GetValue(1) +  " "  +
                             "Number: "  + rdr.GetValue(2) +  "\n" );
                }
                rdr.Close();
                 //最??小?值??
cmd.CommandText = sqlMin;
                txtMaxMin.AppendText( "最小值:\n" );
                rdr = cmd.ExecuteReader();
                 while  (rdr.Read())
                {
                    txtMaxMin.AppendText( "GroupNo: "  + rdr.GetValue(0) +  " "  +
                             "GroupName: "  + rdr.GetValue(1) +  " "  +
                             "Number: "  + rdr.GetValue(2) +  "\n" );
                }
                rdr.Close();
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
            }
           
        }
    }
}
SQLServer
刷新缓存,代码提示
级联在外键后面添加  on  delete  cascade

vs快捷键
  • 恢复默认设置 工具 - 导入和导出设置 - 重置所有设置
  • ctrl+j      ==       alt+/
  • 打try-catch        tab tab 两次

必备头文件:
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

FormMain.cs

控件: MenuStrip  
属性:IsMdiContainer : True

using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormMain  :  Form
    {
         public  FormMain()
        {
            InitializeComponent();
        }
         private  void  信息查询ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormSearch  fs =  new  FormSearch ();
            fs.MdiParent =  this ;
            fs.Show();
        }
         private  void  信息统计ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormStatistics  fss =  new  FormStatistics ();
            fss.MdiParent =  this ;
            fss.Show();
        }
         private  void  病人信息表维护ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormPatient  fp =  new  FormPatient ();
            fp.MdiParent =  this ;
            fp.Show();
        }
         private  void  小科室表维护ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             FormGroup  fg =  new  FormGroup ();
            fg.MdiParent =  this ;
            fg.Show();
        }
         private  void  退出程序ToolStripMenuItem_Click( object  sender,  EventArgs  e)
        {
             Application .Exit();
        }
    }
}




DBHelperSQL.cs
@"server = admin-THINK; database = my2017; Trusted_Connection = SSPI;" ;
using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Text;
using  System.Data;
using  System.Data.SqlClient;
using  System.Windows.Forms;
namespace  my2017
{
     class  DBHelperSQL
    {
         ///  <summary>
         ///  连接字符串
         ///  </summary>
         public  static  string  connStr =  @"server = admin-THINK; database = my2017; integrated security = true;" ;
       
         ///  <summary>
         ///  连接实例初始值为空
         ///  </summary>
         public  static  SqlConnection  conn =  null ;
         ///  <summary>
         ///  查询
         ///  </summary>
         ///  <param name="sql"></param>
         ///  <param name="para"></param>
         ///  <returns></returns>
         public  static  DataTable  tableSelect( string  sql,  SqlParameter [] para =  null )
        {
             try
            {
                 SqlCommand  cmd =  new  SqlCommand (sql, conn);
                 if  (para !=  null )
                    cmd.Parameters.AddRange(para);
                 DataTable  dt =  new  DataTable ();
                 SqlDataAdapter  da =  new  SqlDataAdapter (cmd);
                da.Fill(dt);
                 return  dt;
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
                 return  null ;
            }
        }
       
         ///  <summary>
         ///  增删改
         ///  </summary>
         ///  <param name="sql"></param>
         ///  <param name="para"></param>
         public  static  void  tableChange( string  sql,  SqlParameter [] para =  null )
        {
             try
            {
                 SqlCommand  cmd =  new  SqlCommand (sql, conn);
                 if  (para !=  null )
                    cmd.Parameters.AddRange(para);
                 if  (cmd.ExecuteNonQuery() > 0)
                {
                     MessageBox .Show( "操作成功!" );
                }
                 else
                {
                     MessageBox .Show( "操作失败! \n请检查数据库是否存在此数据!" );
                }
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
            }
        }
    }
}

Program.cs
using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Windows.Forms;
using  System.Data;
using  System.Data.SqlClient;
namespace  my2017
{
     static  class  Program
    {
         ///  <summary>
         ///  应用程序的主入口点。
         ///  </summary>
        [ STAThread ]
         static  void  Main()
        {
             Application .EnableVisualStyles();
             Application .SetCompatibleTextRenderingDefault( false );
             try
            {
                 DBHelperSQL .conn =  new  SqlConnection ( DBHelperSQL .connStr);
                 DBHelperSQL .conn.Open();
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
            }
             Application .Run( new  FormMain ());
             DBHelperSQL .conn.Close();
        }
    }
}

FormPatient.cs
控件: DataGridView 
属性:AutoSizeColumnsMode : Fill

using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Data;
using  System.Data.SqlClient;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormPatient  :  Form
    {
         public  FormPatient()
        {
            InitializeComponent();
        }
         private  void  btnAdd_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"INSERT INTO [my2017].[dbo].[Patient]
                               ([PID]
                               ,[PName]
                               ,[Date]
                               ,[GroupNo])
                         VALUES(@PID,@PName,@Date,@GroupNo)" ;
             SqlParameter [] para = {  new  SqlParameter ( "@PID" , txtPID.Text),
                                   new  SqlParameter ( "@PName" , txtPName.Text),
                                   new  SqlParameter ( "@Date" , txtDate.Text),
                                   new  SqlParameter ( "@GroupNo" , cboGroupNo.SelectedValue.ToString())};
             DBHelperSQL .tableChange(sql, para);
            myShow();
           
        }
         private  void  btnDel_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"DELETE FROM [my2017].[dbo].[Patient]
                           WHERE [PID] = @PID" ;
             SqlParameter [] para = {  new  SqlParameter ( "@PID" , txtPID.Text) };
             DBHelperSQL .tableChange(sql, para);
            myShow();
        }
         private  void  btnAlt_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"UPDATE [my2017].[dbo].[Patient]
                           SET [PName] = @PName
                              ,[Date] = @Date
                              ,[GroupNo] = @GroupNo
                         WHERE [PID] = @PID" ;
             SqlParameter [] para = {  new  SqlParameter ( "@PID" , txtPID.Text),
                                   new  SqlParameter ( "@PName" , txtPName.Text),
                                   new  SqlParameter ( "@Date" , txtDate.Text),
                                   new  SqlParameter ( "@GroupNo" , cboGroupNo.SelectedValue.ToString())};
             DBHelperSQL .tableChange(sql, para);
            myShow();
        }
         private  void  btnSelect_Click( object  sender,  EventArgs  e)
        {
            myShow();
        }
         private  void  myShow()
        {
             string  sql =  @"SELECT [PID]
                              ,[PName]
                              ,[Date]
                              ,[GroupNo]
                          FROM [my2017].[dbo].[Patient]" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
         private  void  FormPatient_Load( object  sender,  EventArgs  e)
        {
             string  sqlG =  @"SELECT [GroupNo]
                              ,[GroupName]
                              ,[DeptNo]
                              ,[Month]
                              ,[Number]
                          FROM [my2017].[dbo].[Group]" ;
             DataTable  dtG =  DBHelperSQL .tableSelect(sqlG);
            cboGroupNo.DataSource = dtG;
            cboGroupNo.DisplayMember = dtG.Columns[ "GroupNo" ].ToString();
            cboGroupNo.ValueMember = dtG.Columns[ "GroupNo" ].ToString();
            cboGroupNo.SelectedIndex = 0;
        }
    }
}

FormSearch.cs     

控件: DataGridView 
属性:AutoSizeColumnsMode : Fill
using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormSearch  :  Form
    {
         public  FormSearch()
        {
            InitializeComponent();
        }
         private  void  FormSearch_Load( object  sender,  EventArgs  e)
        {
             string  sqlD =  @"SELECT [DeptNo]
                              ,[DeptName]
                          FROM [my2017].[dbo].[Department]" ;
             DataTable  dtD =  DBHelperSQL .tableSelect(sqlD);
            cboDeptName.DataSource = dtD;
            cboDeptName.DisplayMember = dtD.Columns[ "DeptName" ].ToString();
            cboDeptName.ValueMember = dtD.Columns[ "DeptName" ].ToString();
            cboDeptName.SelectedIndex = 0;
             string  sqlG =  @"SELECT [GroupNo]
                              ,[GroupName]
                              ,[DeptNo]
                              ,[Month]
                              ,[Number]
                          FROM [my2017].[dbo].[Group]" ;
             DataTable  dtG =  DBHelperSQL .tableSelect(sqlG);
            cboGroupName.DataSource = dtG;
            cboGroupName.DisplayMember = dtG.Columns[ "GroupName" ].ToString();
            cboGroupName.ValueMember = dtG.Columns[ "GroupName" ].ToString();
            cboGroupName.SelectedIndex = 0;
        }
         private  void  btnSelect_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"select d.DeptName, g.GroupName, p.PName
                        from Patient p, [Group] g, Department d
                        where p.GroupNo = g.GroupNo and g.DeptNo = d.DeptNo " ;
             if  (chbDeptName.CheckState ==  CheckState .Checked)
            {
                sql +=  string .Format( @"and d.DeptName = '{0}'" , cboDeptName.SelectedValue.ToString());
            }
             if  (chbGroupName.CheckState ==  CheckState .Checked)
            {
                sql +=  string .Format( @"and g.GroupName = '{0}'" , cboGroupName.SelectedValue.ToString());
            }
             if  (chbPName.CheckState ==  CheckState .Checked)
            {
                sql +=  string .Format( @"and p.PName like '%{0}%'" , txtPName.Text);
            }
            sql +=  @" order by d.DeptNo desc, g.GroupNo, p.PID desc" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
    }
}

FormStatistics.cs
控件: DataGridView 
属性:AutoSizeColumnsMode : Fill
using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
namespace  my2017
{
     public  partial  class  FormStatistics  :  Form
    {
         public  FormStatistics()
        {
            InitializeComponent();
        }
         private  void  btn1_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"select g.DeptNo 大科室编号, d.DeptName 大科室名, SUM(g.Number) 病人总数
                        from [Group] g join Department d on g.DeptNo = d.DeptNo
                        group by g.DeptNo, d.DeptName" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
         private  void  btn2_Click( object  sender,  EventArgs  e)
        {
             string  sql =  @"select g.[Month] 月份, SUM(Number) 病人总数
                        from [Group] g
                        group by g.[Month]" ;
            dv.DataSource =  DBHelperSQL .tableSelect(sql);
        }
    }
}



使用Text显示 返回一行数据:
using  System;
using  System.Collections.Generic;
using  System.Data;
using  System.Drawing;
using  System.Linq;
using  System.Text;
using  System.Windows.Forms;
using  System.Data;
using  System.Data.SqlClient;
namespace  my2017
{
     public  partial  class  FormMaxMin  :  Form
    {
         public  FormMaxMin()
        {
            InitializeComponent();
        }
         private  void  FormMaxMin_Load( object  sender,  EventArgs  e)
        {
             string  sqlMax =  @"select GroupNo, GroupName, Number
                        from [Group]
                        where Number in (select Max(Number) from [Group])" ;
             string  sqlMin=  @"select GroupNo, GroupName, Number
                        from [Group]
                        where Number in (select Min(Number) from [Group])" ;
             try
            {
                 //最??大???值??
                 SqlCommand  cmd =  new  SqlCommand (sqlMax,  DBHelperSQL .conn);
                txtMaxMin.AppendText( "最大值:\n" );
                 SqlDataReader  rdr = cmd.ExecuteReader();
                 while  (rdr.Read())
                {
                    txtMaxMin.AppendText( "GroupNo: "  + rdr.GetValue(0) +  " "  +
                             "GroupName: "  + rdr.GetValue(1) +  " "  +
                             "Number: "  + rdr.GetValue(2) +  "\n" );
                }
                rdr.Close();
                 //最??小?值??
cmd.CommandText = sqlMin;
                txtMaxMin.AppendText( "最小值:\n" );
                rdr = cmd.ExecuteReader();
                 while  (rdr.Read())
                {
                    txtMaxMin.AppendText( "GroupNo: "  + rdr.GetValue(0) +  " "  +
                             "GroupName: "  + rdr.GetValue(1) +  " "  +
                             "Number: "  + rdr.GetValue(2) +  "\n" );
                }
                rdr.Close();
            }
             catch  ( Exception  ex)
            {
                 MessageBox .Show(ex.Message);
            }
           
        }
    }
}
学习安排:4周4个项目实战 学习形式:录播视频+在线作业考核+助教一对一辅导答疑 1. C#基本语法:基本编程(If:…else)语句、数组等。2. C#面向对象编程:封装、继承、多态性、面向接口编程、动态多态性、字符串基础等。3. .Net 框架原理讲解:多维数组、可变参数 Params、类的实例化内存分配机制等。4. 深入学习对象类型:里氏替换原则(LSP)、类的属性极其本质特性、IS ,AS 关键字、深入学习字符串理论、枚举类型以及适用场合。5. 深入学习集合特性:索引器、自定义集合、深入刨析集合类型本质(ArrayList、HashTable)、学习泛型集合、泛型约束等。6. 学习委托与事件:委托与事件的区别、匿名方法、Lambda表达式。7. 正则表达式。8. 查询表达式Linq。9. 反射、特性、动态编程。10. 多线程编程。11. Socket通讯技术。 第二模块:Unity 入门与基础 学习安排:4周3个项目实战 学习形式:录播视频+在线作业考核+助教一对一辅导答疑 课程内容:游戏与Unity发展历史概述、 3D 模型基础、 地形编辑器、光源、音频、Unity脚本程序基础、GUI、3D模型动画的导入 与基本应用、物理学模拟(初级)、碰撞盒与触发器、协程、SendMessage数据传值技术等。 学习安排:4周4个项目实战 学习形式:录播视频+在线作业考核+助教一对一辅导答疑 课程内容:讲解粒子系统、Mecanim、导航寻路、Unity游戏移植技术、Mecanim 动画系统、导航寻路、项目研发常用优化策略、Unity游戏移植与手指触控识别、射线、数据持久化、对象缓冲池技术、物理学模拟(铰链关节(Hinge Joint)、弹簧关节 、固定关节、角色关节)与资源动态加载技术(AssetBundle与WWW)等。 第四模块:Unity项目实训: ARPG项目"地下守护神" 学习安排:4周1个项目实战 学习形式:录播视频+在线作业考核+助教一对一辅导答疑 课程内容:1:前端分层的MVC架构搭建,开发自定义的资源动态加载插件、音频插件、对话系统插件、事件监听插件等。2: UI粒子特效、场景淡入淡出控制。3: 单机与移动端的双输入控制系统开发。4: 数值平衡处理与开发。5: 多种设计模式在游戏研发过程中的灵活运用。6: XML技术的灵活运用,在系统解耦与资源国际化方面的技术突破。7: 开发强大灵活的日志系统插件,应对服务器与移动端的各种复杂系统调试需求。8:开发“对话系统”,与“新手导航”。9:开发基于XML的对象持久化技术。10:开发“背包系统”、“商城系统”、“公告系统”、“任务系统”。11:开发“副本”多种类怪物的战斗系统。12:开发各种战斗特效系统: “血条”、“漂字”、“连击”等功能。 第五模块:虚拟现实(VR)与增强现实技术(AR) 学习安排:1周2个项目实战 学习形式:录播视频+在线作业考核+助教一对一辅导答疑 课程内容:R虚拟现实技术开发:先从什么是虚拟现实(VR)、虚拟现实的主要特点、虚拟现实技术的基础底层原理、国际与国内的产业布局、国际权威机构未来发展趋势预测等讲起。然后主要介绍国际主要领军品牌:Oculus、HTC、SonyVR等产品规格、主要性能指标等。最后重点以一款国内著名VR产品:3Glasses 为代表,介绍VR产品的具体使用、维护、与开发项目全过程流程等。AR 增强实现开发:讲解什么是增强现实、注册高通AR账号、制作识别图、SDK下载与制作、打包发布
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值