예제 #1
0
        private void ToolBar1_ButtonClick(System.Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (ToolBar1.Buttons.IndexOf(e.Button))
            {
                case 0: //添加数据
                    frmEditOp editop = new frmEditOp();
                    editop.GetEmplList();

                    editop.frmMode = 1; //添加记录
                    editop.Text = "添加操作员信息";

                    editop.ShowDialog();
                    if (editop.DialogResult == DialogResult.OK)
                    {
                        LoadOperatorList();
                    }
                    break;
                case 1: //修改数据
                    if (! (dgOp.CurrentRowIndex < 0))
                    {
                        EditOPInfo();
                    }
                    break;
                case 2: //删除当前数据
                    if (! (dgOp.CurrentRowIndex < 0))
                    {
                        if (MessageBox.Show("确定要删除当前选中的 " + dgOp[dgOp.CurrentRowIndex, 0].ToString().Trim() + " 帐号吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            //'删除操作
                            if (DelOprt(dgOp[dgOp.CurrentRowIndex, 0].ToString()))
                            {
                                LoadOperatorList();
                            }
                        }
                    }
                    break;
                case 4: //密码
                    frmEditPsw frmeditpassword = new frmEditPsw();
                    frmeditpassword.ShowDialog();
                    if (frmeditpassword.DialogResult == DialogResult.OK)
                    {
                        //更新当前操作员帐号的密码
                        System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
                        conn.ConnectionString = rms_var.ConnStr;
                        try
                        {

                            SqlCommand selectCMD = new SqlCommand();
                            selectCMD.Connection = conn;
                            selectCMD.CommandText = "update Operator set " + "password='******' " + "where operatorid='" + dgOp[dgOp.CurrentRowIndex, 0] + "'";
                            selectCMD.CommandTimeout = 30;
                            conn.Open();
                            selectCMD.ExecuteNonQuery();
                            MessageBox.Show("密码修改成功!");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        finally
                        {
                            conn.Close();
                        }
                    }
                    break;
                case 5: //权限
                    frmEditAccess frmeditacs = new frmEditAccess();
                    frmeditacs.OpID = dgOp[dgOp.CurrentRowIndex, 0].ToString(); //保存帐号,用于更新
                    frmeditacs.ShowDialog();
                    break;
                case 7:
                    this.Close();
                    break;

            }
        }
예제 #2
0
        private void MenuItem5_Click(System.Object sender, System.EventArgs e)
        {
            frmEditPsw frmeditpassword = new frmEditPsw();
            frmeditpassword.ShowDialog();
            if (frmeditpassword.DialogResult == DialogResult.OK)
            {
                //更新当前操作员帐号的密码
                System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
                conn.ConnectionString = rms_var.ConnStr;
                try
                {

                    SqlCommand selectCMD = new SqlCommand();
                    selectCMD.Connection = conn;
                    selectCMD.CommandText = "update Operator set " + "password='******' " + "where operatorid='" + rms_var.opinfo.OpID + "'";
                    selectCMD.CommandTimeout = 30;
                    conn.Open();
                    selectCMD.ExecuteNonQuery();
                    MessageBox.Show("密码修改成功!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    conn.Close();
                }
            }
        }
예제 #3
0
        private void ToolBar1_ButtonClick(System.Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (ToolBar1.Buttons.IndexOf(e.Button))
            {
            case 0:                     //添加数据
                frmEditOp editop = new frmEditOp();
                editop.GetEmplList();

                editop.frmMode = 1;                         //添加记录
                editop.Text    = "添加操作员信息";

                editop.ShowDialog();
                if (editop.DialogResult == DialogResult.OK)
                {
                    LoadOperatorList();
                }
                break;

            case 1:                     //修改数据
                if (!(dgOp.CurrentRowIndex < 0))
                {
                    EditOPInfo();
                }
                break;

            case 2:                     //删除当前数据
                if (!(dgOp.CurrentRowIndex < 0))
                {
                    if (MessageBox.Show("确定要删除当前选中的 " + dgOp[dgOp.CurrentRowIndex, 0].ToString().Trim() + " 帐号吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        //'删除操作
                        if (DelOprt(dgOp[dgOp.CurrentRowIndex, 0].ToString()))
                        {
                            LoadOperatorList();
                        }
                    }
                }
                break;

            case 4:                     //密码
                frmEditPsw frmeditpassword = new frmEditPsw();
                frmeditpassword.ShowDialog();
                if (frmeditpassword.DialogResult == DialogResult.OK)
                {
                    //更新当前操作员帐号的密码
                    System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
                    conn.ConnectionString = rms_var.ConnStr;
                    try
                    {
                        SqlCommand selectCMD = new SqlCommand();
                        selectCMD.Connection     = conn;
                        selectCMD.CommandText    = "update Operator set " + "password='******' " + "where operatorid='" + dgOp[dgOp.CurrentRowIndex, 0] + "'";
                        selectCMD.CommandTimeout = 30;
                        conn.Open();
                        selectCMD.ExecuteNonQuery();
                        MessageBox.Show("密码修改成功!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
                break;

            case 5:                                                         //权限
                frmEditAccess frmeditacs = new frmEditAccess();
                frmeditacs.OpID = dgOp[dgOp.CurrentRowIndex, 0].ToString(); //保存帐号,用于更新
                frmeditacs.ShowDialog();
                break;

            case 7:
                this.Close();
                break;
            }
        }