google

Newest Post

Select Date in SQL in Desired Formats like AM, PM

| Friday, May 6, 2016
Read more »
Use following in-built function to select the dates in desired formats. Following format returns date in AM, PM format

Query - SELECT FORMAT(GetDate(),'MM/dd/yyyy hh:mm:ss tt')
Result - 05/06/2016 03:06:02 PM

Select Date in SQL in Desired Formats like AM, PM

Posted by : Stranger
Date :Friday, May 6, 2016
With 0comments

Microsoft Excel - Unmerge cells and fill down the values in all rows

| Tuesday, March 22, 2016
Read more »
This can be done using Go to Special command in Find and Select option. Following are the steps to achieve this.
1. Select the columns that have merged cells.
2. Click Home > Merge & Center > Unmerge Cells
3. The merged cells have been unmerged and only the first cell will be filled with the original values. Keep the range selected or select the range again.
4. Click Home > Find & Select > Go To Special. In the Go To Special dialog box, select Blanks option

5. Click OK, all of the blank cells in the range have been selected. Then input = and press Up arrow key on the keyboard.
6. Press Ctrl + Enter keys, all of the blank cells have been filled with the original merged data.

And

TaDa!!!! DONE

Convert base64 into Image, Resize the image and again convert it into base64

| Saturday, March 5, 2016
Read more »
Convert base64 into Image, Resize the image and again convert it into base64

Use Following Code:

                       byte[] bytes = (byte[])row["Picture"];

                        Image image;

                       //Convert byte[] into image
                        using (MemoryStream ms = new MemoryStream(bytes))
                        {
                            image = Image.FromStream(ms);
                        }

                        // Resize the image
                        Bitmap b = new Bitmap(200, 200);
                        Graphics g = Graphics.FromImage((Image)b);
                        g.InterpolationMode = InterpolationMode.HighQualityBicubic;

                        g.DrawImage(image, 0, 0, 200, 200);
                        g.Dispose();
                        image = (Image)b;

                        using (MemoryStream ms = new MemoryStream())
                        {
                            // Convert Image to byte[]
                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                            byte[] imageBytes = ms.ToArray();

                            // Convert byte[] to Base64 String
                            string base64String = Convert.ToBase64String(imageBytes);
                            obj.StudentPicture = base64String;
                        }

Convert base64 into Image, Resize the image and again convert it into base64

Posted by : Stranger
Date :Saturday, March 5, 2016
With 0comments

Custom Date Time Picker for Android

| Friday, November 6, 2015
Read more »
Android itself does not provide any date or time picker which can let user choose date and time together.

We can choose dates using DatePickerDialog and times using TimePickerDialog, which requires 2 different dialogs and 2 different actions. Instead of that we can use following code to provide selection of Date and Time in one dialog.

Following is the code of the layout file "date_time_picker.xml" which will be inflated to be displayed in the Date Time Picker Dialog.


 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout  
   xmlns:android="http://schemas.android.com/apk/res/android"  
   android:orientation="vertical"  
   android:layout_width="match_parent"  
   android:padding="10dp"  
   android:layout_height="match_parent">  
   <DatePicker  
     android:id="@+id/datepicker"  
     android:layout_width="match_parent"  
     android:calendarViewShown="true"  
     android:spinnersShown="false"  
     android:layout_weight="4"  
     android:layout_height="0dp" />  
   <TimePicker  
     android:id="@+id/timepicker"  
     android:layout_weight="4"  
     android:layout_width="match_parent"  
     android:layout_height="0dp" />  
   <Button  
     android:id="@+id/datetimeset"  
     android:layout_weight="1"  
     android:layout_width="match_parent"  
     android:text="Set"  
     android:layout_height="0dp" />  
 </LinearLayout>  

Following is the code of Button click in Java file which will open the dialog.


  public void SelectDateTime(View v) {  
     final View dialogView = View.inflate(this, R.layout.date_time_picker, null);  
     final AlertDialog alertDialog = new AlertDialog.Builder(this).create();  
     dialogView.findViewById(R.id.datetimeset).setOnClickListener(new View.OnClickListener() {  
       @Override  
       public void onClick(View view) {  
         DatePicker datePicker = (DatePicker) dialogView.findViewById(R.id.datepicker);  
         TimePicker timePicker = (TimePicker) dialogView.findViewById(R.id.timepicker);  
         Calendar calendar = new GregorianCalendar(datePicker.getYear(),  
             datePicker.getMonth(),  
             datePicker.getDayOfMonth(),  
             timePicker.getCurrentHour(),  
             timePicker.getCurrentMinute());  
         SimpleDateFormat mSDF = new SimpleDateFormat("HH:mm:ss");  
         String time = mSDF.format(calendar.getTime());  
         int day = datePicker.getDayOfMonth();  
         int month = datePicker.getMonth();  
         int year = datePicker.getYear();  
         SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");  
         String formatedDate = sdf.format(new Date(year-1900, month, day));  
         editText_datetime.setText(formatedDate + ' ' + time);  
         alertDialog.dismiss();  
       }  
     });  
     alertDialog.setView(dialogView);  
     alertDialog.show();  
   }  


"SelectDateTime" method is called on button click which will fetch the values from Date Time picker into the EditText.

"SimpleDateFormat" class has been used to set the values in desired date and time formats.

Important

String formatedDate = sdf.format(new Date(year-1900, month, day));  

Always +/- 1900 with year formatted using SimpleDateFormat. 

Custom Date Time Picker

Video - Converting a base64 string into the jpg or png Image and save in a folder in website

| Friday, August 28, 2015
Read more »

Video - Converting a base64 string into the jpg or png Image and save in a folder in website

Posted by : Stranger
Date :Friday, August 28, 2015
With 0comments

Converting a base64 string into the jpg or png Image and save in a folder in website

| Wednesday, March 4, 2015
Read more »
Converting a base64 string into the jpg or png Image and save in a folder in website.

This feature can be used for saving the images from the Mobile apps.



  if (!string.IsNullOrEmpty(base64Image))  
     {  
       using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(base64Image)))  
       {  
         using (Bitmap bm2 = new Bitmap(ms))  
         {  
           bm2.Save(HostingEnvironment.MapPath("~/upload/" + "Pic" + ".jpg"));  
         }  
       }  
     }  


The above code has been implemented in a .Net based WCF web service method for saving the image from the mobile app which is returning image as base64 string when uploaded from the mobile.

Converting a base64 string into the jpg or png Image and save in a folder in website

Posted by : Stranger
Date :Wednesday, March 4, 2015
With 0comments

Code to export the Grid View/Data Grid data into Excel File.

| Friday, February 13, 2015
Read more »
 protected void btnExportToExcel_Click(object sender, EventArgs e)  
   {  
     try  
     {  
       DataTable dt = student.GetDetails("B.Tech").Tables[0];  
       DataGrid GridView1 = new DataGrid();  
       GridView1.DataSource = dt;  
       GridView1.DataBind();  
       Response.Clear();  
       Response.Buffer = true;  
       Response.AddHeader("content-disposition", string.Format("attachment; filename=StudentsBTech.xls"));  
       Response.Charset = "";  
       Response.ContentType = "application/vnd.ms-excel";  
       StringWriter sw = new StringWriter();  
       HtmlTextWriter htw = new HtmlTextWriter(sw);  
       GridView1.GridLines = GridLines.Both;  
       GridView1.AllowPaging = false;  
       GridView1.RenderControl(htw);  
       Response.Output.Write(sw.ToString());  
       GridView1.DataBind();  
       Response.Flush();  
     }  
     catch (Exception ex)  
     {  
     }  
     finally { Response.End(); }  
   }  
   public override void VerifyRenderingInServerForm(Control control)  
   { }  

Code to export the Grid View/Data Grid data into Excel File.

Posted by : Stranger
Date :Friday, February 13, 2015
With 0comments

$5 eBook Bonanza – Every title, every topic - On PacktPub

| Friday, December 19, 2014
Read more »
$5 EBOOK BONANZA – EVERY TITLE, EVERY TOPIC


The $5 eBook Bonanza is here!
Treat yourself to the eBook or Video of your choice for just $5 and get as many as you like until January 6th 2015. To get you started, we've put together the Top 20 Titles of 2014 for you to pick up here. But don’t forget, you can get ANY eBook or Video for $5 in this offer.
For specific tech, you can browse all the categories this page - http://bit.ly/1w1Vkps



$5 eBook Bonanza – Every title, every topic - On PacktPub

Posted by : Stranger
Date :Friday, December 19, 2014
With 1 comments:
Prev
▲Top▲