string.Fomat() is may favorite method in c#

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();
 
        }

Tags:

CSharp

Set DataGridView Columns

by ssi 11. September 2013 10:57

private void SetColumns()
{
ssiMethods.clsStaticMethods.SetupGrid(dataGridView1, Color.LightSalmon, false);



for (int c = 0; c &lt; dataGridView1.Columns.Count; c++)
{
DataGridViewColumn column = dataGridView1.Columns[c];
column.HeaderText = column.HeaderText.Replace(&quot;_&quot;, &quot; &quot;).ToUpper();

column.Width = 125;
if (column.HeaderText.Contains(&quot;AMOUNT&quot;))
{
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
column.DefaultCellStyle.Format = &quot;##0.00&quot;;
column.Width = 100;
}
if (column.HeaderText.Contains(&quot;STATUS&quot;))
column.Width = 85;
}

}

Tags: , ,

Blog | CSharp

Dynamic Where clause

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();             }

Tags: ,

Dynamic Where clause

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();             }

Tags: ,

linq

JQuery code when using Master Pages.

by ssi 28. August 2013 08:29

This might give you an idea on how to structure JQuery code when using Master Pages.

 

http://jquerybyexample.blogspot.com/2012/05/things-to-remember-while-using-jquery.html

Tags: , ,

Asp.net

Remember Me checkbox

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
Thank you! It woked!
 
 
 


 Sent from my iDevice. 

Tags:

Asp.net

Security Security

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

Tags:

Security

Arrays

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:

Tags:

CSharp

private void btnSave_Click(object sender, EventArgs e)

by ssi 4. May 2013 17:49
{
string sSQL = &quot;UPDATE tbl_Loan SET BorrowerName = @BorrowerName &quot;
+ &quot;,DateCreated = @DateCreated&quot;
+ &quot;,DateDue = @DateDue&quot;
+ &quot;,DateClosedString = @DateClosedString&quot;
+ &quot;,Suspensedescription = @Suspensedescription&quot;
+ &quot; WHERE Id = @RecordId &quot;;

OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(ConnectionString);

OleDbCommand Cmd = new OleDbCommand(sSQL, objConn);

Cmd.Parameters.Add(new OleDbParameter(&quot;@BorrowerName&quot;, txtBorrowerName.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@DateCreated&quot;, txtDateCreated.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@DateDue&quot;, txtDateDue.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@DateClosedString&quot;, txtClosed.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@Suspensedescription&quot;, txtDesc.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@RecordId&quot;, RecordID));

objConn.Open();
int nResult = Cmd.ExecuteNonQuery();
objConn.Close();
lblResult.Text = string.Format(&quot;Result: {0}&quot;, nResult == 1 ? &quot;saved&quot; : &quot;err saving&quot;);
}

Tags: , ,

Blog | CSharp

string sAccessFilePath = SuspenseMgrAccess

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 = &quot;SELECT * FROM tbl_Loan&quot;;
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();
}

Tags: , ,

Blog | CSharp

Calendar

<<  May 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

""If everyone is thinking alike, someone isn't thinking.""
- General George Patton Jr