コード例 #1
0
        private void tsbRYSave_Click(object sender, EventArgs e)
        {
            if ((dgvRY.SelectedRows.Count < 1) || (txtID.Text == ""))
            {
                Dlg.ShowErrorInfoAndHelp("请先选择要保存的用户");
                return;
            }
            if (txtLoginName.Text.Trim() == string.Empty)
            {
                toolTip1.Show("登录名不能为空", txtLoginName, 0, txtLoginName.Height, 2000);
                return;
            }
            if (txtUserName.Text.Trim() == string.Empty)
            {
                toolTip1.Show("姓名不能为空", txtUserName, 0, txtUserName.Height, 2000);
                return;
            }
            ry ry = new ry();

            ry.ID        = Convert.ToInt64(txtID.Text);
            ry.LoginName = txtLoginName.Text;
            ry.UserName  = txtUserName.Text.Trim();

            ry.AreaCode        = txtAreaCode.Text.Trim();
            ry.IntDepartmentID = Convert.ToInt32(cmbDepart.SelectedValue);
            ry.IntRoleID       = Convert.ToInt32(cmbRole.SelectedValue);

            ry.DepartmentName = cmbDepart.Text.Trim(); //部门名称
            ry.OperRight      = cmbRole.Text.Trim();   //权限名称


            int ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from t_users where loginName='{0}' and id <> {1}", ry.LoginName, ry.ID)));

            if (ret > 0)
            {
                toolTip1.Show("该登陆名已存在,请重新输入", txtLoginName, 0, txtLoginName.Height, 2000);
                txtLoginName.Focus();
                return;
            }


            if ((ry.LoginName.ToLower() == "admin"))
            {
                Dlg.ShowErrorInfoAndHelp("员工admin不允许修改!");
                return;
            }

            //string mSql = string.Format("update t_users set loginName='{0}',UserName='******',userChar='{2}',intdepartmentID='{3}',IntRoleID={4} where id='{5}'", ry.LoginName, ry.UserName, ry.AreaCode,ry.IntDepartmentID,ry.IntRoleID,ry.ID);

            //添加部门名称和权限名称字段
            string mSql = string.Format("update t_users set loginName='{0}',UserName='******',userChar='{2}',intdepartmentID='{3}',IntRoleID={4},DepartmentName='{6}',OperRight='{7}' where id='{5}'", ry.LoginName, ry.UserName, ry.AreaCode, ry.IntDepartmentID, ry.IntRoleID, ry.ID, ry.DepartmentName, ry.OperRight);

            ret = SqlHelper.ExecuteNonQuery(mSql);
            if (ret > 0)
            {
                InitRY();
                SelectRow(ry.ID);
                Dlg.ShowOKInfo("修改成功!");
            }
        }
コード例 #2
0
ファイル: ManageUserRight.cs プロジェクト: zymITsky/ss
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (tvRYZ.SelectedNode == null)
            {
                Dlg.ShowErrorInfoAndHelp("请选择用户的角色以分配权限!");
                return;
            }
            if (tvRYZ.SelectedNode.Text == "管理员")
            {
                Dlg.ShowErrorInfoAndHelp("管理员角色不允许修改权限!");
                return;
            }
            int           ryzbh = Convert.ToInt32(tvRYZ.SelectedNode.Tag);
            List <string> mSqls = new List <string>();

            mSqls.Add(string.Format("delete from ptzqx where ryzbh={0} and MKBH in (select MKBH from PTcd where MKBH <> '0000' and (cardtype in (-1,-2) or cardtype ={1}))", ryzbh, CommonClass.SttIC.iCardType));
            foreach (TreeNode tn in tvRight.Nodes)
            {
                AddSqlStr(ref mSqls, tn, ryzbh);
            }
            int ret = SqlHelper.ExecuteSqls(mSqls.ToArray());

            if (ret == 0)
            {
                Dlg.ShowOKInfo("保存成功");
                return;
            }
            else
            {
                Dlg.ShowErrorInfo("保存失败");
                return;
            }
        }
コード例 #3
0
        private void btnAudit_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes == MessageBox.Show("确认复核通过?", "提示", MessageBoxButtons.YesNo))
            {
                int    ret         = 0;
                string auditString = "";
                foreach (DataGridViewRow mRow in dgvNoTicketAudit.Rows)
                {
                    if (Convert.ToBoolean(mRow.Cells["ColumnChecked"].Value) == true)
                    {
                        auditString += mRow.Cells["idDataGridViewTextBoxColumn"].Value + ",";
                    }
                }
                auditString = auditString.TrimEnd(',');

                if (auditString == "")
                {
                    Dlg.ShowErrorInfoAndHelp("没有选择要复核的记录");
                    return;
                }

                string mSql = string.Format("UPDATE T_NoTicket SET P2 = '{0}',P3 = '{1}', AuditDate = GETDATE()  WHERE Id IN ({2})", "复核已通过", Classes.PubClass.UserId, auditString);
                ret = SqlHelper.ExecuteNonQuery(mSql);
                if (ret > 0)
                {
                    Dlg.ShowOKInfo("保存成功");
                    //刷新页面
                    refresh();
                }
                else
                {
                    Dlg.ShowErrorInfo("保存失败");
                }
            }
        }
コード例 #4
0
ファイル: ManageMenu.cs プロジェクト: zymITsky/ss
        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();
                }
            }
        }
コード例 #5
0
        private void btnSave1_Click(object sender, EventArgs e)
        {
            string ConnStr = null;

            //ConnStr = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", txtAccess.Text);
            ConnStr = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=True;Jet OLEDB:Database Password=meiyoumima2011", txtAccess.Text);

            try
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration("PubClasses.dll");

                config.ConnectionStrings.ConnectionStrings.Remove("PubClasses.Properties.Settings.Setting_ConnStr");
                config.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings("PubClasses.Properties.Settings.Setting_ConnStr", ConnStr, "System.Data.OleDb"));
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("ConnectionStrings");
                // My.Settings.ConnectionString = config.ConnectionStrings.ConnectionStrings("一卡通.Properties.Settings.Default.ConnectionString").ToString
                //MsgBox(My.Settings.ConnectionString)
                Dlg.ShowOKInfo("保存成功,程序将重新启动");
                Application.Exit();
                System.Diagnostics.Process.Start(Application.ExecutablePath.ToString());
            }
            catch (Exception ex)
            {
                Dlg.ShowErrorInfo(ex.Message.ToString());
            }
        }
コード例 #6
0
        public static void Restore(string PFileName)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title            = "数据库恢复";
            openFileDialog1.InitialDirectory = Application.StartupPath;
            openFileDialog1.Filter           = "备份文件(*.mdb)|*.mdb";
            openFileDialog1.ShowDialog();

            string strOldFile = openFileDialog1.FileName;

            if (strOldFile == PFileName)
            {
                Dlg.ShowErrorInfo("文件已存在!");
                return;
            }

            try
            {
                FileInfo fileInfo1 = new FileInfo(strOldFile);
                fileInfo1.CopyTo(PFileName, true);
                Dlg.ShowOKInfo("数据库恢复成功!");
                return;
            }
            catch
            {
                throw;
            }
        }
コード例 #7
0
ファイル: ManageUserRight.cs プロジェクト: zymITsky/ss
        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("重置失败!");
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 刷新查询数据
        /// </summary>
        private void refresh()
        {
            string mSql = @" SELECT a.[Id] ,
                    c.[UserName] ,
                    b.[CompanyName] ,
                    a.[ProjectName] ,
                    a.[SumMoney] ,
                    a.[SumMoney]*1.28 '含税金额' ,
                    a.[SalaryDate] ,
                    a.[Status] ,
                    d.UserName[AuditId] ,
                    a.[AuditDate],
                    a.p2,
                    e.UserName[p3]
            FROM[dbo].T_NoTicket a
                    LEFT JOIN T_Users c ON a.UserName = c.id
                    LEFT JOIN T_Users d ON a.AuditId = d.id
                    LEFT JOIN T_Users e ON a.p3 = e.id
                    LEFT JOIN dbo.T_Customers b ON a.CustomerName = b.id
            WHERE   1 = 1 and p1='正常' and a.Status='审批已通过' {0} {1} {2} {3} {4}";//

            string mC1 = "", mC2 = "", mC3 = "", mC4 = "", sDept = "";

            if (cmbUserName.Text != string.Empty)
            {
                mC1 = " and c.username like '%" + cmbUserName.Text + "%'";
            }

            if (cmbCustomers.Text != string.Empty)
            {
                mC2 = " and b.companyname like '%" + cmbCustomers.Text + "%'";
            }

            if (cmbHasAudit.Text != string.Empty)
            {
                mC3 = " and a.P2='" + cmbHasAudit.Text + "'";
            }
            if (CBoxDept.Text != string.Empty)
            {
                sDept = " and c.DepartmentName like '%" + CBoxDept.Text + "%'";
            }

            if (dtpStart.Checked == true)
            {
                mC4 = " and a.SalaryDate between '" + dtpStart.Value.Date.ToString("yyyy-MM-dd") + "' and '" + dtpEnd.Value.Date.ToString("yyyy-MM-dd") + "'";
            }

            mSql = string.Format(mSql, mC1, mC2, mC3, mC4, sDept);

            var mTable = SqlHelper.GetData(mSql);

            dgvNoTicketAudit.DataSource = mTable;
            if (mTable.Rows.Count < 1)
            {
                Dlg.ShowOKInfo("没有记录");
                return;
            }
        }
コード例 #9
0
 private void UserControlBase_DoubleClick(object sender, EventArgs e)
 {
     if ((ModifierKeys & Keys.Control) == Keys.Control)
     {
         FileVersionInfo FileVerInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
         string          sInfo       = string.Format("程序集版本:{0}\n   产品版本:{1}\n   文件版本:{2}", Assembly.GetExecutingAssembly().GetName().Version
                                                     , FileVerInfo.ProductVersion, FileVerInfo.FileVersion);
         Dlg.ShowOKInfo(sInfo);
     }
 }
コード例 #10
0
        private void tsbRYAdd_Click(object sender, EventArgs e)
        {
            TrimTextBox();
            if (txtLoginName.Text.Trim() == string.Empty)
            {
                toolTip1.Show("登录名不能为空", txtLoginName, 0, txtLoginName.Height, 2000);
                return;
            }
            if (txtUserName.Text.Trim() == string.Empty)
            {
                toolTip1.Show("姓名不能为空", txtUserName, 0, txtUserName.Height, 2000);
                return;
            }



            ry ry = new ry();

            ry.LoginName       = txtLoginName.Text.Trim();
            ry.UserName        = txtUserName.Text.Trim();
            ry.AreaCode        = txtAreaCode.Text.Trim();
            ry.IntDepartmentID = Convert.ToInt32(cmbDepart.SelectedValue);
            ry.IntRoleID       = Convert.ToInt32(cmbRole.SelectedValue);

            ry.DepartmentName = cmbDepart.Text.Trim(); //部门名称
            ry.OperRight      = cmbRole.Text.Trim();   //权限名称

            int ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from t_users where loginName='{0}'", ry.LoginName)));

            if (ret > 0)
            {
                toolTip1.Show("该登陆名已存在,请重新输入", txtLoginName, 0, txtLoginName.Height, 2000);
                txtLoginName.Focus();
                return;
            }

            // string mSql = string.Format("insert into t_users(loginname,UserName,userChar,IntDepartmentID,IntRoleID,userstatus,PassWord) values ('{0}','{1}','{2}',{3},{4},'正常','{5}')", ry.LoginName, ry.UserName, ry.AreaCode, ry.IntDepartmentID, ry.IntRoleID, MD5.Md5Encrypt("1"));

            //添加部门名称和权限名称
            string mSql = string.Format("insert into t_users(loginname,UserName,userChar,IntDepartmentID,IntRoleID,userstatus,PassWord,DepartmentName,OperRight) values ('{0}','{1}','{2}',{3},{4},'正常','{5}','{6}','{7}')", ry.LoginName, ry.UserName, ry.AreaCode, ry.IntDepartmentID, ry.IntRoleID, MD5.Md5Encrypt("1"), ry.DepartmentName, ry.OperRight);



            ret = SqlHelper.ExecuteNonQuery(mSql);
            if (ret > 0)
            {
                InitRY();
                mSql       = string.Format("select id from t_users where loginname='{0}'", ry.LoginName);
                ry.ID      = Convert.ToInt64(SqlHelper.ExecuteScalar(mSql));
                txtID.Text = ry.ID.ToString();
                SelectRow(ry.ID);
                Dlg.ShowOKInfo("添加成功,初始密码1!");
            }
        }
コード例 #11
0
        private void btnAudit2_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes == MessageBox.Show("确认审批不通过?", "提示", MessageBoxButtons.YesNo))
            {
                int    ret         = 0;
                string auditString = "";
                foreach (DataGridViewRow mRow in dgvNoTicketAudit.Rows)
                {
                    if (Convert.ToBoolean(mRow.Cells["ColumnChecked"].Value) == true)
                    {
                        auditString += mRow.Cells["idDataGridViewTextBoxColumn"].Value + ",";
                    }
                }
                auditString = auditString.TrimEnd(',');
                if (auditString == "")
                {
                    Dlg.ShowErrorInfoAndHelp("没有选择要审批的记录");
                    return;
                }

                string mSql = string.Format("UPDATE T_NoTicket SET Status = '{0}',AuditId = '{1}', AuditDate = GETDATE()  WHERE (Id IN ({2}))", "审批未通过", Classes.PubClass.UserId, auditString);

                ret = SqlHelper.ExecuteNonQuery(mSql);
                if (ret > 0)
                {
                    Dlg.ShowOKInfo("保存成功!");

                    //修改页面显示2016.9.6
                    refresh();

                    //foreach (DataGridViewRow mRow in dgvExAllocation.Rows)
                    //{
                    //    if (Convert.ToBoolean(mRow.Cells["ColumnChecked"].Value) == true)
                    //    {
                    //        dgvExAllocation.Rows.Remove(mRow);
                    //    }
                    //}
                }
                else
                {
                    Dlg.ShowErrorInfo("保存失败");
                }
            }
        }
コード例 #12
0
        public static void RefreshSection(string mConnStr)
        {
            try
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                config.ConnectionStrings.ConnectionStrings.Remove("PubClasses.Properties.Settings.Setting_ConnStr");
                config.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings("PubClasses.Properties.Settings.Setting_ConnStr", mConnStr, "System.Data.OleDb"));
                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("ConnectionStrings");

                Dlg.ShowOKInfo("保存成功,程序将重新启动");
                Application.Restart();
            }
            catch (Exception ex)
            {
                Dlg.ShowErrorInfo(ex.Message.ToString());
            }
        }
コード例 #13
0
        private void btnTest1_Click(object sender, EventArgs e)
        {
            string ConnStr = null;

            ConnStr = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=True;Jet OLEDB:Database Password=meiyoumima2011", txtAccess.Text);
            //;Persist Security Info=True;Jet OLEDB:Database Password=
            OleDbConnection mConn = new OleDbConnection(ConnStr);

            try
            {
                mConn.Open();
                mConn.Close();
                Dlg.ShowOKInfo("连接成功");
                BtnSaveAccess.Enabled = true;
            }
            catch (Exception ex)
            {
                Dlg.ShowErrorInfo(ex.Message.ToString());
                BtnSaveAccess.Enabled = false;
            }
        }
コード例 #14
0
ファイル: ManageUserRight.cs プロジェクト: zymITsky/ss
 private void tsbAddRole_Click(object sender, EventArgs e)
 {
     using (FrmInput mForm = new FrmInput())
     {
         if (mForm.ShowDialog() == DialogResult.OK)
         {
             int iRet = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(*) from ptryz where ZMC='{0}'", mForm.txtInput.Text.Trim())));
             if (iRet > 0)
             {
                 Dlg.ShowErrorInfoAndHelp("该角色已存在,请重新创建!");
                 return;
             }
             iRet = SqlHelper.ExecuteNonQuery(string.Format("insert into ptryz(zmc)values('{0}')", mForm.txtInput.Text.Trim()));
             InitRYZ();
             if (iRet != 0)
             {
                 Dlg.ShowOKInfo("创建成功!");
             }
         }
     }
 }
コード例 #15
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            string ConnStr = null;

            //Provider=SQLOLEDB;Data Source=.;Integrated Security=SSPI;Initial Catalog=DBMeter
            ConnStr = string.Format("Provider=SQLOLEDB;Data Source={0},{1};Password={2};User ID={3};Initial Catalog={4}", txtAddress.Text, txtPort.Text, txtDBPass.Text, txtDBUser.Text, txtDBName.Text);

            OleDbConnection mConn = new OleDbConnection(ConnStr);

            try
            {
                mConn.Open();
                mConn.Close();
                Dlg.ShowOKInfo("连接成功");
                BtnSave.Enabled = true;
            }
            catch (Exception ex)
            {
                Dlg.ShowErrorInfo(ex.Message.ToString());
                BtnSave.Enabled = false;
            }
        }
コード例 #16
0
        /// <summary>
        /// 刷新查询数据
        /// </summary>
        private void refresh()
        {
            string mSql = @"select ms.Id,ms.datadate,un.username userid,cn.companyname customerid,ms.cardid,ca.cardname cardname,ca.cardbalance,edu.ed,ms.mealmoney,ms.recdate,ms.status,an.username auditid,ms.auditdate,p.DepartmentName,P.username IntUsedID from t_meals ms
left join t_users un on ms.userid = un.id
left join t_customers cn on ms.customerid = cn.id
left join t_cards ca on ms.cardid = ca.id
left join t_users [an] on ms.operid = an.id
left join t_users P on ms.IntUsedID = P.id
left join (select isnull(ss.salesum,0) - isnull(gs.GiftSum,0)-isnull(ms.mealsum,0) ed,a.id from t_users a
left join
(select sum(summoney)/200 salesum ,username from T_Saledetails where saledate between (convert(varchar(4),getdate(),120) + '-01-01') and (convert(varchar(4),getdate(),120) + '-12-31') group by username) ss on a.id = ss.username
left join
(select sum(GiftSum) giftsum,IntUsedID from t_GiftStockOut where datadate between (convert(varchar(4),getdate(),120) + '-01-01') and (convert(varchar(4),getdate(),120) + '-12-31') and status not in('已删除','审核未通过','已提交等待领导审核') group by IntUsedID) gs on a.id = gs.IntUsedID
left join 
(select sum(mealmoney) mealsum,IntUsedID from t_meals where  datadate between (convert(varchar(4),getdate(),120) + '-01-01') and (convert(varchar(4),getdate(),120) + '-12-31') and status not in('已删除','已提交等待领导审核') group by IntUsedID) ms on a.id = ms.IntUsedID
) edu on ms.IntUsedID = edu.id
where ms.status <> '已删除' {0} {1} {2} {3} {4} {5}";//
            string mC1 = "", mC2 = "", mC3 = "", mC4 = "", sDept = "", sUsedEmp = "";

            if (cmbUserName.Text != string.Empty)
            {
                mC1 = "and un.username like '%" + cmbUserName.Text + "%'";
            }
            if (CBoxUsed.Text != string.Empty)
            {
                sUsedEmp = "and P.username like '%" + CBoxUsed.Text + "%'";
            }
            if (cmbCustomers.Text != string.Empty)
            {
                mC2 = "and cn.companyname like '%" + cmbCustomers.Text + "%'";
            }
            if (cmbCards.Text != string.Empty)
            {
                mC3 = "and ca.cardname like '%" + cmbCards.Text + "%'";
            }
            if (cmbHasAudit.Text != string.Empty)
            {
                //dgvExAllocation.Columns["ColumnChecked"].Visible = false;
                if (cmbHasAudit.Text == "未审核")
                {
                    mC4 = "and ms.status='已提交等待领导审核'";
                    //dgvExAllocation.Columns["ColumnChecked"].Visible = true;
                }
                else if (cmbHasAudit.Text == "审核未通过")
                {
                    mC4 = "and ms.status='" + cmbHasAudit.Text + "'";
                }
                else //已通过
                {
                    mC4 = "and ms.status not in('审核未通过','已提交等待领导审核')";
                }
            }
            if (CBoxDept.Text != string.Empty)
            {
                sDept = "and P.DepartmentName like '%" + CBoxDept.Text + "%'";
            }
            mSql = string.Format(mSql, mC1, mC2, mC3, mC4, sDept, sUsedEmp);

            var mTable = SqlHelper.GetData(mSql);

            dgvExAllocation.DataSource = mTable;
            if (mTable.Rows.Count < 1)
            {
                Dlg.ShowOKInfo("没有记录");
                return;
            }
        }
コード例 #17
0
ファイル: ManageMenu.cs プロジェクト: zymITsky/ss
        private void tsbModify_Click(object sender, EventArgs e)
        {
            string MKBH;

            if (tvRight.SelectedNode == null)
            {
                Dlg.ShowErrorInfoAndHelp("请选择要修改的模块!");
                return;
            }
            MKBH = ((ModuleList)tvRight.SelectedNode.Tag).MKBH;
            ModuleList ml = new ModuleList();

            ml.MKBH = txtMKBH.Text.Trim();
            ml.MKMC = txtMKMC.Text.Trim();
            ml.MKTP = cmbTP.Text;
            ml.BBH  = txtBBH.Text.Trim();

            ml.CardType = Convert.ToInt32(cmbCardType.SelectedValue);

            if (ml.MKBH == "")
            {
                toolTip1.Show("模块编号不能为空!", txtMKBH, 0, txtMKBH.Height, 2000);
                return;
            }
            if (ml.MKMC == "")
            {
                toolTip1.Show("模块名称不能为空!", txtMKMC, 0, txtMKMC.Height, 2000);
                return;
            }
            if (ml.BBH == "")
            {
                toolTip1.Show("模块版本号不能为空!", txtBBH, 0, txtBBH.Height, 2000);
                return;
            }

            int           ret;
            string        mSql;
            List <string> mSqls = new List <string>();

            if (MKBH != ml.MKBH)
            {
                ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from ptcd where mkbh='{0}'", ml.MKBH)));
                if (ret > 0)
                {
                    toolTip1.Show("该模块编号已存在!", txtMKBH, 0, txtMKBH.Height, 2000);
                    return;
                }
            }
            if (rbZCD.Checked == true)
            {
                ml.MKWJM     = "";
                ml.MKHSM     = "";
                ml.MKJB      = 1;
                ml.MKFCD     = "0000";
                ml.FastStart = "0";
            }
            else
            {
                if (ml.MKWJM == "")
                {
                    toolTip1.Show("模块文件名不能为空!", txtMKWJM, 0, txtMKWJM.Height, 2000);
                    return;
                }
                if (ml.MKHSM == "")
                {
                    toolTip1.Show("模块函数名不能为空!", txtMKWJM, 0, txtMKWJM.Height, 2000);
                    return;
                }
                ml.FastStart = Convert.ToInt32(cbFastStart.Checked).ToString();
                ml.MKJB      = 2;
                ml.MKFCD     = cmbFCD.SelectedValue.ToString();
                ml.MKWJM     = txtMKWJM.Text.Trim();
                ml.MKHSM     = txtMKHSM.Text.Trim();
            }
            mSql = string.Format("update ptcd set mkbh='{0}',mkmc='{1}',mkjb='{2}',mkfcd='{3}',mktp='{4}',mkwjm='{5}',mkhsm='{6}',faststart='{7}',bbh='{8}',cardtype={9} where mkbh='{10}'", ml.MKBH, ml.MKMC, ml.MKJB, ml.MKFCD, ml.MKTP, ml.MKWJM, ml.MKHSM, ml.FastStart, ml.BBH, ml.CardType, MKBH);
            mSqls.Add(mSql);
            mSql = string.Format("update ptcd set mkfcd ='{0}' where mkfcd='{1}'", ml.MKBH, MKBH);
            mSqls.Add(mSql);
            ret = SqlHelper.ExecuteSqls(mSqls.ToArray());
            if (ret == 0)
            {
                InitRight();
                //tvRight.BeginUpdate();
                //try
                //{
                //    TreeNode[] mNodes = tvRight.Nodes.Find(ml.MKBH, true);
                //    if (mNodes.Length > 0)
                //        tvRight.SelectedNode = mNodes[0];
                //}
                //finally
                //{
                //    tvRight.EndUpdate();
                //}
                Dlg.ShowOKInfo("修改成功!");
            }
        }
コード例 #18
0
        /// <summary>
        /// 复制文件
        /// </summary>
        /// <param name="fromFile">要复制的文件</param>
        /// <param name="toFolder">要复制到的文件夹</param>
        /// <returns></returns>
        public static void Backup(int backupMode, string fromFile, string toDirectory)
        {
            try
            {
                if (backupMode == 2)
                {
                    //toDirectory = @"C:\Windows\Data";
                    toDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\一卡通数据备份";
                }
                if (Directory.Exists(toDirectory) == false)
                {
                    Directory.CreateDirectory(toDirectory);
                }

                string   toFile;
                FileInfo fileInfo1;

                switch (backupMode)
                {
                case 0:    //提示
                    SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
                    SaveFileDialog1.Title            = "数据库备份";
                    SaveFileDialog1.InitialDirectory = toDirectory;
                    SaveFileDialog1.FileName         = string.Format("DBMeter_{0}", DateTime.Now.ToString("yyyyMMdd_HHmmss")); //备份文件名
                    SaveFileDialog1.Filter           = "备份文件(*.mdb)|*.mdb";

                    if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        toFile = SaveFileDialog1.FileName;

                        if (toFile == fromFile)
                        {
                            return;
                        }
                        fileInfo1 = new FileInfo(fromFile);
                        fileInfo1.CopyTo(toFile, false);
                        Dlg.ShowOKInfo("数据库备份成功!");
                    }
                    break;

                case 1:    //不提示
                    toFile = string.Format(toDirectory + @"\DBMeter_{0}.mdb", DateTime.Now.ToString("yyyyMMdd_HHmmss"));

                    if (toFile == fromFile)
                    {
                        return;
                    }
                    fileInfo1 = new FileInfo(fromFile);
                    fileInfo1.CopyTo(toFile, true);
                    //Dlg.ShowOKInfo("数据库备份成功!");
                    break;

                case 2:    //自动备份到C盘
                    DirectoryInfo directoryInfo1 = new DirectoryInfo(toDirectory);
                    FileInfo[]    fileArr        = directoryInfo1.GetFiles("DBMeter_Auto_*.mdb");

                    //排序,按创建时间从大到小
                    for (int i = 0; i < fileArr.Length; i++)
                    {
                        for (int j = i; j < fileArr.Length; j++)
                        {
                            if (fileArr[i].CreationTime < fileArr[j].CreationTime)
                            {
                                FileInfo temp = fileArr[i];
                                fileArr[i] = fileArr[j];
                                fileArr[j] = temp;
                            }
                        }
                    }
                    //只留创建时间最大的2个
                    for (int i = 2; i < fileArr.Length; i++)
                    {
                        File.Delete(fileArr[i].FullName);
                    }

                    //备份文件名
                    toFile = string.Format(toDirectory + @"\DBMeter_Auto_{0}.mdb", DateTime.Now.ToString("yyyyMMdd_HHmmss"));

                    if (toFile == fromFile)
                    {
                        return;
                    }
                    fileInfo1 = new FileInfo(fromFile);
                    fileInfo1.CopyTo(toFile, true);
                    //Dlg.ShowOKInfo("数据库备份成功!");
                    break;

                default:
                    return;
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #19
0
ファイル: ManageMenu.cs プロジェクト: zymITsky/ss
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ModuleList ml = new ModuleList();

            ml.MKBH     = txtMKBH.Text.Trim();
            ml.MKMC     = txtMKMC.Text.Trim();
            ml.MKTP     = cmbTP.Text;
            ml.BBH      = txtBBH.Text.Trim();
            ml.CardType = Convert.ToInt32(cmbCardType.SelectedValue);

            if (ml.MKBH == "")
            {
                toolTip1.Show("模块编号不能为空!", txtMKBH, 0, txtMKBH.Height, 2000);
                return;
            }
            if (ml.MKMC == "")
            {
                toolTip1.Show("模块名称不能为空!", txtMKMC, 0, txtMKMC.Height, 2000);
                return;
            }
            if (ml.BBH == "")
            {
                toolTip1.Show("模块版本号不能为空!", txtBBH, 0, txtBBH.Height, 2000);
                return;
            }

            int    ret;
            string mSql;

            ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from ptcd where mkbh='{0}'", ml.MKBH)));
            if (ret > 0)
            {
                toolTip1.Show("该模块编号已存在!", txtMKBH, 0, txtMKBH.Height, 2000);
                return;
            }
            if (rbZCD.Checked == true)
            {
                ml.MKJB      = 1;
                ml.MKFCD     = "0000";
                ml.MKWJM     = "";
                ml.MKHSM     = "";
                ml.FastStart = "0";
                mSql         = string.Format("insert into ptcd(mkbh,mkmc,mkjb,mkfcd,mktp,bbh,cardtype) values('{0}','{1}','{2}','{3}','{4}','{5}',{6})", ml.MKBH, ml.MKMC, ml.MKJB, ml.MKFCD, ml.MKTP, ml.BBH, ml.CardType);
            }
            else
            {
                if (ml.MKWJM == "")
                {
                    toolTip1.Show("模块文件名不能为空!", txtMKWJM, 0, txtMKWJM.Height, 2000);
                    return;
                }
                if (ml.MKHSM == "")
                {
                    toolTip1.Show("模块函数名不能为空!", txtMKWJM, 0, txtMKWJM.Height, 2000);
                    return;
                }
                if (cmbFCD.SelectedIndex == -1)
                {
                    toolTip1.Show("请选择父菜单!", cmbFCD, 0, cmbFCD.Height, 2000);
                    return;
                }
                ml.FastStart = Convert.ToInt32(cbFastStart.Checked).ToString();
                ml.MKJB      = 2;
                ml.MKFCD     = cmbFCD.SelectedValue.ToString();
                ml.MKWJM     = txtMKWJM.Text.Trim();
                ml.MKHSM     = txtMKHSM.Text.Trim();
                mSql         = string.Format("insert into ptcd(mkbh,mkmc,mkjb,mkfcd,mktp,mkwjm,mkhsm,faststart,bbh,cardtype) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',{9})", ml.MKBH, ml.MKMC, ml.MKJB, ml.MKFCD, ml.MKTP, ml.MKWJM, ml.MKHSM, ml.FastStart, ml.BBH, ml.CardType);
            }
            ret = SqlHelper.ExecuteNonQuery(mSql);
            if (ret > 0)
            {
                InitRight();
                Dlg.ShowOKInfo("创建成功");
            }
        }
コード例 #20
0
ファイル: FrmModifyPass.cs プロジェクト: zymITsky/ss
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtNewPass.Text.Trim() == string.Empty)
            {
                Dlg.ShowErrorInfo("新密码不能为空");
                return;
            }
            if (txtRePass.Text.Trim() == string.Empty)
            {
                Dlg.ShowErrorInfo("确认密码不能为空");
                return;
            }
            if (txtNewPass.Text.Trim().Equals(txtRePass.Text.Trim()) == false)
            {
                Dlg.ShowErrorInfo("新密码与确认密码不符");
                return;
            }

            try
            {
                //检查旧密码是否正确
                string _sPass = txtOldPass.Text.Trim();
                string mSql;
                //加密
                _sPass = MD5.Md5Encrypt(_sPass);
                mSql   = string.Format("SELECT mm FROM PTry WHERE gh='{0}' ", txtGH.Text.Trim());

                DataTable mTable = SqlHelper.GetData(mSql);
                if (mTable == null)
                {
                    Dlg.ShowErrorInfo("获取操作员信息失败!");
                    return;
                }
                if (mTable.Rows.Count < 1)
                {
                    Dlg.ShowErrorInfo("工号输入错误!");
                    return;
                }
                if (_sPass != mTable.Rows[0]["mm"].ToString())
                {
                    Dlg.ShowErrorInfo("原密码输入错误");
                    return;
                }

                //修改用户密码
                string _NewPass = txtNewPass.Text.Trim();
                _NewPass = MD5.Md5Encrypt(_NewPass);

                mSql = string.Format("update ptry set mm ='{0}' where gh='{1}'", _NewPass, txtGH.Text.Trim());

                int ret = SqlHelper.ExecuteNonQuery(mSql);

                if (ret > 0)
                {
                    Dlg.ShowOKInfo("修改成功!");
                    txtOldPass.Text = "";
                    txtNewPass.Text = "";
                    txtRePass.Text  = "";
                    return;
                }
                else
                {
                    Dlg.ShowOKInfo("修改失败!");
                    return;
                }
            }
            catch (Exception ex)
            {
                Dlg.ShowErrorInfo(ex.Message);
                return;
            }
        }
コード例 #21
0
ファイル: ManageUserRight.cs プロジェクト: zymITsky/ss
        private void tsbRYAdd_Click(object sender, EventArgs e)
        {
            TrimTextBox();
            if (TBGH.Text.Trim() == string.Empty)
            {
                toolTip1.Show("工号不能为空", TBGH, 0, TBGH.Height, 2000);
                return;
            }
            if (TBXM.Text.Trim() == string.Empty)
            {
                toolTip1.Show("姓名不能为空", TBXM, 0, TBXM.Height, 2000);
                return;
            }
            if (Utils.StrToIntDef(TBGH.Text, -1) == -1)
            {
                Dlg.ShowErrorInfoAndHelp("请输入四位数字工号,且不能与已有工号重复!");
                TBGH.SelectAll();
                TBGH.Focus();
                return;
            }
            if (TBDH.Text != "")
            {
                if (Utils.StrToIntDef(TBDH.Text, -1) == -1)
                {
                    Dlg.ShowErrorInfoAndHelp("请输入正确的电话号码数字!");
                    TBDH.SelectAll();
                    TBDH.Focus();
                    return;
                }
            }

            ry ry = new ry();

            ry.GH  = Convert.ToInt32(TBGH.Text);
            ry.XM  = TBXM.Text.Trim();
            ry.XB  = "男";
            ry.DH  = TBDH.Text.Trim();
            ry.SH  = Convert.ToInt32(CBoxSH.SelectedValue);
            ry.RYZ = Convert.ToInt32(CBoxRole.SelectedValue);
            if (rbFemale.Checked == true)
            {
                ry.XB = "女";
            }
            int ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from ptry where gh='{0}'", ry.GH)));

            if (ret > 0)
            {
                toolTip1.Show("该工号已存在,请重新输入", TBGH, 0, TBGH.Height, 2000);
                TBGH.Focus();
                return;
            }

            string mSql = string.Format("insert into ptry(gh,xm,xb,dh,sh,jb,zt,mm) values ({0},'{1}','{2}','{3}',{4},{5},'0','{6}')", ry.GH, ry.XM, ry.XB, ry.DH, ry.SH, ry.RYZ, MD5.Md5Encrypt("1001"));

            ret = SqlHelper.ExecuteNonQuery(mSql);
            if (ret > 0)
            {
                InitRY();
                SelectRow(ry.GH);
                Dlg.ShowOKInfo("添加成功,初始密码1001!");
            }
        }
コード例 #22
0
ファイル: ManageUserRight.cs プロジェクト: zymITsky/ss
        private void tsbRYSave_Click(object sender, EventArgs e)
        {
            if (dgvRY.SelectedRows.Count < 1)
            {
                Dlg.ShowErrorInfoAndHelp("请先选择要保存的用户");
                return;
            }
            if (TBGH.Text.Trim() == string.Empty)
            {
                toolTip1.Show("工号不能为空", TBGH, 0, TBGH.Height, 2000);
                return;
            }
            if (TBXM.Text.Trim() == string.Empty)
            {
                toolTip1.Show("姓名不能为空", TBXM, 0, TBXM.Height, 2000);
                return;
            }
            ry ry = new ry();

            ry.GH  = Convert.ToInt32(TBGH.Text);
            ry.XM  = TBXM.Text.Trim();
            ry.XB  = "男";
            ry.DH  = TBDH.Text.Trim();
            ry.SH  = Convert.ToInt32(CBoxSH.SelectedValue);
            ry.RYZ = Convert.ToInt32(CBoxRole.SelectedValue);
            if (rbFemale.Checked == true)
            {
                ry.XB = "女";
            }
            int gh = Convert.ToInt32(dgvRY.SelectedRows[0].Cells["ColGH"].Value);
            int ret;

            if (gh != ry.GH)
            {
                Dlg.ShowErrorInfoAndHelp("已经创建的员工不允许修改其工号!");
                return;
                //if (gh == 1001)
                //{
                //    Dlg.ShowErrorInfoAndHelp("员工1001不允许修改工号!");
                //    return;
                //}
                //ret = Convert.ToInt32(SqlHelper.ExecuteScalar(string.Format("select count(1) from ptry where gh={0}", ry.GH)));
                //if (ret > 0)
                //{
                //    toolTip1.Show("该工号已存在,请重新输入", TBGH, 0, TBGH.Height, 2000);
                //    TBGH.Focus();
                //    return;
                //}
            }
            if ((gh == 1001) && (ry.RYZ != (int)dgvRY.SelectedRows[0].Cells["ColJB"].Value))
            {
                Dlg.ShowErrorInfoAndHelp("员工1001不允许修改权限!");
                return;
            }
            string mSql = string.Format("update ptry set gh='{0}',xm='{1}',xb='{2}',dh='{3}',sh={4},jb={5} where gh='{6}'", ry.GH, ry.XM, ry.XB, ry.DH, ry.SH, ry.RYZ, gh);

            ret = SqlHelper.ExecuteNonQuery(mSql);
            if (ret > 0)
            {
                InitRY();
                SelectRow(ry.GH);
                Dlg.ShowOKInfo("修改成功!");
            }
        }