Asides

Angular JS

Good Morning!!!

I think we are good in transforming our  data while displaying in browser web pages , sometimes it becomes complex but can be easily done by using angular js filters.

  1. String
  2. Number.
  3. Date
  4. Object

u can access complete doc here

Converting Data Base table to .CSV file

Most of the time we used to download the data onto .csv file from website we can also code the same thing by writing this code

protected void Download_Click(object sender, EventArgs e)
{

SqlConnection conn = new SqlConnection(“Server=.;uid=sa;pwd=****;database=practice”);
string query = “select * from rnemp;
SqlCommand cmd = new SqlCommand(query, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
string csv = string.Empty;
foreach (DataColumn column in ds.Columns)
{
csv += column.ColumnName + ‘,’;
}
csv += “\r\n”;
foreach (DataRow row in ds.Rows)
{
foreach (DataColumn column in ds.Columns)
{
csv += row[column.ColumnName].ToString().Replace(“,”, “;”) + ‘,’;
}
csv += “\r\n”;
}
Response.Clear();
Response.Buffer = true;
Response.AddHeader(“content-disposition”, “attachment;filename=SqlExport.csv”);
Response.Charset = “”;
Response.ContentType = “application/text”;
Response.Output.Write(csv);
Response.Flush();
Response.End();
}
}

Binary Serialization

Serialization is the process of  converting a object into binary format and store data in a  text file

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace SerializeExample
{
public partial class Form1 : Form
{
Employee E1 = new Employee();
FileStream fs ;
BinaryFormatter b = new BinaryFormatter();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
E1.Eno = int.Parse(textBox1.Text);
E1.Ename = textBox2.Text;
fs = new FileStream(“E:\\Employee.txt”, FileMode.Create, FileAccess.Write);
b.Serialize(fs, E1);
fs.Flush();
fs.Close();
MessageBox.Show(“Serialized”);
textBox1.Text = “”;
textBox2.Text = “”;
}

private void button2_Click(object sender, EventArgs e)
{
fs = new FileStream(“E:\\Employee.txt”, FileMode.Open, FileAccess.Read);
E1 = (Employee)b.Deserialize(fs);
fs.Flush();
fs.Close();
textBox4.Text = E1.Eno.ToString();
textBox3.Text = E1.Ename;
MessageBox.Show(“Deserialized”);
}
}
}

HTML Table

Good Evening Decoders!!!!. As u are aware that nearly 600k websites are being launching everyday. Jobs for techies were growing in proportionally to them. Somehow company were testing the fresher fellows with codebytes. Here is the task to create a HTML table using rowspan and colspan elements .Like Below

img_20181114_1718363736497441369057345.jpg

Code will be like below :

img_20181114_1718152525200007668668061.jpg

You can get code by clicking Here .