welcome

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using CCWin;




namespace best
{
    public partial class welcome : CCSkinMain
    {
       
        public welcome()
        {
            InitializeComponent();
        }


        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //实现最小化后通知栏鼠标双击的时候恢复窗体的效果。
            this.Visible = true;
            this.WindowState = FormWindowState.Normal;
         
        }


        private void Form1_Deactivate(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.Visible = false;
            }
        }


        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {


        }


        private void welcome_Load(object sender, EventArgs e)
        {
           


        }


        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {


        }


        private void welcome_LocationChanged(object sender, EventArgs e)
        {


        }


        private void 更改信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {


        }


        private void 查询信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection shu = new SqlConnection("server=.;database=bestr;uid=sa;pwd=123456");
            string sql = "select * from Employee";
            SqlDataAdapter ad = new SqlDataAdapter(sql, shu);
            DataSet da = new DataSet();
            ad.Fill(da, "Employee");
            dataGridView1.DataSource = da.Tables["Employee"];
        }


        private void 添加员工ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form a= new Form2();
            a.Show();
            this.Close();
           
        }


        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {


        }


        private void 删除信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
             try  
    {  
        //选中的行数  
        int iCount = dataGridView1.SelectedRows.Count;  
        if (iCount < 1)  
        {  
            MessageBox.Show("Delete Data Fail!", "Error", MessageBoxButtons.OK,  
               MessageBoxIcon.Error);  
            return;  
        }  
        if (DialogResult.Yes == MessageBox.Show("是否删除选中的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))  
        {  
            for (int i = 0; i < this.dataGridView1.Rows.Count-1; i++)  //循环遍历所有行  
            {  
            
             if(true==this.dataGridView1.Rows[i].Selected)//当前行处于选中状态,则将其删除  
             this.dataGridView1.Rows.RemoveAt(i);  
                    }  
                    //删除任意行数据后,应该刷新dataGridView表格,使索引值从上至下按大小顺序排序  
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)  
                    {  
                        dataGridView1.Rows[i].Cells[0].Value = i + 1;  
                    }  
                }     
            }  
            catch (Exception ex)  
            {  
                MessageBox.Show(ex.Message);  
            }  
        }  
        }


    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值