当前位置: 首页>>代码示例>>C#>>正文


C# DB.AddParam方法代码示例

本文整理汇总了C#中DB.AddParam方法的典型用法代码示例。如果您正苦于以下问题:C# DB.AddParam方法的具体用法?C# DB.AddParam怎么用?C# DB.AddParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB.AddParam方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnLogin_Click

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text.Trim().Length <= 0)
            {
                MessageBox.Show("Please enter a valid username.");
                txtUsername.Focus();
                return;
            }
            else if (txtPassword.Text.Trim().Length <= 0)
            {
                MessageBox.Show("Please enter a valid password.");
                txtPassword.Focus();
                return;
            }
            else
            {
                int UserID = 0;
                DB db = new DB();
                try
                {
                    db.AddParam("@Username", txtUsername.Text.Trim());
                    db.AddParam("@Password", BMan_Encryption.EncryptPassword(txtPassword.Text.Trim(), ConfigurationManager.AppSettings["EncKey"]));
                    DataTable dtUser = db.SQLResults("usp_Login");
                    if (dtUser.Rows.Count > 0)
                    {
                        UserID = Convert.ToInt32(dtUser.Rows[0]["UserID"]);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "Login.btnLogin_Click");
                }
                finally
                {
                    db.CleanUp();
                }

                if (UserID > 0)
                {
                    Menu m = new Menu(UserID);
                    m.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Login or Password invalid. Please try again.");
                    txtPassword.Text = "";
                    txtPassword.Focus();
                    return;
                }
            }
        }
开发者ID:brneff,项目名称:IndianaWhiskey,代码行数:52,代码来源:Login.cs

示例2: Menu

        public Menu(int UserID)
        {
            Size MinButtonSize = new System.Drawing.Size(290, 30);

            InitializeComponent();
            if (UserID <= 0)
            {
                Login l = new Login();
                l.Show();
                this.Hide();
            }
            else
            {
                _userID = UserID;

                DB db = new DB();
                db.AddParam("@UserID", UserID);
                DataTable dtMenu = db.SQLResults("usp_MenuGet");

                foreach (DataRow dr in dtMenu.Rows)
                {
                    Button btn = new Button();
                    btn.AutoSize = true;
                    btn.BackColor = Color.Azure;
                    btn.MinimumSize = MinButtonSize;
                    btn.Text = dr["DisplayName"].ToString();
                    btn.Name = dr["MenuID"].ToString();
                    btn.Margin = new Padding(3,0,0,0);
                    btn.Click += new EventHandler(btnMenu_Click);

                    flpMenu.Controls.Add(btn);
                }
            }
        }
开发者ID:brneff,项目名称:IndianaWhiskey,代码行数:34,代码来源:Menu.cs

示例3: btnMenu_Click

        protected void btnMenu_Click(object sender, EventArgs e)
        {
            DB db = new DB();
            db.AddParam("@MenuID", ((Button)sender).Name);
            DataTable dt = db.SQLResults("usp_MenuGetByID");

            Assembly assembly = Assembly.Load("IndianaWhiskey");
            Type t = assembly.GetType("IndianaWhiskey." + dt.Rows[0]["FormName"].ToString());
            Form frmNext = (Form)Activator.CreateInstance(t, _userID);

            frmNext.Show(this);
            this.Hide();
        }
开发者ID:brneff,项目名称:IndianaWhiskey,代码行数:13,代码来源:Menu.cs

示例4: GetUserName

        private string GetUserName(int userID)
        {
            string strUserName = "";

            DB db = new DB();
            db.AddParam("@UserID", userID);
            DataTable dt = db.SQLResults("usp_UserNameGet");
            if (dt.Rows.Count >= 1 && dt.Rows[0]["UserName"] != null && dt.Rows[0]["UserName"] != DBNull.Value)
                strUserName = dt.Rows[0]["UserName"].ToString();
            db.CleanUp();

            return strUserName;
        }
开发者ID:brneff,项目名称:IndianaWhiskey,代码行数:13,代码来源:PageHeader.cs

示例5: PopulateComboBox

        public static void PopulateComboBox(string storedProc, ComboBox cbo, string colName, string colValue, List<SqlParameter> lstParams, BindingContext bindingContext)
        {
            if (cbo != null)
            {
                DB db = new DB();
                if (lstParams != null)
                {
                    foreach (SqlParameter p in lstParams)
                    {
                        db.AddParam(p.ParameterName, p.Value);
                    }
                }

                DataTable dt = db.SQLResults(storedProc);
                cbo.DataSource = dt;
                cbo.DisplayMember = colName;
                cbo.ValueMember = colValue;
                cbo.BindingContext = bindingContext;
            }
        }
开发者ID:brneff,项目名称:IndianaWhiskey,代码行数:20,代码来源:Common.cs

示例6: btnSave_Click

 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtFirstName.Text.Trim().Length <= 0)
     {
         MessageBox.Show("Please enter a first name.");
         txtFirstName.Focus();
         return;
     }
     else if (txtLastName.Text.Trim().Length <= 0)
     {
         MessageBox.Show("Please enter a last name.");
         txtLastName.Focus();
         return;
     }
     else if (txtUsername.Text.Trim().Length <= 0)
     {
         MessageBox.Show("Please enter a username.");
         txtUsername.Focus();
         return;
     }
     else if (txtPassword.Text.Trim().Length <= 0)
     {
         MessageBox.Show("Please enter a password.");
         txtPassword.Focus();
         return;
     }
     else if (txtPasswordConfirm.Text.Trim().Length <= 0)
     {
         MessageBox.Show("Please confirm your password.");
         txtPasswordConfirm.Focus();
         return;
     }
     else if (txtPassword.Text.Trim() != txtPasswordConfirm.Text.Trim())
     {
         MessageBox.Show("Passwords do not match. Please try again.");
         txtPassword.Text = "";
         txtPasswordConfirm.Text = "";
         txtPassword.Focus();
         return;
     }
     else if (cboUserType.SelectedIndex < 0)
     {
         MessageBox.Show("Please select a user type.");
         cboUserType.Focus();
         return;
     }
     else
     {
         UserID = 0;
         DB db = new DB();
         try
         {
             db.AddParam("@FirstName", txtFirstName.Text.Trim());
             db.AddParam("@LastName", txtLastName.Text.Trim());
             db.AddParam("@Username", txtUsername.Text.Trim());
             db.AddParam("@Password", BMan_Encryption.EncryptPassword(txtPassword.Text.Trim(), ConfigurationManager.AppSettings["EncKey"]));
             db.AddParam("@UserTypeID", cboUserType.SelectedValue);
             DataTable dtUser = db.SQLResults("usp_UserAdd");
             if (dtUser.Rows.Count > 0)
             {
                 UserID = Convert.ToInt32(dtUser.Rows[0]["UserID"]);
             }
         }
         catch (Exception ex)
         {
             Common.LogError(ex, "UserMaintenance.btnSave_Click");
             UserID = 0;
         }
         finally
         {
             db.CleanUp();
         }
         if (UserID > 0)
         {
             Menu m = new Menu(UserID);
             m.Show();
             this.Hide();
         }
         else if (UserID == -1)
         {
             MessageBox.Show("Username already exists. Please enter a different one.");
             txtUsername.Focus();
             return;
         }
         else
         {
             MessageBox.Show("Error adding user. Please try again.");
             return;
         }
     }
 }
开发者ID:brneff,项目名称:IndianaWhiskey,代码行数:91,代码来源:UserMaintenance.cs


注:本文中的DB.AddParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。