Skip to main content

Posts

Create table runtime using c sharp code

Create table runtime using c sharp code try { if (RadioButton1.Checked == true) { string first = TextBox1.Text.ToString(); string last = TextBox3.Text.ToString(); string user = TextBox4.Text.ToString(); string ps = TextBox6.Text.ToString(); string quest = DropDownList1.Text.ToString(); string answ = TextBox7.Text.ToString(); string source = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\dfd.mdf;Integrated Security=True; User Instance=True"; SqlConnection conn = new SqlConnection(source); conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO users(fname, lname, uid, pswd, ques, ans) VALUES ('" + first + "', '" + last + "', '" + user + "', '" + ps + "', '" + quest + "', '" + answ + "')", conn); int i = cmd.ExecuteNonQuery(); String sql = "CREATE TABLE " + user + "" +"(Stu...

Example of abstract and interface class using c sharp

Example of abstract and interface class using c sharp namespace abstractClassDemo { class Program { static void Main(string[] args) { Car mycar = new Car("Skoda", "Fabia2CX"); mycar.ModelName(); mycar.BodyColor(); mycar.CubicCapacity(); mycar.Mileage(); Console.ReadKey(); } } abstract class Vehicle { string _model = ""; string _type = ""; public Vehicle(string company,string type) { _model = company; _type = type; } public abstract void CubicCapacity(); public abstract void BodyColor(); public abstract void Mileage(); public void ModelName() { Console.WriteLine("Vehicle is " + _type + " and Company is " + _model); } } class Car: Vehicle { public Car(string companyName, string modelName) : base(companyName, modelName) { } public override void BodyColor() { Console.Write("Color is Red."); } pub...

Data Decryption using C# Code

Data Decryption using C# Code public static byte[] Decryptor(string secrpcnm, string key) { byte[] b = Convert.FromBase64String(secrpcnm); TripleDES des = CreateDES(key); ICryptoTransform ct = des.CreateDecryptor(); byte[] output = ct.TransformFinalBlock(b, 0, b.Length); return Convert.FromBase64String(Encoding.Unicode.GetString(output)); } static TripleDES CreateDES(string key) { MD5 md5 = new MD5CryptoServiceProvider(); TripleDES des = new TripleDESCryptoServiceProvider(); des.Key=md5.ComputeHash(Encoding.Unicode.GetBytes(key)); des.IV = new byte[des.BlockSize / 8]; return des; } //And to call the functions on the click event of a button:: private void button4_Click(object sender, EventArgs e) { label6.Text = (EncrypCls.Decryptor(label5.Text, "sksdege")).ToString(); }

Re size image in ASP.NET while uploading an image

Re size image in ASP.NET while uploading an image public bool SaveThumbnailImage(System.Web.UI.WebControls.FileUpload fu, string FullSavePath, int HeightMax, int WidthMax) { try { if (fu.HasFile){string tmpSaveDir = pg.Server.MapPath("~/TempUploads/"); if (System.IO.Directory.Exists(tmpSaveDir) == false) { System.IO.Directory.CreateDirectory(tmpSaveDir); } string tmpSavePath = pg.Server.MapPath("~/TempUploads/" + fu.FileName); if (System.IO.File.Exists(tmpSavePath)) { try { System.IO.File.Delete(tmpSavePath); } catch { } } fu.SaveAs(tmpSavePath); System.Drawing.Image img = System.Drawing.Image.FromFile(tmpSavePath); double ratioWidth = (double)img.Width / (double)WidthMax; double ratioHeight = (double)img.Height / (double)HeightMax; double ratio = Math.Max(ratioHeight, ratioWidth); int newWidth = (int)(img.Width / ratio); int newHeight = (int)(img.Height / ratio); System.Drawing.Ima...

Encapsulate some code module in the code behind file of c#

Add a new project to you solution as class library. You can find class library under C# windows section. Name it as per your convenience. after adding, you will get a class file, with the name of you supplied. make this class public. Now you can write you logic in this class file, build it. it will create a dll file. add reference by right clicking on you main application project file select "Add reference", path of dll file. in your application, add the namespace of your class file and then call class and its methods. below is a sample class file using System; using System.Data; namespace myEncapsulatedNameSpace { public class myEncapsulatedClass { //property declaration //properties are used for passing values between application layers private string _myName = string.empty; public string myName { get { return _myName; } set { _myName = value; } public string myMethod() { return myName = "sk";...

How Tsunami occurs?

How Tsunami occurs? As one plate subducts below another, pressure builds after many years, resulting in a section of the megathrust giving away. As this section gives way. 1 ruptures the ocean floor, resulting in a massive displacement of water, causing a Tsunami. Tsunamis are barely fell as a ripple on the ocean surface, but as the wave reaches land, they increases in size as the water becomes shallower.    World’s worst Tsunamis In Chile, Japan and Russia on February27, 2011, thousands died after an 8.8-magnitude earthquake. Many who survived the quake were killed hours later by a massive tsunami. Waves of up to 1.5 meters [5feet] went on to hit far – flung Pacific regions from the Russian far east and Japan to New Zealand’s Chatham islands. The biggest Tsunami  occurred on July 9, 1958 in Lituya bay, Alaska by a magnitude of 8 earthquake causing massive landslides. Waves reached an unbelievable heights of 1,720 feet, killing more than 36,000 people. We shall pr...

Micro organisms

Micro-organisms There are some organisms around us which we cannot see through naked eyes. These organisms are called Micro-organisms.  There are five types of Micro-organisms bacteria, fungi, protozoa, algae and virus. Where do micro-organisms live? Micro-organisms can survive under all types of environment, ranging from ice cold climate to hot springs and deserts to marshy lands. They are also found inside the bodies of animals including humans. fungi   Fungi is a type of micro-organism. There are three types of fungi Bread mould, penicillium, aspergillus. Protozoa There are two types of protozoa Amoeba and paramecium. Diseases like dysentery and malaria are caused by protozoa.  Algae There are two types of algae chlamydomonas and spirogyra. Viruses Virus are microscopic. Diseases caused by viruses are cold, influenza, coughs, polio and chicken pox.