Ejemplo n.º 1
0
        /// <summary>
        /// 增加用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string usertype = getUserType(cmbType.Text);

            if (usertype == null)
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0049I", db.Language);
                MessageBox.Show(msg);
                return;
            }
            int    id        = 0;
            String fieldlist = "UserID,UserName,UserPwd,UserRight,UpperUserID";
            String valuelist = "'" + txtUser.Text + "','" + txtName.Text + "','"
                               + NCCryp.Encrypto(txtPassword.Text) + "','"
                               + usertype + "','" + db.UserID + "'";

            if (db.SetUser(0, 0, fieldlist,
                           "", valuelist, out id))
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0043I", db.Language);
                MessageBox.Show(msg);
                init();
            }
            else
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0044I", db.Language);
                MessageBox.Show(msg);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新用户
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         string usertype = getUserType(cmbType.Text);
         if (usertype == null)
         {
             string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0049I", db.Language);
             MessageBox.Show(msg);
             return;
         }
         int    id       = 0;
         String wheresql = "UserId='" + txtUser.Text + "' and UpperUserID='" + db.UserID + "'";
         String valuesql = "UserName='******',UserPwd='" + NCCryp.Encrypto(txtPassword.Text)
                           + "',UserRight='" + usertype + "'";
         if (db.SetUser(0, 1, "", wheresql, valuesql, out id) && id == 1)
         {
             string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0045I", db.Language);
             MessageBox.Show(msg);
             init();
         }
         else
         {
             string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0046I", db.Language);
             MessageBox.Show(msg);
         }
     }
     else
     {
         string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0042I", db.Language);
         MessageBox.Show(msg);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 配置値设定
        /// </summary>
        private Boolean SetDatabaseConfig()
        {
            NdnXmlConfig xmlConfig;

            xmlConfig = new NdnXmlConfig(NCConst.CONFIG_FILE_DIR + NCUtility.GetAppConfig());
            string strConnectionString = string.Format(
                "Data Source={0};Initial Catalog={1};User ID={2};Password={3}",
                txtDataSource.Text, txtDatabase.Text, txtUser.Text, NCCryp.Encrypto(txtPwd.Text));
            string str = "ConnectionString";

            if (!xmlConfig.WriteValue("database", str, strConnectionString))
            {
                string msg = string.Format(NCMessage.GetInstance(db.Language).GetMessageById("CM0450E", db.Language), str);
                NCLogger.GetInstance().WriteErrorLog(msg);
                return(false);
            }
            strConnectionString = string.Format(
                "Data Source={0};Initial Catalog={1};User ID={2};Password={3}",
                txtDataSource.Text, "master", txtUser.Text, NCCryp.Encrypto(txtPwd.Text));
            str = "MConnectionString";
            if (!xmlConfig.WriteValue("database", str, strConnectionString))
            {
                string msg = string.Format(NCMessage.GetInstance(db.Language).GetMessageById("CM0450E", db.Language), str);
                NCLogger.GetInstance().WriteErrorLog(msg);
                return(false);
            }
            return(SetDatabaseConfig2());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Owner
        /// </summary>
        /// <returns></returns>
        private Boolean isOwner()
        {
            DataSet ds       = new DataSet();
            String  wheresql = "UserID='" + db.UserID + "'";

            if (db.GetUser(0, 0, "*", wheresql, "", ref ds) && ds.Tables[0].Rows.Count == 1)
            {
                if (ds.Tables[0].Rows[0]["UserPwd"].ToString() == NCCryp.Encrypto("zjhuen123"))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            DataSet ds       = new DataSet();
            String  wheresql = "UserId='" + txtUser.Text + "' and UserPwd='" + NCCryp.Encrypto(txtOldPwd.Text) + "'";

            if (db.GetUser(0, 0, "*", wheresql, "", ref ds) && ds.Tables[0].Rows.Count == 1)
            {
                int id = 0;
                if (db.SetUser(0, 1, "", wheresql, "UserPwd='" + NCCryp.Encrypto(txtNewPwd.Text) + "'", out id) && id == 1)
                {
                    DialogResult = DialogResult.OK;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            DataSet ds       = new DataSet();
            String  wheresql = "UserName='******' and UserPwd='" + NCCryp.Encrypto(txtPwd.Text) + "'";

            if (db.GetUser(0, 0, "*", wheresql, "", ref ds) && ds.Tables[0].Rows.Count == 1)
            {
                db.UserID    = ds.Tables[0].Rows[0]["UserID"].ToString();
                db.UserRight = ds.Tables[0].Rows[0]["UserRight"].ToString();
                DialogResult = DialogResult.OK;
            }
            else
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0011I", db.Language);
                MessageBox.Show(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPwd.Text = "";
                txtPwd.Focus();
            }
        }