Thursday, 15 May, 2008
Baur
App_Code\GData.cs
using System;
using System.Data;
...
public class UserInfo
{
private static string pin;
public static string Pin
{
get { return pin; }
set { pin = value; }
}
private static string fio;
public static string Fio
{
get { return fio; }
set { fio = value; }
}
}
public class QData
{
...
public class GData
{
public static void SetUserInfoPIN(string pin)
{
UserInfo.Pin = pin;
}
public static string GetUserInfoPIN()
{
return UserInfo.Pin;
}
...
}
Read more…
Saturday, 26 April, 2008
Baur
The switch statement chooses flow of control based on the evaluation of a
numeric or string comparison.The switch statement does not allow control to fall
through to the next case as in C/C++ unless the case statement is followed
immediately by another case statement. In other words, you must use a break statement
with every case statement.You can also use a goto statement, although most
programmers frown on using them. Here are two examples:
int j = 0;
int i = 1;
switch (i)
{
case 1:j = 7;break;
case 2:
case 3:j = 22;break;
default:j = 33; break;
}
...
string lastName = "";
string text = "fred";
switch ( text )
{
case "fred":lastName = "Flinstone";break;
case "barney":lastName = "Rubble";break;
default:lastName = "Slate";break;
}
Thursday, 24 April, 2008
Baur
Getting Visitors IP Address:
There are two ways, either by using:
HttpContext.Current.Request.UserHostAddress;
or
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
The Following Line will get the IP Address of the machine instead of Proxy’s IP
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Getting Server’s IP address:
string strHostName = Dns.GetHostName ();
IPHostEntry ipEntry = Dns.GetHostByName (strHostName);
IPAddress [ ] addr = ipEntry.AddressList;
for(int i=0;i< addr.Length;i++)
{
lblServerIP.Text=lblServerIP.Text+"The Server IP address is"+addr[i].ToString()+"\n";
}
Thursday, 24 April, 2008
Baur
void FillDropDownLists()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ASPGConnectionString"].ConnectionString);
SqlCommand commGetDept = new SqlCommand("select id, dept from s_dept where id in (select dept from s_users) order by dept", conn);
try
{
conn.Open();
SqlDataReader res = commGetDept.ExecuteReader();
ListDepts.DataTextField = "dept";
ListDepts.DataValueField = "id";
ListDepts.DataSource = res;
ListDepts.DataBind();
ListDepts.Items.Insert(0, "Все");
res.Close();
}
catch (SqlException sqlex)
{
//ErrMess.Text = sqlex.Message;
return;
}
catch
{
return;
}
finally
{
if (conn.State != ConnectionState.Closed) conn.Close();
}
}
Thursday, 24 April, 2008
Baur
Any data
——————————————————
store:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="admins" value="esetov_b, lobanov_v"/>
</appSettings>
...
get:
string admins = ConfigurationManager.AppSettings["Admins"];
Connection String
——————————————————
store
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ASPGConnectionString" connectionString="Data Source=DS;Initial Catalog=basename;Persist Security Info=True;User ID=user;Password=psw"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
...
get
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["ASPGConnectionString"].ConnectionString);
Wednesday, 23 April, 2008
Baur
string domen = HttpContext.Current.User.Identity.Name;
int pos = domen.IndexOf("\\");
string UserName = domen.Substring(pos + 1);
Wednesday, 23 April, 2008
Baur
declare:
public class UserInfo
{
private static string pin;
public static string Pin
{
get { return pin; }
set { pin = value; }
}
}
using:
UserInfo.Pin = userdata["pin"].ToString();
string pin = UserInfo.Pin;
Recent Comments