by ssi
18. October 2013 16:54
static void Main(string[] args)
{
Console.WriteLine("string.Fomat() is may favorite method in c#");
string sOuput = string.Format("Whatever you put after the comma converts to a string");
Console.WriteLine(sOuput);
object[] array = new object[8];
array[0] = 1000;
array[1] = DateTime.Parse("1/1/2013");
array[2] = "Cadence bank";
array[3] = DateTime.Now;
array[4] = 'A';
array[5] = null;
array[6] = true;
array[7] = "ross";
for (int i = 0; i <= array.GetUpperBound(0); i++)
{
sOuput = string.Format("{0}", array[i]);
Console.WriteLine(sOuput);
}
Console.ReadLine();
}
70f07ef0-a431-4309-8467-24eade389044|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: string.Fomat
CSharp
by ssi
11. September 2013 10:57
private void SetColumns()
{
ssiMethods.clsStaticMethods.SetupGrid(dataGridView1, Color.LightSalmon, false);
for (int c = 0; c < dataGridView1.Columns.Count; c++)
{
DataGridViewColumn column = dataGridView1.Columns[c];
column.HeaderText = column.HeaderText.Replace("_", " ").ToUpper();
column.Width = 125;
if (column.HeaderText.Contains("AMOUNT"))
{
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
column.DefaultCellStyle.Format = "##0.00";
column.Width = 100;
}
if (column.HeaderText.Contains("STATUS"))
column.Width = 85;
}
}
by ssi
11. September 2013 10:55
Dynamic LINQ clause with Join that allows items to be concatenated.
if (FormLoaded)
{
var loans = dc.TRACKING_FILEs;
var status = dc.TRACKING_FILE_As;
var results = loans.Join(status, sta => sta.Loan_ID, tr => tr.Loan_ID,
(tr, sta) => new { tr.Loan_ID, tr.f463_loan_status, tr.f450_loan_officer_code, tr.f2b1_last_name_buyer, tr.F430B1_dob_buyer, tr.f413_application_date, tr.f426_disbursement_date, tr.f7001_Buyer_1_First_and_Last_Name, tr.f13B1_B1_Curr_Street, tr.f14B1_B1_Curr_City, tr.f15B1_B1_Curr_St_Zip, tr.f440b1_Buyers_mailing_street_address, tr.f441b1_Buyers_mailing_city_State_zip, sta.f447b1_b1_email_address }).OrderBy(c => c.Loan_ID)
.Select(r => new { r.Loan_ID, r.f450_loan_officer_code, r.f463_loan_status, r.f2b1_last_name_buyer, r.F430B1_dob_buyer, r.f413_application_date, r.f426_disbursement_date, r.f7001_Buyer_1_First_and_Last_Name, r.f13B1_B1_Curr_Street, r.f14B1_B1_Curr_City, r.f15B1_B1_Curr_St_Zip, r.f440b1_Buyers_mailing_street_address, r.f441b1_Buyers_mailing_city_State_zip, r.f447b1_b1_email_address });
if (!string.IsNullOrEmpty(cbLO.Text))
{
results = results.Where(r => r.f450_loan_officer_code == cbLO.Text);
}
if (rbApplicationDate.Checked)
results = results.Where(c => c.f413_application_date >= dtpStart.Value.Date
& c.f413_application_date <= dtpEnd.Value.Date);
if (rbDisbursementDate.Checked)
results = results.Where(c => c.f426_disbursement_date >= dtpStart.Value.Date
& c.f426_disbursement_date <= dtpEnd.Value.Date);
if (ckStatus.Checked)
results = results.Where(c => c.f463_loan_status == cbStatus.Text);
dataGridView1.DataSource = results;
lblStatus.Text = string.Format("Record Count: {0:#,##0}", results.Count());
SetColumns();
}
dd5d9de4-3358-4960-9fa8-21c6f4107ac1|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: linq, c# Linq.Join
by ssi
11. September 2013 10:33
Dynamic LINQ clause with Join that allows items to be concatenated.
if (FormLoaded)
{
var loans = dc.TRACKING_FILEs;
var status = dc.TRACKING_FILE_As;
var results = loans.Join(status, sta => sta.Loan_ID, tr => tr.Loan_ID,
(tr, sta) => new { tr.Loan_ID, tr.f463_loan_status, tr.f450_loan_officer_code, tr.f2b1_last_name_buyer, tr.F430B1_dob_buyer, tr.f413_application_date, tr.f426_disbursement_date, tr.f7001_Buyer_1_First_and_Last_Name, tr.f13B1_B1_Curr_Street, tr.f14B1_B1_Curr_City, tr.f15B1_B1_Curr_St_Zip, tr.f440b1_Buyers_mailing_street_address, tr.f441b1_Buyers_mailing_city_State_zip, sta.f447b1_b1_email_address }).OrderBy(c => c.Loan_ID)
.Select(r => new { r.Loan_ID, r.f450_loan_officer_code, r.f463_loan_status, r.f2b1_last_name_buyer, r.F430B1_dob_buyer, r.f413_application_date, r.f426_disbursement_date, r.f7001_Buyer_1_First_and_Last_Name, r.f13B1_B1_Curr_Street, r.f14B1_B1_Curr_City, r.f15B1_B1_Curr_St_Zip, r.f440b1_Buyers_mailing_street_address, r.f441b1_Buyers_mailing_city_State_zip, r.f447b1_b1_email_address });
if (!string.IsNullOrEmpty(cbLO.Text))
{
results = results.Where(r => r.f450_loan_officer_code == cbLO.Text);
}
if (rbApplicationDate.Checked)
results = results.Where(c => c.f413_application_date >= dtpStart.Value.Date
& c.f413_application_date <= dtpEnd.Value.Date);
if (rbDisbursementDate.Checked)
results = results.Where(c => c.f426_disbursement_date >= dtpStart.Value.Date
& c.f426_disbursement_date <= dtpEnd.Value.Date);
if (ckStatus.Checked)
results = results.Where(c => c.f463_loan_status == cbStatus.Text);
dataGridView1.DataSource = results;
lblStatus.Text = string.Format("Record Count: {0:#,##0}", results.Count());
SetColumns();
}
fd63240c-63e9-4544-a896-923c4d53f6dd|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: linq, c# Linq.Join
linq
by ssi
28. August 2013 08:29
by ssi
4. July 2013 18:10
Create a cookie and store the user id and password.On the blur event of textbox of userid access the password from the cookie and set it.then do this code on Login1_LoggedIN Event like below
protected
void
Login1_LoggedIN(
object
sender, EventArgs e)
{
CheckBox rm = (CheckBox)Login1.FindControl(
"RememberMe"
);
if
(rm.Checked)
{
HttpCookie myCookie =
new
HttpCookie(
"myCookie"
);
Response.Cookies.Remove(
"myCookie"
);
Response.Cookies.Add(myCookie);
myCookie.Values.Add(
"Email"
,
this
.Login1.UserName.ToString());
myCookie.Values.Add(
"Pass"
,
this
.Login1.Password.ToString());
DateTime dtExpiry = DateTime.Now.AddDays(15);
//you can add years and months too here
Response.Cookies[
"myCookie"
].Expires = dtExpiry;
}
}
and then
do
this
code on Page_Load Event
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
if
(Request.Cookies[
"myCookie"
] !=
null
)
{
HttpCookie cookie = Request.Cookies.Get(
"myCookie"
);
string
emailID = cookie.Values[
"Email"
].ToString();
string
password = cookie.Values[
"Pass"
].ToString();
if
(Membership.ValidateUser(emailID, password))
{
FormsAuthentication.RedirectFromLoginPage(emailID,
true
);
}
}
}
}
<
asp:Login
ID
=
"Login1"
runat
=
"server"
OnLoggedIn
=
"Login1_LoggedIN"
/>
Becky replied to Becky on 24-Jan-11 11:43 AM
Sent from my iDevice.
by ssi
15. June 2013 11:24
Security is mostly a superstition. It does not exist in nature nor do the children of man as a whole experience it. Avoiding danger is no safer in the long run than outright exposure. Life is either a daring adventure or nothing.
Helen Keller
f34fe6fe-8523-46c6-96a0-09006080186c|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags:
Security
by ssi
4. May 2013 20:04
Initializing Arrays
C# provides simple and straightforward ways to initialize arrays at declaration time by enclosing the initial values in curly braces ({}). The following examples show different ways to initialize different kinds of arrays.
Note If you do not initialize an array at the time of declaration, the array members are automatically initialized to the default initial value for the array type. Also, if you declare the array as a field of a type, it will be set to the default value null when you instantiate the type.
Single-Dimensional Array
int[] numbers = new int[5] {1, 2, 3, 4, 5};
string[] names = new string[3] {"Matt", "Joanne", "Robert"};
You can omit the size of the array, like this:
int[] numbers = new int[] {1, 2, 3, 4, 5};
string[] names = new string[] {"Matt", "Joanne", "Robert"};
You can also omit the new operator if an initializer is provided, like this:
int[] numbers = {1, 2, 3, 4, 5};
string[] names = {"Matt", "Joanne", "Robert"};
Multidimensional Array
int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = new string[2, 2] { {"Mike","Amy"}, {"Mary","Albert"} };
You can omit the size of the array, like this:
int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = new string[,] { {"Mike","Amy"}, {"Mary","Albert"} };
You can also omit the new operator if an initializer is provided, like this:
int[,] numbers = { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = { {"Mike", "Amy"}, {"Mary", "Albert"} };
Jagged Array (Array-of-Arrays)
You can initialize jagged arrays like this example:
int[][] numbers = new int[2][] { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
You can also omit the size of the first array, like this:
int[][] numbers = new int[][] { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
-or-
int[][] numbers = { new int[] {2,3,4}, new int[] {5,6,7,8,9} };
Notice that there is no initialization syntax for the elements of a jagged array.
Accessing Array Members
Accessing array members is straightforward and similar to how you access array members in C/C++. For example, the following code creates an array called numbers
and then assigns a 5
to the fifth element of the array:
f9d4f967-c13c-459f-8ee6-d23c248cc057|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: Arrays
CSharp
by ssi
4. May 2013 17:49
{
string sSQL = "UPDATE tbl_Loan SET BorrowerName = @BorrowerName "
+ ",DateCreated = @DateCreated"
+ ",DateDue = @DateDue"
+ ",DateClosedString = @DateClosedString"
+ ",Suspensedescription = @Suspensedescription"
+ " WHERE Id = @RecordId ";
OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(ConnectionString);
OleDbCommand Cmd = new OleDbCommand(sSQL, objConn);
Cmd.Parameters.Add(new OleDbParameter("@BorrowerName", txtBorrowerName.Text));
Cmd.Parameters.Add(new OleDbParameter("@DateCreated", txtDateCreated.Text));
Cmd.Parameters.Add(new OleDbParameter("@DateDue", txtDateDue.Text));
Cmd.Parameters.Add(new OleDbParameter("@DateClosedString", txtClosed.Text));
Cmd.Parameters.Add(new OleDbParameter("@Suspensedescription", txtDesc.Text));
Cmd.Parameters.Add(new OleDbParameter("@RecordId", RecordID));
objConn.Open();
int nResult = Cmd.ExecuteNonQuery();
objConn.Close();
lblResult.Text = string.Format("Result: {0}", nResult == 1 ? "saved" : "err saving");
}
by ssi
4. May 2013 17:46
Properties.Settings.Default.AccessFilePathAndname;
if (File.Exists(sAccessFilePath))
{
ConnectionString = SuspenseMgrAccess.Properties.Settings.Default.AccessConnectionString;
OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(ConnectionString);
String QueryString = "SELECT * FROM tbl_Loan";
OleDbCommand Cmd = new OleDbCommand(QueryString, objConn);
objConn.Open();
OleDbDataReader reader = Cmd.ExecuteReader();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(QueryString, objConn);
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);
DataTable table = new DataTable();
dataAdapter.Fill(table);
dataGridView1.DataSource = table;
objConn.Close();
}