using System.IO;
using System.IO.Compression;
FileStream sourceFile;
GZipStream compStream;
FileStream destFile;
protected void btnCompress_Click1(object sender, EventArgs e)
{
if (File1.PostedFile != null)
{
txtSource.Text = File1.PostedFile.FileName.ToString();

}
sourceFile = File.OpenRead(txtSource.Text);
destFile = File.Create(txtDestination.Text);
compStream = new GZipStream(destFile, CompressionMode.Compress);
int theByte = sourceFile.ReadByte();
while (theByte != -1)
{
compStream.WriteByte((byte)theByte);
theByte = sourceFile.ReadByte();
}
sourceFile.Close();
destFile.Close();
}


protected void btnDecompress_Click(object sender, EventArgs e)
{

if (File1.PostedFile != null)
{
txtSource.Text = File1.PostedFile.FileName.ToString();

}

string srcFile = txtSource.Text;
string dstFile = txtDestination.Text;

FileStream fsIn = null; // will open and read the srcFile
FileStream fsOut = null; // will be used by the GZipStream for output to the dstFile
GZipStream gzip = null;
const int bufferSize = 4096;
byte[] buffer = new byte[bufferSize];
int count = 0;


{

fsIn = new FileStream(srcFile, FileMode.Open, FileAccess.Read, FileShare.Read);
fsOut = new FileStream(dstFile, FileMode.Create, FileAccess.Write, FileShare.None);
gzip = new GZipStream(fsIn, CompressionMode.Decompress, true);
while (true)
{
count = gzip.Read(buffer, 0, bufferSize);
if (count != 0)
{
fsOut.Write(buffer, 0, count);
}
if (count != bufferSize)
{
// have reached the end
break;
}
}
}

}
}
TextBox txt1 = new TextBox();
TextBox txt2 = new TextBox();
txt1.Text = "This is the textbox inside the placeholder";
txt2.Text = "This is the textbox inside the panel";
txt1.Style["width"] = "650px";
txt2.Style["width"] = "650px";
PlaceHolder1.Controls.Add(txt1);
Panel1.Controls.Add(txt2);


This article is about communicating through the PC's Serial COM RS-232 port using Microsoft .NET 2.0 or later by using the System.IO.Ports.SerialPort class.

using System.IO.Ports;
using System.Threading;
using System.Windows.Forms;

SerialPort port = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);


try
{
port.Open();
port.Write("x");


Thread.Sleep(500);


string x = port.ReadExisting().ToString();
port.Write("c");
Thread.Sleep(500);
string c = port.ReadExisting().ToString();
port.Write(" ");
Thread.Sleep(500);
string p = port.ReadExisting().ToString();
port.Write("s");
Thread.Sleep(500);
string s = port.ReadExisting().ToString();
port.Write("l" + "01" + "FF" + "\r\n");

Thread.Sleep(500);
string l = port.ReadExisting().ToString();
port.Write("r" + "04");

Thread.Sleep(500);
string r = port.ReadExisting().ToString();

port.Write("r" + "04");
Thread.Sleep(500);
string t = port.ReadExisting().ToString();
Thread.Sleep(500);
port.Write("rv" + "04");

Thread.Sleep(500);

string v = port.ReadExisting().ToString();

//string u = v.Substring(0, v.IndexOf("\r\n"));
//int k = Convert.ToInt32(u, 16);
//// k = Int32.Parse(u, NumberStyles.HexNumber);

//TextBox1.Text = k.ToString();


int num = Convert.ToInt32(txtamt.Text);

string st = num.ToString("X");
int bt = st.Length;
for (int i = 0; i < 8 - bt; i++)
{
st = "0" + st;
}
port.Write("+" + "04" + st);
Thread.Sleep(500);

string b = port.ReadExisting().ToString();
string u = b.Substring(0, b.IndexOf("\r\n"));

int d = Convert.ToInt32(u, 16);

string j = d.ToString();
MessageBox.Show("Your Balance Amount is " + j);
}
catch (Exception ex)
{
throw ex;
}
port.Close();
Firstly Add DataList Control in Design View.Then Change the html code of Datalist as follows:





Source Code:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class dynamic : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=ELWIN;Initial Catalog=sherin;Integrated Security=True");
public void display(string query)
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
da.Fill(dt);
DataView dv = new DataView(dt);
PagedDataSource objpag = new PagedDataSource();
objpag.DataSource = dv;
objpag.AllowPaging = true;
objpag.PageSize = 5;
DataList1.DataSource = objpag;
DataList1.DataBind();
con.Close();

}
public void check(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{

if (Session["programid"] != null)
{
Session["programid"] = Session["programid"] + " or programid=" + e.CommandName;

}
else
{
Session["programid"] = e.CommandName;
}

string fg = Session["programid"].ToString();
Response.Redirect("shoppingcart.aspx");
}

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

display("select * from addprogram2 ");
}

}
}


Output:



Workflow means performing any task in order. Today, each application is based on workflow approach
and involves some processes to be executed. While creating an application, developers are still following
the traditional approach that leads to create steps in the process implicit in the code. This traditional
approach works fine, but requires a deep programming logic making the process difficult to change and execute.

Workflow engine is not a new technology; it came into existence in early 2000. In the market, several
workflow engines are available for Windows and other platforms. Today, all applications are based on
workflow approach. So, defining different engines for different applications is a cumbersome task. To
avoid this, Microsoft has decided to define a single common workflow engine for all the windows-based
applications. This is what the Windows Workflow Foundation (WF) performs. WF provides a common
workflow technology for all the windows-based applications, such as Microsoft Office 2007 and
Windows Share Point Services.
Microsoft SQL Server is a relational database management system (RDBMS) produced by Microsoft. Its primary query language is Transact-SQL, an implementation of the ANSI/ISO standard Structured Query Language (SQL) used by both Microsoft and Sybase.


Add SQL Connection in asp.net with c#:






How to get Connection String for SQLConnection :










Source Code :


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class data : System.Web.UI.Page
{
SqlConnection scn = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=True");

protected void Page_Load(object sender, EventArgs e)
{

}
}
Add Reference for Serial Communication:



Add MSComm Control For Serial Communication:




Serial Communication Form Design:





Source Code For Serial Communication:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace mifaretest
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private static int num;
private static string st;

private void button1_Click(object sender, EventArgs e)
{
num = Convert.ToInt32(txtamt.Text);

st = num.ToString("X");
int bt = st.Length;
for (int i = 0; i < 8 - bt; i++)
{
st = "0" + st;
}
axMSComm1.Output = "+" + "04" + st;
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
string b = axMSComm1.Input.ToString();
string u = b.Substring(0, b.IndexOf("\r\n"));

int c = Convert.ToInt32(u, 16);

txtbal.Text = c.ToString();
}

}



private void Form2_Load(object sender, EventArgs e)
{
if (axMSComm1.PortOpen == false)
{
axMSComm1.PortOpen = true;
}


}

private void btnwithdrawal_Click(object sender, EventArgs e)
{
num = Convert.ToInt32(txtamt.Text);

st = num.ToString("X");
int bt = st.Length;
for ( int i = 0; i < 8 - bt; i++)
{
st = "0" + st;
}
axMSComm1.Output = "-" +"04" + st;
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
string b = axMSComm1.Input.ToString();
string u = b.Substring(0, b.IndexOf("\r\n"));

int c = Convert.ToInt32(u, 16);

txtbal.Text = c.ToString();
}

}


private static int i=0;
private static string x;
private static string c;
private static string p;
private static string s;
private static string l;
private static string r;
private static string t;
private static string v;
private static string u;
private static int k;
private void button2_Click(object sender, EventArgs e)
{
axMSComm1.Output = "x";
int o = axMSComm1.InBufferCount;

Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
x = axMSComm1.Input.ToString();
}

axMSComm1.Output = "c";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
c = axMSComm1.Input.ToString();
}
axMSComm1.Output = " ";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
p = axMSComm1.Input.ToString();
}
axMSComm1.Output = "s";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
s = axMSComm1.Input.ToString();
}
axMSComm1.Output = "l" + "01" + "FF" + "\r\n";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
l = axMSComm1.Input.ToString();
}
axMSComm1.Output = "r" + "04";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
r = axMSComm1.Input.ToString();
}
axMSComm1.Output = "r" + "04";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
t = axMSComm1.Input.ToString();
}
Thread.Sleep(500);

axMSComm1.Output = "rv" + "04";
Thread.Sleep(500);
// string m = x + c + p + s + l + r + t;
if (axMSComm1.InBufferCount > 0)
{
v = axMSComm1.Input.ToString();

u = v.Substring(0, v.IndexOf("\r\n"));
k = Convert.ToInt32(u, 16);
k = Int32.Parse(u, NumberStyles.HexNumber);

txtbal.Text = k.ToString();

}

}








}
}