本文整理汇总了C#中DB.SQLResults方法的典型用法代码示例。如果您正苦于以下问题:C# DB.SQLResults方法的具体用法?C# DB.SQLResults怎么用?C# DB.SQLResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.SQLResults方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: 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;
}
}
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
}
}
示例7: UserMaintenance_Load
private void UserMaintenance_Load(object sender, EventArgs e)
{
DB db = new DB();
DataTable dtUT = db.SQLResults("usp_UserTypeList");
cboUserType.DataSource = dtUT;
cboUserType.DisplayMember = "Description";
cboUserType.ValueMember = "UserTypeID";
db.CleanUp();
}