Esempio n. 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            task = new Task();
            var    mySqlCon      = new My_SqlCon();
            var    sqlConnection = mySqlCon.GetConnection();
            String serial        = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            var    dr            = mySqlCon.getSqlDr_Login($"select * from task where serial='{serial}'", sqlConnection);

            if (dr.Read())
            {
                task.Id         = dr[0].ToString();
                task.Serial     = dr[1].ToString();
                task.Shenheren  = dr[2].ToString();
                task.Time       = dr[3].ToString();
                task.Zherenren  = dr[4].ToString();
                task.Content    = dr[5].ToString();
                task.Gonghao    = dr[6].ToString();
                task.Sqtime     = dr[7].ToString();
                task.Status     = dr[8].ToString();
                task.Bu         = dr[9].ToString();
                task.Faqiren    = dr[10].ToString();
                task.Timeformat = dr[11].ToString();
                task.Subject    = dr[12].ToString();
            }
            var formInfo_Sub = new FormInfo_Sub(task, this);

            dr.Close();
            sqlConnection.Close();
            formInfo_Sub.ShowDialog();
        }
Esempio n. 2
0
        //设置视图的数据和格式
        public void setDateView()
        {
            String mysql = $"select serial as 单号, status as 状态,subject as 会议主题,content as 项目内容,"
                           + $"time as 完成时间,zherenren as 责任人 from task where ((shenheren = '{Main_Menu.userInfo.Username}' and substatus = 1) or (zherenren = '{Main_Menu.userInfo.Username}' and substatus = 0)) and status != '已结案' order by sqtime desc";
            My_SqlCon mySqlCon      = new My_SqlCon();
            var       sqlConnection = this.mySqlCon.GetConnection();
            DataSet   ds            = mySqlCon.getSqlds(mysql, sqlConnection);

            this.dataGridView1.DataSource        = ds.Tables[0];
            this.dataGridView1.RowHeadersVisible = false;
            //设置数据表格为只读
            dataGridView1.ReadOnly = true;
            //不允许添加行
            dataGridView1.AllowUserToAddRows = false;
            //背景为白色
            //不允许拖动行
            dataGridView1.AllowUserToResizeColumns = false;
            dataGridView1.AllowUserToResizeRows    = false;
            // 禁止用户改变列头的高度
            dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            //只允许选中单行
            dataGridView1.MultiSelect = false;
            //整行选中
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            sqlConnection.Close();
        }
Esempio n. 3
0
        public void SetDataView()
        {
            String mysql = $"select serial as 单号, status as 状态,subject as 会议主题,content as 项目内容,"
                           + $"time as 完成时间,zherenren as 责任人 from task where faqiren='{Main_Menu.userInfo.Username}' order by sqtime desc";
            My_SqlCon mySqlCon      = new My_SqlCon();
            var       sqlConnection = mySqlCon.GetConnection();
            DataSet   ds            = mySqlCon.getSqlds(mysql, sqlConnection);

            dataGridView1.DataSource = ds.Tables[0];

            /*//设置数据表格上显示的列标题
             * dataGridView1.Columns[0].HeaderText = "编号";
             * dataGridView1.Columns[1].HeaderText = "课程名称";
             * dataGridView1.Columns[2].HeaderText = "学分";
             * dataGridView1.Columns[3].HeaderText = "备注";*/
            //设置数据表格为只读
            dataGridView1.ReadOnly = true;
            //不允许添加行
            dataGridView1.AllowUserToAddRows = false;
            //背景为白色
            dataGridView1.BackgroundColor = Color.White;
            //只允许选中单行
            dataGridView1.MultiSelect = false;
            //整行选中
            dataGridView1.SelectionMode          = DataGridViewSelectionMode.FullRowSelect;
            this.dataGridView1.RowHeadersVisible = false;
            sqlConnection.Close();
        }
Esempio n. 4
0
        public void Auto_Login()
        {
            string usernameConfig = WebConfigurationManager.AppSettings["username"];
            string islogined      = WebConfigurationManager.AppSettings["islogined"];
            string passwd         = WebConfigurationManager.AppSettings["passwd"];

            if (islogined == "1")
            {
                My_SqlCon     sqlCon        = new My_SqlCon();
                var           sqlConnection = sqlCon.GetConnection();
                SqlDataReader dr            = sqlCon.getSqlDr_Login("select * from usermanage where gh='" + usernameConfig +
                                                                    "'and passwd='" + passwd + "'", sqlConnection);
                if (dr.Read())
                {
                    String username = (string)dr[0];
                    Main_Menu.userInfo          = new UserInfo();
                    Main_Menu.userInfo.Username = username;
                    Main_Menu.userInfo.Type     = (string)dr[2];
                    dr.Close();
                    sqlConnection.Close();
                    var thread1 = new Thread(this.openForm);
                    thread1.Start();
                }
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            var mySqlCon      = new My_SqlCon();
            var sqlConnection = mySqlCon.GetConnection();

            if (string.IsNullOrEmpty(textBox1.Text) && String.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("请输入查询内容");
            }
            //搜索姓名
            if (!String.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text))
            {
                var dataSet = mySqlCon.getSqlds($"select username as 姓名,gh as 工号 from usermanage where username like '%{textBox1.Text}%'", sqlConnection);
                dataGridView1.DataSource = dataSet.Tables[0];
            }
            //搜索工号
            if (!string.IsNullOrEmpty(textBox2.Text) && string.IsNullOrEmpty(textBox1.Text))
            {
                var dataSet = mySqlCon.getSqlds($"select username as 姓名,gh as 工号 from usermanage where gh='{textBox2.Text}'", sqlConnection);
                dataGridView1.DataSource = dataSet.Tables[0];
            }


            if (!string.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox2.Text))
            {
                var dataSet = mySqlCon.getSqlds($"select username as 姓名,gh as 工号 from usermanage where username like '%{textBox1.Text}%' and gh='{textBox2.Text}'", sqlConnection);
                dataGridView1.DataSource = dataSet.Tables[0];
            }

            sqlConnection.Close();
        }
Esempio n. 6
0
        private void ChooseUser_Load(object sender, EventArgs e)
        {
            string    mysql         = "select username as 姓名 ,gh as 工号 from usermanage";
            My_SqlCon mySqlCon      = new My_SqlCon();
            var       sqlConnection = mySqlCon.GetConnection();
            var       dataSet       = mySqlCon.getSqlds(mysql, sqlConnection);

            dataGridView1.DataSource = dataSet.Tables[0];
            sqlConnection.Close();
        }
Esempio n. 7
0
        public bool Sql()
        {
            My_SqlCon     sqlCon        = new My_SqlCon();
            var           sqlConnection = sqlCon.GetConnection();
            SqlDataReader dr            = sqlCon.getSqlDr_Login("select * from usermanage where gh='" + textBox_UserName.Text +
                                                                "'and passwd='" + textBox_Passwd.Text + "'", sqlConnection);

            if (dr.Read())
            {
                String username = (string)dr[0];
                Main_Menu.userInfo          = new UserInfo();
                Main_Menu.userInfo.Username = username;
                Main_Menu.userInfo.Type     = (string)dr[2];
                return(true);
            }
            dr.Close();
            sqlConnection.Close();
            return(false);
        }
Esempio n. 8
0
        public void ChangeTask()
        {
            String mysql = $"update task set changetime='{DateTime.Now}',shenheren='{textBox2.Text.ToString()}'," +
                           $"time='{dateTimePicker1.Value.ToString("yyyy-MM-dd")}',zherenren='{textBox3.Text.ToString()}'," +
                           $"bu='{comboBox1.Text.ToString()}',subject='{textBox4.Text.ToString()}',content='{richTextBox1.Text.ToString()}',substatus=0 " +
                           $"where serial='{task.Serial}'";
            var sqlCon     = new My_SqlCon();
            var connection = sqlCon.GetConnection();
            var sqlCommand = sqlCon.getCmd(mysql, connection);

            if (sqlCommand.ExecuteNonQuery() != 0)
            {
                MessageBox.Show("修改成功");
                connection.Close();
                this.Close();
            }
            else
            {
                MessageBox.Show("服务器正忙,请稍后再试");
            }
            submitted.SetDataView();
        }