Ejemplo n.º 1
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (Dlg.ShowConfirmInfo("确认要删除该模块吗?") == DialogResult.Yes)
            {
                string MKBH;
                if (tvRight.SelectedNode == null)
                {
                    Dlg.ShowErrorInfoAndHelp("请选择要删除的模块!");
                    return;
                }
                MKBH = ((ModuleList)tvRight.SelectedNode.Tag).MKBH;
                List <string> mSqls = new List <string>();
                string        mSql  = string.Format("delete from ptcd where mkbh='{0}'", MKBH);
                mSqls.Add(mSql);
                mSql = string.Format("delete from ptzqx where mkbh='{0}'", MKBH);
                mSqls.Add(mSql);

                int ret = SqlHelper.ExecuteSqls(mSqls.ToArray());
                if (ret == 0)
                {
                    Dlg.ShowOKInfo("删除成功!");
                    ClearForm();
                    InitRight();
                }
            }
        }
Ejemplo n.º 2
0
 private void 注销ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Dlg.ShowConfirmInfo("是否确定要注销?") == DialogResult.Yes)
     {
         Logout();
     }
 }
Ejemplo n.º 3
0
 private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Dlg.ShowConfirmInfo("是否确定要退出系统?") == DialogResult.Yes)
     {
         Close();
     }
 }
Ejemplo n.º 4
0
        private void tsbResetPass_Click(object sender, EventArgs e)
        {
            //Confirm
            if (Dlg.ShowConfirmInfo("确认要重置密码吗?") == DialogResult.No)
            {
                return;
            }
            if (dgvRY.SelectedRows.Count < 1)
            {
                Dlg.ShowErrorInfoAndHelp("请先选择要重置的用户");
                return;
            }
            int gh = Convert.ToInt32(dgvRY.SelectedRows[0].Cells["ColGH"].Value);

            using (FrmInput mForm = new FrmInput())
            {
                if (mForm.ShowDialog() == DialogResult.OK)
                {
                    string strPass = mForm.txtInput.Text.Trim();
                    strPass = MD5.Md5Encrypt(strPass);

                    string mSql = string.Format("update ptry set mm='{0}' where gh='{1}'", strPass, gh);
                    int    ret  = SqlHelper.ExecuteNonQuery(mSql);
                    if (ret > 0)
                    {
                        Dlg.ShowOKInfo("重置成功!");
                    }
                    else
                    {
                        Dlg.ShowErrorInfo("重置失败!");
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void tsbRYDel_Click(object sender, EventArgs e)
        {
            if (dgvRY.SelectedRows.Count == 0)
            {
                return;
            }
            string loginName = dgvRY.SelectedRows[0].Cells[ColLoginName.Index].Value.ToString();

            if (loginName == "admin")
            {
                Dlg.ShowErrorInfoAndHelp("admin不能进行删除!");
                return;
            }

            //Confirm
            if (Dlg.ShowConfirmInfo("确认要删除该用户吗?") == DialogResult.No)
            {
                return;
            }
            long   id   = Convert.ToInt64(dgvRY.SelectedRows[0].Cells[ColID.Index].Value);
            string mSql = string.Format("delete from t_users where id='{0}'", id);
            int    ret  = SqlHelper.ExecuteNonQuery(mSql);

            if (ret > 0)
            {
                InitRY();
            }
        }
Ejemplo n.º 6
0
        private void tsbRYDel_Click(object sender, EventArgs e)
        {
            if (dgvRY.SelectedRows.Count == 0)
            {
                return;
            }
            int gh = Convert.ToInt32(dgvRY.SelectedRows[0].Cells["ColGH"].Value);

            if (gh == 1001)
            {
                Dlg.ShowErrorInfoAndHelp("工号1001不能进行删除!");
                return;
            }
            //检查用户是否过做业务
            DbAccess DbAcs = new DbAccess(CommonClass.ConnStr);

            DbAcs.m_sSQL = string.Format("select count(*) from XTtradelist where operaterid='{0}'", gh);
            DataSet DS = DbAcs.GetDataSet();

            if (DS.ExtendedProperties["ReturnFlag"].ToString() != "0")
            {
                Dlg.ShowErrorInfo(DS.ExtendedProperties["ReturnFlag"].ToString());
                return;
            }
            if (DS.Tables[0].Rows[0][0].ToString() != "0")
            {
                Dlg.ShowErrorInfo("该用户已经做过业务,不能删除!");
                return;
            }
            //Confirm
            if (Dlg.ShowConfirmInfo("确认要删除该用户吗?") == DialogResult.No)
            {
                return;
            }
            string mSql = string.Format("delete from ptry where gh='{0}'", gh);
            int    ret  = SqlHelper.ExecuteNonQuery(mSql);

            if (ret > 0)
            {
                InitRY();
            }
        }
Ejemplo n.º 7
0
        private void tsbDel_Click(object sender, EventArgs e)
        {
            if (tvRYZ.SelectedNode == null)
            {
                Dlg.ShowErrorInfo("未选择要删除的角色!");
                return;
            }
            if (tvRYZ.SelectedNode.Text == "管理员")
            {
                Dlg.ShowErrorInfo("管理员角色不允许删除!");
                return;
            }
            //Check
            DbAccess DbAcs = new DbAccess(CommonClass.ConnStr);

            DbAcs.m_sSQL = string.Format("SELECT count(*) FROM [PTry] where JB={0}", tvRYZ.SelectedNode.Tag.ToString());
            DataSet DS = DbAcs.GetDataSet();

            if (DS.ExtendedProperties["ReturnFlag"].ToString() != "0")
            {
                Dlg.ShowErrorInfo(DS.ExtendedProperties["ReturnFlag"].ToString());
                return;
            }
            if (DS.Tables[0].Rows[0][0].ToString() != "0")
            {
                Dlg.ShowErrorInfo("该系统角色已经做过分配,不能删除!");
                return;
            }
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            if (Dlg.ShowConfirmInfo("确认要删除该角色吗?") == DialogResult.Yes)
            {
                string mSql = string.Format("delete from ptryz where zbh={0}", Convert.ToInt32(tvRYZ.SelectedNode.Tag));
                int    ret  = SqlHelper.ExecuteNonQuery(mSql);
                InitRYZ();
                InitRight();
            }
        }
Ejemplo n.º 8
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (blZhuxiao == false)
                {
                    if (Dlg.ShowConfirmInfo("确定退出系统?") == System.Windows.Forms.DialogResult.No)
                    {
                        e.Cancel = true;
                        return;
                    }
                    else
                    {
                        e.Cancel = false;
                        //return;

                        #region 取数据库备份参数
                        int    backupMode;
                        string backupPath;

                        string lsql = string.Format("SELECT IntCode,VcParam1 from SysParam where IntType=1");
                        using (DataTable dt = SqlHelper.GetData(lsql))
                        {
                            if (dt.Rows.Count == 0)
                            {
                                Dlg.ShowErrorInfoAndHelp("第一次使用,请设置数据库备份参数!");
                                e.Cancel = true;
                                return;
                            }
                            else
                            {
                                backupMode = Utils.StrToIntDef(dt.Rows[0]["IntCode"].ToString(), -1);
                                backupPath = Convert.ToString(dt.Rows[0]["VcParam1"]).Trim();
                            }

                            if ((backupMode < 0) || (backupMode > 2))
                            {
                                Dlg.ShowErrorInfo("数据库“备份选项”不正确,请设置!");
                                e.Cancel = true;
                                return;
                            }

                            if (backupMode != 2)
                            {
                                if (string.IsNullOrEmpty(backupPath) == true)
                                {
                                    if (Dlg.ShowConfirmInfo("数据库备份路径为空,请设置!") == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        e.Cancel = true;
                                        return;
                                    }
                                }
                                if ((!Directory.Exists(backupPath)) && CommonClass.SttDb.iDBType == 0)
                                {
                                    if (Dlg.ShowConfirmInfo("数据库备份路径在本机不存在,请设置!") == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        e.Cancel = true;
                                        return;
                                    }
                                }
                            }
                        }
                        #endregion

                        #region 备份
                        if (CommonClass.SttDb.iDBType == 0)
                        {
                            string dbFullName = Application.StartupPath + @"\DbMeter.mdb";
                            Cursor.Current = Cursors.WaitCursor;
                            CopyFileClass.Backup(backupMode, dbFullName, backupPath);
                            Cursor.Current = Cursors.Default;
                        }
                        else
                        {
                            if (backupMode == 0)
                            {
                                if (Dlg.ShowConfirmInfo("是否备份数据库") == System.Windows.Forms.DialogResult.Yes)
                                {
                                    Cursor.Current = Cursors.WaitCursor;
                                    string dbFullName = backupPath + "\\dbmeter" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak";
                                    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\(.*?\)");
                                    string dbName = regex.Match(CommonClass.SttDb.sDbInfo).ToString().Trim('(', ')');
                                    string mSql   = string.Empty;
                                    mSql = string.Format(@"BACKUP DATABASE {0} TO  DISK = N'{1}' WITH  INIT ,  NOUNLOAD , NAME = N'{0}备份',NOSKIP , STATS = 10, NOFORMAT", dbName, dbFullName);
                                    SqlHelper.ExecuteNonQuery(mSql);
                                    Cursor.Current = Cursors.Default;
                                }
                            }
                            else if (backupMode == 1)
                            {
                                Cursor.Current = Cursors.WaitCursor;
                                string dbFullName = backupPath + "\\dbmeter" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak";
                                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\(.*?\)");
                                string dbName = regex.Match(CommonClass.SttDb.sDbInfo).ToString().Trim('(', ')');
                                string mSql   = string.Empty;
                                mSql = string.Format(@"BACKUP DATABASE {0} TO  DISK = N'{1}' WITH  INIT ,  NOUNLOAD , NAME = N'{0}备份',NOSKIP , STATS = 10, NOFORMAT", dbName, dbFullName);
                                SqlHelper.ExecuteNonQuery(mSql);
                                Cursor.Current = Cursors.Default;
                            }
                        }
                        #endregion

                        //关闭启动窗体
                        myLogin.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Dlg.ShowErrorInfo(ex.Message);
                e.Cancel = true;
                return;
            }
        }