Good Idea.. Thank you, but where do i write the conditional statement? Just a little illustration please
Xonel
Posts
-
Setting users access permissions on tabs in C# tabcontrol -
Setting users access permissions on tabs in C# tabcontrolHi I have a desktop C# application that is basically built on Tab control. I have 8 tabs and i need to have different domains to be selected(e.g Admin, clerk, bursar, secretary) on my login where when a user under a specific domain clicks on a certain tab, an event is generated that prevents him from viewing the content of that tab. I was thinking of it this way...
private void Form1\_Load(object sender, EventArgs e) { if ((Thread.CurrentPrincipal.IsInRole("admin"))) // admin in this case should be a domain name. { tabPage4.Hide(); } else { MessageBox.Show("You must be a member of the Manager or Administrator's roles to view username and password information", "Insufficient Permissions", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
But now instead of
CurrentPrincipal.IsInRole
put something that will read the domain name. Something of that sort. I'll appreciate any help Thank you
-
C Sharp Login with different user privilegeI was thinking of it this way...
private void Form1\_Load(object sender, EventArgs e) { if ((Thread.CurrentPrincipal.IsInRole("admin"))) // admin in this case should be a domain name. { tabPage4.Hide(); } else { MessageBox.Show("You must be a member of the Manager or Administrator's roles to view username and password information", "Insufficient Permissions", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
But now instead of
CurrentPrincipal.IsInRole
put something that will read the domain name. Something of that sort. I'll appreciate any help Thank you
-
C Sharp Login with different user privilegeIt is a desktop application
-
C Sharp Login with different user privilegePlease give me a simple guide line... Thank you
-
C Sharp Login with different user privilegeHello I have an application that is basically built on Tab control. I have 8 tabs and i need to have different domains(e.g Admin, clerk, bursar, secretary) on my login where when a user under a specific domain clicks on a certain tab, an event is generated that prevents him from viewing the content of that tab Any advice please???
-
Validating textboxes in C#Nop....This is not VB
-
Validating textboxes in C#A simple example please?? :)
-
Validating textboxes in C#Hi This code here below allows only numbers and one decimal point to be typed on a textbox. It does not prevent you from: 1. Saving nulls in the database 2. From pasting any other character(words, asterisks,numbers etc) to the textbox. What do i have to add to the code to prevent the two problems from occurring?? Here is my code:
private void txtBalance\_TextChanged(object sender, EventArgs e) { txtBalance.KeyPress += new KeyPressEventHandler(numbercheck\_KeyPress); } private void numbercheck\_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.') { e.Handled = true; } //only allow one decimal point if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1) { e.Handled = true; } }
Please help me figure out Thanks
-
Mortgage Calculator Error:) Can't believe it was that simple.... Thanks a lot! It worked.. :)
-
Mortgage Calculator ErrorWhen i write it like this
txtPayment.Text = (int)payment;
am getting this error
Cannot implicitly convert type 'int' to 'string'
with a blue line under '(int)'
-
Mortgage Calculator ErrorHi, I have this error in my code that am having difficulties in rectifying it. Initially, my code looked like this..
private void CalculateTheMortgage()
{
// (Loan Value) * (1 + r/12) ^ p = (12x / r) * ((1 + r/12)^p - 1)
// payment = (((Loan Value) * (1 + r/12) ^ p) * r)/ (12 * ((1 + r/12)^p - 1)));
double loanAmount = (double)txtLoanAmount.CurrentValue; // price of total mortgage before down payment
double taxesPerYear = (double)txtPropertyTax.CurrentValue; // this will divided by 12 and added to the monthly payment
double downPayment = (double)txtDownPayment.CurrentValue; // down payment will be subtracted from the loan
double interestRate = (double)udInterest.Value / 100; // calculate interest from 100%
double termOfLoan = (double)(udTerm.Value * 12); // monthly term
double propertyTax = (double)txtPropertyTax.CurrentValue;
double insurance = (double)txtInsurance.CurrentValue;double payment = (loanAmount - downPayment) \* (Math.Pow((1 + interestRate/12), termOfLoan) \* interestRate)/(12 \* (Math.Pow((1+interestRate/12), termOfLoan) - 1)); // add on a monthly property tax payment = payment + (propertyTax + insurance) / 12; txtPayment.CurrentValue = (int)payment; }
and i changed it a little to this...
private void CalculateTheMortgage()
{
// (Loan Value) * (1 + r/12) ^ p = (12x / r) * ((1 + r/12)^p - 1)
// payment = (((Loan Value) * (1 + r/12) ^ p) * r)/ (12 * ((1 + r/12)^p - 1)));
double loanAmount = Convert.ToDouble(txtLoanAmount.Text);// price of total mortgage before down payment
double taxesPerYear = Convert.ToDouble(txtPropertyTax.Text); // this will divided by 12 and added to the monthly payment
double downPayment = Convert.ToDouble(txtDownPayment.Text); // down payment will be subtracted from the loan
double interestRate = (double)udInterest.Value / 100; // calculate interest from 100%
double termOfLoan = (double)(udTerm.Value * 12); // monthly term
double propertyTax = Convert.ToDouble(txtPropertyTax.Text);
double insurance = Convert.ToDouble(txtInsurance.Text);double payment = (loanAmount - downPayment) \* (Math.Pow((1 + interestRate / 12), termOfLoan) \* interestRate) / (12 \* (Math.Pow((1 + inter
-
how to retrieve data from mysql database and display it into textbox in c#Thank you guyz, You gave me ideas and it worked. :) This is the code that worked...
private void btnView_Click(object sender, EventArgs e)
{
string input = cmbMemberId.Text;
string conn = "server=[servername];user=[username];password=[userpassword];database=[databasename];";MySqlConnection myconn = new MySqlConnection(conn); string sql = "SELECT Member\_ID, First\_Name, ...., ......, ....., ....., ...., EMAIL FROM addmember WHERE Member\_ID = @ID;"; MySqlDataAdapter da = new MySqlDataAdapter(sql, myconn); da.SelectCommand.Parameters.AddWithValue("@ID", input); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 0) { MessageBox.Show("No data found.", "Not Exists"); } else { foreach (DataRow dr in dt.Rows) { if (dr\[0\] + "" == input) { cmbMemberId.Text = dr\[0\] + ""; txtFirstName.Text = dr\[1\].ToString(); ..... ..... ..... ..... .... .... txtEmail.Text = dr\[8\].ToString(); break; } } } }
Thank you soo much.
-
how to retrieve data from mysql database and display it into textbox in c#Hi, I have this code below that is not working like i want it to and has no errors when i debug. I want it to display a member values in respective textboxes that are in a table called 'addpeople' by a click of a button AFTER i key in the member ID of a member. Text boxes are like; Title member ID First name Last Name Address 1 Address 2 .... ... ... Email.. Here is the code:
private void btnView_Click(object sender, EventArgs e)
{string input = cmbMemberId.Text; string conn = "server=localhost;user=root;password='';database=m\_chama;"; MySqlConnection myconn = new MySqlConnection(conn); string sql = "SELECT \* FROM addmember WHERE Member\_ID = '" + input + "';"; MySqlDataAdapter da = new MySqlDataAdapter(sql, myconn); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 0) { MessageBox.Show("No data found.", "Not Exists"); } else { foreach (DataRow dr in dt.Rows) { if (dr\[0\] + "" == input) { txtFirstName.Text = dr\[0\] + ""; break; } } } }
-
iserting,deleting,updating mysql database FROM form in C#Hello, Am new in Programming and i chose to start with C#. I have an application that am building but am unable to connect my 'Add a member' form to a MySql database. I have created text boxes for first name, last name, phone, city and down there an ADD and CANCEL buttons. Could someone please give me the code to link the add button to the database such that the information on the text box is sent to the database. Please help out like you doing it to a two year old. Thanks.