LoginPage

Login page

Simple Login Page

Username Password

Senin, 15 Oktober 2018

Send email smtpClient using Gmail Account

I just got the knowledge how to send an email using gmail account by smtpclient.
The sample is using C#.

SmtpClient client = new SmtpClient();                    
client.Host = "smtp.gmail.com";
client.Port = 587;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(stFromUserName, stFromPassword); 
client.EnableSsl = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mail);


You'll also need to go here and enable less secure apps.
Or if you have two step authentication on your account you'll need to set an app specific password, then use that password in your code instead of your main account password.
Thanks to equalsk
Reference : 

Senin, 26 Februari 2018

Using - End Using connection

using (SqlConnection sqlConn = new SqlConnection("Data Source=TANYA-PC;Initial Catalog=biore1;Integrated Security=True")) //here goes connStrng or the variable of it
   {
      sqlConn.Open();
      string sqlQuery = @"SELECT farmername,villagename,gender,farmsize FROM cottonpurchase WHERE farmercode = @code";

      using (SqlCommand cmd = new SqlCommand(sqlQuery, sqlConn))
      {
         cmd.Parameters.Add("@code", SqlDbType.Int).Value = intValue;
         using (SqlDataReader reader = cmd.ExecuteReader())
         {;
            if (reader.Read())
            {
               TxtFarmerName.Text = (string)reader[0];
               TxtVillageName.Text = (string)reader[1];
               TxtGender.Text = (string)reader[2];
            }
            else
               MessageBox.Show("For Farmer Code " + intValue.ToString() + " there is no farmer in the database.");
         }
      }
   }

How to pass data from 2nd activity to 1st activity when pressed back? - android

I've 2 activities, Activity1 and Activity2.
In Activity1 I've a Button and TextView. When the button is clicked Activity2 is started.
In Activity2 I've an EditText.
I want to display the data retrieved from EditText in Activity2 in the TextView in Activity1 when back is pressed from Activity2.
can someone help me with the code to make this work?
Answer :
Start Activity2 with startActivityForResult and use setResult method for sending data back from Activity2 to Activity1. In Activity1 you will need to override onActivityResult for updating TextView with EditText data from Activity2.
For example:
In Activity1, start Activity2 as:
Intent i = new Intent(this, Activity2.class);
startActivityForResult(i, 1);
In Activity2, use setResult for sending data back:
Intent intent = new Intent();
intent.putExtra("editTextValue", "value_here")
setResult(RESULT_OK, intent);        
finish();
And in Activity1, receive data with onActivityResult:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1) {
         if(resultCode == RESULT_OK) {
             String strEditText = data.getStringExtra("editTextValue");
         }     
    }
} 
If you can, also use SharedPreferences for sharing data between Activities.

Source : https://stackoverflow.com/questions/14292398/how-to-pass-data-from-2nd-activity-to-1st-activity-when-pressed-back-android