示例#1
0
        private void btn_Login_Click(object sender, EventArgs e)
        {       //登录按钮事件
            string  strSql = "";
            DataSet ds;

            if (txt_Username.Text.Trim() != "" && txt_Password.Text.Trim() != "")
            {
                username = txt_Username.Text.Trim(); password = txt_Password.Text.Trim();
                strSql   = "select * from LoginUsers where username = '******' and password='******'";
                if (txt_Password.Text.Equals(""))
                {
                    strSql = "select * from LoginUsers where username = '******'";
                }
                DataConnector data = new DataConnector();
                data.dataCon();
                ds = data.getDataset(strSql);

                if (ds.Tables[0].Rows.Count == 1)                    //判断是否查询到一个用户.
                {
                    permission = ds.Tables[0].Rows[0][2].ToString(); //获取用户权限等级
                    frm_Main fMain = new frm_Main();
                    fMain.Show();                                    //显示主窗体.
                    this.Hide();                                     //隐藏登录窗体.
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!\r\n请重新输入.", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txt_Password.Text = "";
                }
            }
            else
            {
                MessageBox.Show("用户名或密码为空,请输入完整的登录凭据.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private DataSet doSQL(string strSql)
        {
            DataConnector data = new DataConnector();
            DataSet       ds;

            data.dataCon();
            return(ds = data.getDataset(strSql));
        }
示例#3
0
        private void btn_Apply_Click(object sender, EventArgs e)
        {   //应用更改
            string        strSql = "UPDATE Preferences SET P_Value = '" + txt_Opacity.Text + "' WHERE P_Key = 'form_opacity' AND P_Username = '******'";
            DataConnector data   = new DataConnector();
            DataSet       ds;

            data.dataCon();
            ds = data.getDataset(strSql);

            if (chk_statusBar.Checked)
            {
                strSql = "UPDATE Preferences SET P_Value = 'show' WHERE P_Key = 'form_statusbar' AND P_Username = '******'";
            }
            else
            {
                strSql = "UPDATE Preferences SET P_Value = 'hide' WHERE P_Key = 'form_statusbar' AND P_Username = '******'";
            }
            ds = data.getDataset(strSql);

            switch (qa_state)   //处理此处的变量
            {
            case 1:
                strSql = "UPDATE Preferences SET P_Value = 'include' WHERE P_KEY= 'btn_QuickAdd' AND P_Username = '******'";
                break;

            case 2:
                strSql = "UPDATE Preferences SET P_Value = 'float' WHERE P_KEY= 'btn_QuickAdd' AND P_Username = '******'";
                break;

            case 3:
                strSql = "UPDATE Preferences SET P_Value = 'hide' WHERE P_KEY= 'btn_QuickAdd' AND P_Username = '******'";
                break;
            }
            ds = data.getDataset(strSql);
            frm_Main.ActiveForm.Refresh();

            switch (wstate)
            {
            case 1:
                strSql = "UPDATE Preferences SET P_Value = 'normal' WHERE P_KEY='form_state' AND P_Username = '******'";
                break;

            case 2:
                strSql = "UPDATE Preferences SET P_Value = 'maximized' WHERE P_KEY='form_state' AND P_Username = '******'";
                break;

            case 3:
                strSql = "UPDATE Preferences SET P_Value = 'minimized' WHERE P_KEY='form_state' AND P_Username = '******'";
                break;
            }
            ds = data.getDataset(strSql);

            btn_Apply.Enabled = false;
            frm_Main.frm_M.form_Refresh();
            //调用方法调整按钮状态
        }
示例#4
0
        private void QuickAdd_FormClosed(object sender, FormClosedEventArgs e)
        {   //浮动工具窗口关闭后,修改数据库中的按钮状态属性.
            DataConnector data = new DataConnector();
            DataSet       ds;

            data.dataCon();
            string strSql = "UPDATE Preferences SET P_Value = 'hide' WHERE P_KEY='btn_QuickAdd' AND P_Username = '******'";

            ds = data.getDataset(strSql);
        }
示例#5
0
        public void check_state()
        {
            DataConnector data = new DataConnector();
            DataSet       ds;

            data.dataCon();
            string strSql = "SELECT P_Value FROM(SELECT P_Key , P_Value , P_Username FROM Preferences WHERE(P_Username = '******')) WHERE(P_Key='btn_QuickAdd')";

            ds = data.getDataset(strSql);
            if (ds.Tables[0].Rows[0][0].ToString().Equals("hide") || ds.Tables[0].Rows[0][0].ToString().Equals("include"))
            {
                this.Close();
            }
        }
示例#6
0
 private void btn_Execute_Click(object sender, EventArgs e)
 {
     if (txt_ID.Text.Length != 0 && txt_BS.Text.Length != 0 && txt_ES.Text.Length != 0)
     {
         string        strSql;
         DataConnector data = new DataConnector();
         strSql = "insert into Salary ( ID , BS , Tax , ES ) values('" + txt_ID.Text + "','" + txt_BS.Text + "','" + txt_tax.Text + "','" + txt_ES.Text + "')";
         data.dataCon();
         if (data.sqlExec(strSql))
         {
             MessageBox.Show("添加成功!!\r\n表中数据将会更新.", "结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("添加失败!!\r\n请确认输入的数据.", "关键性错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("必须的字段未满足!!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#7
0
 private void btn_Execute_Click(object sender, EventArgs e)
 {
     if (txt_ID.TextLength != 0 && txt_Name.TextLength != 0 && txt_Sex.Text.Length != 0 && txt_Birthday.TextLength != 0 && txt_Inworkdate.TextLength != 0)
     {
         string        strSql;
         DataConnector data = new DataConnector();
         strSql = $"UPDATE Employee SET E_Name = '{txt_Name.Text}' , E_Sex = '{txt_Sex.Text}' , E_Age = '{txt_Age.Text}' , E_Birthday = '{txt_Birthday.Text}' , E_InworkDate = '{txt_Inworkdate.Text}' , E_Position = '{txt_Position.Text}' , E_Phone = '{txt_Phone.Text}' , E_Address = '{txt_Address.Text}' WHERE E_ID= '{txt_ID.Text}'";
         data.dataCon();
         if (data.sqlExec(strSql))
         {
             MessageBox.Show("修改成功!!\r\n表中数据将会更新.", "结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("修改失败!!\r\n请确认输入的数据.", "关键性错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("必须的字段未满足!!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#8
0
 private void btn_Execute_Click(object sender, EventArgs e)
 {
     if (txt_ID.Text.Length != 0 && txt_Name.Text.Length != 0 && txt_Sex.Text.Length != 0 && txt_Birthday.Text.Length != 0 && txt_Inworkdate.Text.Length != 0)
     {
         string        strSql;
         DataConnector data = new DataConnector();
         strSql = "insert into Employee ( E_ID , E_Name , E_Sex , E_Age , E_Birthday , E_InworkDate , E_Position , E_Phone , E_Address ) values('" + txt_ID.Text + "','" + txt_Name.Text + "','" + txt_Sex.Text + "','" + txt_Age.Text + "','" + txt_Birthday.Text + "','" + txt_Inworkdate.Text + "','" + txt_Position.Text + "','" + txt_Phone.Text + "','" + txt_Address.Text + "')";
         data.dataCon();
         if (data.sqlExec(strSql))
         {
             MessageBox.Show("添加成功!!\r\n表中数据将会更新.", "结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("添加失败!!\r\n请确认输入的数据.", "关键性错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("必须的字段未满足!!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#9
0
 private void btn_Execute_Click(object sender, EventArgs e)
 {
     if (txt_ID.TextLength != 0 && txt_BS.TextLength != 0 && txt_ES.TextLength != 0)
     {
         string        strSql;
         DataConnector data = new DataConnector();
         strSql = $"UPDATE Salary SET BS = '{txt_BS.Text}' , Tax = '{txt_tax.Text}' , ES = '{txt_ES.Text}' WHERE ID= '{txt_ID.Text}'";
         data.dataCon();
         if (data.sqlExec(strSql))
         {
             MessageBox.Show("修改成功!!\r\n表中数据将会更新.", "结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("修改失败!!\r\n请确认输入的数据.", "关键性错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("必须的字段未满足!!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }