..................................Calculator coding...................................................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Ranjeet_calculator
{
public partial class Form1 : Form
{
#1#
bool plus = false;
bool minus = false;
bool multiply = false;
bool divide = false;
bool equal = false;
public Form1()
{
InitializeComponent();
}
private void ( * coding)button15_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
textBox1.Text = "";
equal = false;
return;
}
else
{
multiply = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void ChekifEqual()
{
if (equal)
{
textBox1.Text = "";
equal = false;
}
}
private void ( = coding) button18_Click(object sender, EventArgs e)
{
equal = true;
if (plus)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (minus)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (multiply)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (divide)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
}
private void ( 1 coding)button1_Click(object sender, EventArgs e)
{
CeckifEqual();
if (equal)
{
textBox1.Text = "";
equal = false;
}
textBox1.Text = textBox1.Text + "1";
}
private void CeckifEqual()
{
if (equal)
{
textBox1.Text = "";
equal = false;
}
}
private void ( 2 coding)button2_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "2";
}
private void ( 3 coding)button3_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "3";
}
private void ( 4 coding)button4_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "4";
}
private void ( 5 coding)button5_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "5";
}
private void ( 6 coding)button6_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "6";
}
private void ( 7 coding)button7_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "7";
}
private void ( 8 coding)button8_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "8";
}
private void ( 9 coding)button9_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "9";
}
private void ( . coding)button11_Click(object sender, EventArgs e)
{
if (textBox1.Text.Contains("."))
{
return;
}
else
{
textBox1.Text = textBox1.Text + ".";
}
}
private void ( +/- coding)button12_Click(object sender, EventArgs e)
{
if (textBox1.Text.Contains("-"))
{
textBox1.Text = textBox1.Text.Remove(0, 1);
}
else
{
textBox1.Text = "-" + textBox1.Text;
}
}
private void ( + coding)button13_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
plus = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void ( - coding) button14_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
minus = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void ( / divide coding)button16_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
divide = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void (c,clear coding) button17_Click(object sender, EventArgs e)
{
plus = minus = multiply = divide = equal = true;
textBox1.Text = "";
textBox1.Tag = "";
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void developerPhotoToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 r = new Form2();
r.Show();
this.Hide();
}
private void ( 0 coding)button10_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "0";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text != "")
try
{
textBox1.Text = Convert.ToDecimal(textBox1.Text.Replace("$", "").Replace(",", "")).ToString("");
}
catch
{
MessageBox.Show("Please enter Numeric value input");
textBox1.Clear();
}
}
}
}
.......................................Notepad Coding.............................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Ranjeet_NotePad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void (new coding)newToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void (open coding)openToolStripMenuItem_Click(object sender, EventArgs e)
{
{
OpenFileDialog ranjeet = new OpenFileDialog();
ranjeet.Title = "open";
ranjeet.Filter = "All Files|*.*";
try
{
if (ranjeet.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.LoadFile(ranjeet.FileName);
}
}
catch (Exception ex)
{
MessageBox.Show("invilid File format");
}
}
}
private void (save coding)saveToolStripMenuItem_Click(object sender, EventArgs e)
{
{
SaveFileDialog s = new SaveFileDialog();
s.Title = "Save";
s.Filter = "Rich Text Files |*.rtf";
try
{
if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SaveFile(s.FileName);
}
}
catch (Exception ex)
{
}
}
}
private void (exit coding)exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void (undo coding)undoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
}
private void (redo coding)redoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Redo();
}
private void (cut coding)cutToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void (copy coding)copyToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void (past coding)pastToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void (clear coding)clearToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void (select all coding)sellectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll();
}
private void (font coding)fontToolStripMenuItem_Click(object sender, EventArgs e)
{
{
FontDialog Font = new FontDialog();
try
{
Font.Font = richTextBox1.SelectionFont;
if (Font.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionFont = (Font)Font.Font.Clone();
}
}
catch (Exception ex)
{
}
}
}
private void (colour coding)colourToolStripMenuItem_Click(object sender, EventArgs e)
{
{
ColorDialog Colour = new ColorDialog();
try
{
Colour.Color = richTextBox1.SelectionColor;
if (Colour.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionColor = Colour.Color;
}
}
catch (Exception ex)
{
}
}
}
private void developerPhotoToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 r = new Form2();
r.Show();
this.Hide();
}
private void (exit coding)exitToolStripMenuItem1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void (clear coding)clearToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void fileToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void (save coding)saveToolStripMenuItem1_Click(object sender, EventArgs e)
{
{
SaveFileDialog s = new SaveFileDialog();
s.Title = "Save";
s.Filter = "Rich Text Files |*.rtf";
try
{
if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SaveFile(s.FileName);
}
}
catch (Exception ex)
{
}
}
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll();
}
private void cutToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void copyToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void formatToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void cToolStripMenuItem_Click(object sender, EventArgs e)
{
{
FontDialog Font = new FontDialog();
try
{
Font.Font = richTextBox1.SelectionFont;
if (Font.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionFont = (Font)Font.Font.Clone();
}
}
catch (Exception ex)
{
}
}
}
private void colourToolStripMenuItem1_Click(object sender, EventArgs e)
{
{
ColorDialog Colour = new ColorDialog();
try
{
Colour.Color = richTextBox1.SelectionColor;
if (Colour.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionColor = Colour.Color;
}
}
catch (Exception ex)
{
}
}
}
private void undoToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
}
private void redoToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Redo();
}
}
}
................................Check Database Connection Coding............................
check connec tion Open yes or not
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;##1##
namespace Image_Save
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
##2## SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=gun; User Id=sa; Password=sapna");
private void Form1_Load(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
### 3 ## con.Open();
if(con.State.ToString() == "Open")
{
MessageBox.Show("hi");
}
}
private void button3_Click(object sender, EventArgs e)
{
}
}
}
.....................................Demo2_project_double_photo_stor_coding..........................
............DATABASE..............
create database check1
CREATE TABLE [dbo].[check]
(
[Id] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [varchar] (50) NOT NULL,
[Address] [varchar] (150) NOT NULL,
[Phone] [varchar] (15) NOT NULL,
[OriginalPath] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[gPath] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Photo] [image] NOT NULL,
[gunPhoto] [image] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
select * from [check]
............................Coding.........................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace Demo_Project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=check1; User Id=sa; Password=sapna");
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void label6_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
show_detail();
}
public void clear()
{
textId.Text = "";
textName.Text = "";
textAddress.Text = "";
textPhone.Text = "";
textPhoto_Path.Text = "";
textgpath.Text = "";
}
public void show_detail()
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from [check]", con);
DataSet ds = new DataSet();
da.Fill(ds, "[check]");
dataGridView1.DataSource = ds.Tables["[check]"];
con.Close();
}
private void (save coding)button2_Click(object sender, EventArgs e)
{
byte[] Photo = ReadFile(textPhoto_Path.Text);
byte[] gunPhoto = ReadFile(textgpath.Text);
try
{
string str = "insert into [check] (Name,Address,Phone,OriginalPath,gPath,Photo,gunPhoto) values(@Name,@Address,@Phone,@OriginalPath,@gPath,@Photo,@gunPhoto)";
SqlCommand cmd = new SqlCommand(str, con);
cmd.Parameters.Add(new SqlParameter("@Name", (object)textName.Text));
cmd.Parameters.Add(new SqlParameter("@Address", (object)textAddress.Text));
cmd.Parameters.Add(new SqlParameter("@Phone", (object)textPhone.Text));
cmd.Parameters.Add(new SqlParameter("@OriginalPath", (object)textPhoto_Path.Text));
cmd.Parameters.Add(new SqlParameter("@gPath", (object)textgpath.Text));
cmd.Parameters.Add(new SqlParameter("@Photo", (object)Photo));
cmd.Parameters.Add(new SqlParameter("@gunPhoto", (object)gunPhoto));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Saved Successfully");
show_detail();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void (add coding)button1_Click(object sender, EventArgs e)
{
// con.Open();
// if (con.State.ToString() == "Open")
// {
// MessageBox.Show("hi");
// }
textName.Enabled = true;
textAddress.Enabled = true;
textPhone.Enabled = true;
textPhoto_Path.Enabled = true;
textgpath.Enabled = true;
clear();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void#(first photo(your_photo) browser coding)# button4_Click(object sender, EventArgs e)
{
OpenFileDialog fl = new OpenFileDialog();
DialogResult dl = fl.ShowDialog();
if (dl != DialogResult.Cancel)
{
pictureBox1.ImageLocation = fl.FileName;
textPhoto_Path.Text = fl.FileName;
}
}
byte[] ReadFile(String spath)
{
byte[] data = null;
FileInfo finfo = new FileInfo(spath);
long numbyts = finfo.Length;
FileStream fs = new FileStream(spath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
data = br.ReadBytes((int)numbyts);
return data;
}
private void (writre click datagredeview and write click and go to even cell enter double click and write)dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
string row;
string row1;
string row2;
string row3;
string row4;
string row5;
row = dataGridView1.CurrentRow.Cells["Name"].Value.ToString();
textName.Text = row;
row1 = dataGridView1.CurrentRow.Cells["Id"].Value.ToString();
textId.Text = row1;
row2 = dataGridView1.CurrentRow.Cells["Address"].Value.ToString();
textAddress.Text = row2;
row3 = dataGridView1.CurrentRow.Cells["Phone"].Value.ToString();
textPhone.Text = row3;
row4 = dataGridView1.CurrentRow.Cells["OriginalPath"].Value.ToString();
textPhoto_Path.Text = row4;
row5 = dataGridView1.CurrentRow.Cells["OriginalPath"].Value.ToString();
textgpath.Text = row5;
try
{
byte[] Photo = (byte[])dataGridView1.Rows[e.RowIndex].Cells["Photo"].Value;
Image newImage;
using (MemoryStream ms = new MemoryStream(Photo, 0, Photo.Length))
{
ms.Write(Photo, 0, Photo.Length);
newImage = Image.FromStream(ms, true);
}
pictureBox1.Image = newImage;
byte[] gunPhoto = (byte[])dataGridView1.Rows[e.RowIndex].Cells["gunPhoto"].Value;
Image newImage1;
using (MemoryStream ms = new MemoryStream(gunPhoto, 0, gunPhoto.Length))
{
ms.Write(gunPhoto, 0, gunPhoto.Length);
newImage1 = Image.FromStream(ms, true);
}
pictureBox2.Image = newImage1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void (3 update coding)button3_Click(object sender, EventArgs e)
{
byte[] Photo = ReadFile(textPhoto_Path.Text);
byte[] gPhoto = ReadFile(textgpath.Text);
try
{
string str = "update [check] set Name=@Name,Address=@Address,Phone=@Phone,OriginalPath=@OriginalPath,gPath=@gPath,Photo=@Photo,gunPhoto=@gunPhoto where Id='" + textId.Text + "'";
SqlCommand cmd = new SqlCommand(str, con);
cmd.Parameters.Add(new SqlParameter("@Name", (object)textName.Text));
cmd.Parameters.Add(new SqlParameter("@Address", (object)textAddress.Text));
cmd.Parameters.Add(new SqlParameter("@Phone", (object)textPhone.Text));
cmd.Parameters.Add(new SqlParameter("@OriginalPath", (object)textPhoto_Path.Text));
cmd.Parameters.Add(new SqlParameter("@gPath", (object)textgpath.Text));
cmd.Parameters.Add(new SqlParameter("@Photo", (object)Photo));
cmd.Parameters.Add(new SqlParameter("@gunPhoto", (object)gPhoto));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Updated Successfully");
show_detail();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void (delete coding)button5_Click(object sender, EventArgs e)
{
try
{
if (textDelete.Text == "")
{
MessageBox.Show("Please enter a valid ID.");
}
else
{
con.Open();
SqlCommand cmd = new SqlCommand("delete from [check] where Id='" + textDelete.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Deleted successfully");
show_detail();
textDelete.Text = "";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void (search coding)textSearch_TextChanged(object sender, EventArgs e)
{
if (textSearch.Text == "")
{
show_detail();
}
else
{
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from [check] where Id LIKE '" + textSearch.Text + "%'", con);
DataSet ds = new DataSet();
da.Fill(ds, "[check]");
dataGridView1.DataSource = ds.Tables["[check]"];
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
private void #(second photo(your_gf_photo) browser coding)#button6_Click(object sender, EventArgs e)
{
OpenFileDialog fl1 = new OpenFileDialog();# object should be change#
DialogResult dll = fl1.ShowDialog();
if (dll != DialogResult.Cancel)
{
pictureBox2.ImageLocation = fl1.FileName;
textgpath.Text = fl1.FileName;
}
}
byte[] ReadFile1(String spath)
{
byte[] data = null;
FileInfo finfo = new FileInfo(spath);
long numbyts = finfo.Length;
FileStream fss = new FileStream(spath, FileMode.Open, FileAccess.Read);
BinaryReader brr = new BinaryReader(fss);
data = brr.ReadBytes((int)numbyts);
return data;
}
}
}
.............................Delete by Id Coding................
try
{
if (txtsearch.Text == "")
{
MessageBox.Show("Please enter a valid ID.");
}
else if (txtid.Text == txtsearch.Text)
{
con.Open();
SqlCommand cmd = new SqlCommand("delete from ImagesStore where Employee_Id='" + txtsearch.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Deleted successfully");
detail();
txtdelete.Text = "";
con.Close();
}
else
{
MessageBox.Show("Id not matched");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
..............................Search by Name Coding....................
try
{
if (comboBox1.Text == "Name")
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from ImagesStore where Employee_Name LIKE '" + txtsearch.Text + "%'", con);
DataSet ds = new DataSet();
da.Fill(ds, "ImagesStore");
dataGridView1.DataSource = ds.Tables["ImagesStore"];
con.Close();
}
else if (comboBox1.Text == "Id")
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from ImagesStore where Employee_Id LIKE '" + txtsearch.Text + "%'", con);
DataSet ds = new DataSet();
da.Fill(ds, "ImagesStore");
dataGridView1.DataSource = ds.Tables["ImagesStore"];
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
..........................................Login Coding.................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Threading;
namespace Login_demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=LOGININFO;Integrated Security = true");
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlCommand cmd = new SqlCommand("Select * from GETGO where USERID ='" + textBox1.Text + "' AND PASSWORD ='" + textBox2.Text + "'", cn);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if ((dr.Read()))
{
hii h1 = new hii();
h1.Show();
this.Hide();
cn.Close();
}
else
{
MessageBox.Show("PLEASE ENTER THE VALID USERID & PASWWORD");
textBox1.Clear();
textBox2.Clear();
}
}
catch(Exception exc)
{
MessageBox.Show(exc.Message);
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Ranjeet_calculator
{
public partial class Form1 : Form
{
#1#
bool plus = false;
bool minus = false;
bool multiply = false;
bool divide = false;
bool equal = false;
public Form1()
{
InitializeComponent();
}
private void ( * coding)button15_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
textBox1.Text = "";
equal = false;
return;
}
else
{
multiply = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void ChekifEqual()
{
if (equal)
{
textBox1.Text = "";
equal = false;
}
}
private void ( = coding) button18_Click(object sender, EventArgs e)
{
equal = true;
if (plus)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (minus)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (multiply)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (divide)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
}
private void ( 1 coding)button1_Click(object sender, EventArgs e)
{
CeckifEqual();
if (equal)
{
textBox1.Text = "";
equal = false;
}
textBox1.Text = textBox1.Text + "1";
}
private void CeckifEqual()
{
if (equal)
{
textBox1.Text = "";
equal = false;
}
}
private void ( 2 coding)button2_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "2";
}
private void ( 3 coding)button3_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "3";
}
private void ( 4 coding)button4_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "4";
}
private void ( 5 coding)button5_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "5";
}
private void ( 6 coding)button6_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "6";
}
private void ( 7 coding)button7_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "7";
}
private void ( 8 coding)button8_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "8";
}
private void ( 9 coding)button9_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "9";
}
private void ( . coding)button11_Click(object sender, EventArgs e)
{
if (textBox1.Text.Contains("."))
{
return;
}
else
{
textBox1.Text = textBox1.Text + ".";
}
}
private void ( +/- coding)button12_Click(object sender, EventArgs e)
{
if (textBox1.Text.Contains("-"))
{
textBox1.Text = textBox1.Text.Remove(0, 1);
}
else
{
textBox1.Text = "-" + textBox1.Text;
}
}
private void ( + coding)button13_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
plus = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void ( - coding) button14_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
minus = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void ( / divide coding)button16_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
divide = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void (c,clear coding) button17_Click(object sender, EventArgs e)
{
plus = minus = multiply = divide = equal = true;
textBox1.Text = "";
textBox1.Tag = "";
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void developerPhotoToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 r = new Form2();
r.Show();
this.Hide();
}
private void ( 0 coding)button10_Click(object sender, EventArgs e)
{
CeckifEqual();
textBox1.Text = textBox1.Text + "0";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text != "")
try
{
textBox1.Text = Convert.ToDecimal(textBox1.Text.Replace("$", "").Replace(",", "")).ToString("");
}
catch
{
MessageBox.Show("Please enter Numeric value input");
textBox1.Clear();
}
}
}
}
.......................................Notepad Coding.............................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Ranjeet_NotePad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void (new coding)newToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void (open coding)openToolStripMenuItem_Click(object sender, EventArgs e)
{
{
OpenFileDialog ranjeet = new OpenFileDialog();
ranjeet.Title = "open";
ranjeet.Filter = "All Files|*.*";
try
{
if (ranjeet.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.LoadFile(ranjeet.FileName);
}
}
catch (Exception ex)
{
MessageBox.Show("invilid File format");
}
}
}
private void (save coding)saveToolStripMenuItem_Click(object sender, EventArgs e)
{
{
SaveFileDialog s = new SaveFileDialog();
s.Title = "Save";
s.Filter = "Rich Text Files |*.rtf";
try
{
if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SaveFile(s.FileName);
}
}
catch (Exception ex)
{
}
}
}
private void (exit coding)exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void (undo coding)undoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
}
private void (redo coding)redoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Redo();
}
private void (cut coding)cutToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void (copy coding)copyToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void (past coding)pastToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void (clear coding)clearToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void (select all coding)sellectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll();
}
private void (font coding)fontToolStripMenuItem_Click(object sender, EventArgs e)
{
{
FontDialog Font = new FontDialog();
try
{
Font.Font = richTextBox1.SelectionFont;
if (Font.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionFont = (Font)Font.Font.Clone();
}
}
catch (Exception ex)
{
}
}
}
private void (colour coding)colourToolStripMenuItem_Click(object sender, EventArgs e)
{
{
ColorDialog Colour = new ColorDialog();
try
{
Colour.Color = richTextBox1.SelectionColor;
if (Colour.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionColor = Colour.Color;
}
}
catch (Exception ex)
{
}
}
}
private void developerPhotoToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 r = new Form2();
r.Show();
this.Hide();
}
private void (exit coding)exitToolStripMenuItem1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void (clear coding)clearToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void fileToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void (save coding)saveToolStripMenuItem1_Click(object sender, EventArgs e)
{
{
SaveFileDialog s = new SaveFileDialog();
s.Title = "Save";
s.Filter = "Rich Text Files |*.rtf";
try
{
if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SaveFile(s.FileName);
}
}
catch (Exception ex)
{
}
}
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll();
}
private void cutToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void copyToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void formatToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void cToolStripMenuItem_Click(object sender, EventArgs e)
{
{
FontDialog Font = new FontDialog();
try
{
Font.Font = richTextBox1.SelectionFont;
if (Font.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionFont = (Font)Font.Font.Clone();
}
}
catch (Exception ex)
{
}
}
}
private void colourToolStripMenuItem1_Click(object sender, EventArgs e)
{
{
ColorDialog Colour = new ColorDialog();
try
{
Colour.Color = richTextBox1.SelectionColor;
if (Colour.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox1.SelectionColor = Colour.Color;
}
}
catch (Exception ex)
{
}
}
}
private void undoToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
}
private void redoToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Redo();
}
}
}
................................Check Database Connection Coding............................
check connec tion Open yes or not
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;##1##
namespace Image_Save
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
##2## SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=gun; User Id=sa; Password=sapna");
private void Form1_Load(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
### 3 ## con.Open();
if(con.State.ToString() == "Open")
{
MessageBox.Show("hi");
}
}
private void button3_Click(object sender, EventArgs e)
{
}
}
}
.....................................Demo2_project_double_photo_stor_coding..........................
............DATABASE..............
create database check1
CREATE TABLE [dbo].[check]
(
[Id] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [varchar] (50) NOT NULL,
[Address] [varchar] (150) NOT NULL,
[Phone] [varchar] (15) NOT NULL,
[OriginalPath] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[gPath] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Photo] [image] NOT NULL,
[gunPhoto] [image] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
select * from [check]
............................Coding.........................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace Demo_Project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=check1; User Id=sa; Password=sapna");
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void label6_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
show_detail();
}
public void clear()
{
textId.Text = "";
textName.Text = "";
textAddress.Text = "";
textPhone.Text = "";
textPhoto_Path.Text = "";
textgpath.Text = "";
}
public void show_detail()
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from [check]", con);
DataSet ds = new DataSet();
da.Fill(ds, "[check]");
dataGridView1.DataSource = ds.Tables["[check]"];
con.Close();
}
private void (save coding)button2_Click(object sender, EventArgs e)
{
byte[] Photo = ReadFile(textPhoto_Path.Text);
byte[] gunPhoto = ReadFile(textgpath.Text);
try
{
string str = "insert into [check] (Name,Address,Phone,OriginalPath,gPath,Photo,gunPhoto) values(@Name,@Address,@Phone,@OriginalPath,@gPath,@Photo,@gunPhoto)";
SqlCommand cmd = new SqlCommand(str, con);
cmd.Parameters.Add(new SqlParameter("@Name", (object)textName.Text));
cmd.Parameters.Add(new SqlParameter("@Address", (object)textAddress.Text));
cmd.Parameters.Add(new SqlParameter("@Phone", (object)textPhone.Text));
cmd.Parameters.Add(new SqlParameter("@OriginalPath", (object)textPhoto_Path.Text));
cmd.Parameters.Add(new SqlParameter("@gPath", (object)textgpath.Text));
cmd.Parameters.Add(new SqlParameter("@Photo", (object)Photo));
cmd.Parameters.Add(new SqlParameter("@gunPhoto", (object)gunPhoto));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Saved Successfully");
show_detail();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void (add coding)button1_Click(object sender, EventArgs e)
{
// con.Open();
// if (con.State.ToString() == "Open")
// {
// MessageBox.Show("hi");
// }
textName.Enabled = true;
textAddress.Enabled = true;
textPhone.Enabled = true;
textPhoto_Path.Enabled = true;
textgpath.Enabled = true;
clear();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void#(first photo(your_photo) browser coding)# button4_Click(object sender, EventArgs e)
{
OpenFileDialog fl = new OpenFileDialog();
DialogResult dl = fl.ShowDialog();
if (dl != DialogResult.Cancel)
{
pictureBox1.ImageLocation = fl.FileName;
textPhoto_Path.Text = fl.FileName;
}
}
byte[] ReadFile(String spath)
{
byte[] data = null;
FileInfo finfo = new FileInfo(spath);
long numbyts = finfo.Length;
FileStream fs = new FileStream(spath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
data = br.ReadBytes((int)numbyts);
return data;
}
private void (writre click datagredeview and write click and go to even cell enter double click and write)dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
string row;
string row1;
string row2;
string row3;
string row4;
string row5;
row = dataGridView1.CurrentRow.Cells["Name"].Value.ToString();
textName.Text = row;
row1 = dataGridView1.CurrentRow.Cells["Id"].Value.ToString();
textId.Text = row1;
row2 = dataGridView1.CurrentRow.Cells["Address"].Value.ToString();
textAddress.Text = row2;
row3 = dataGridView1.CurrentRow.Cells["Phone"].Value.ToString();
textPhone.Text = row3;
row4 = dataGridView1.CurrentRow.Cells["OriginalPath"].Value.ToString();
textPhoto_Path.Text = row4;
row5 = dataGridView1.CurrentRow.Cells["OriginalPath"].Value.ToString();
textgpath.Text = row5;
try
{
byte[] Photo = (byte[])dataGridView1.Rows[e.RowIndex].Cells["Photo"].Value;
Image newImage;
using (MemoryStream ms = new MemoryStream(Photo, 0, Photo.Length))
{
ms.Write(Photo, 0, Photo.Length);
newImage = Image.FromStream(ms, true);
}
pictureBox1.Image = newImage;
byte[] gunPhoto = (byte[])dataGridView1.Rows[e.RowIndex].Cells["gunPhoto"].Value;
Image newImage1;
using (MemoryStream ms = new MemoryStream(gunPhoto, 0, gunPhoto.Length))
{
ms.Write(gunPhoto, 0, gunPhoto.Length);
newImage1 = Image.FromStream(ms, true);
}
pictureBox2.Image = newImage1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void (3 update coding)button3_Click(object sender, EventArgs e)
{
byte[] Photo = ReadFile(textPhoto_Path.Text);
byte[] gPhoto = ReadFile(textgpath.Text);
try
{
string str = "update [check] set Name=@Name,Address=@Address,Phone=@Phone,OriginalPath=@OriginalPath,gPath=@gPath,Photo=@Photo,gunPhoto=@gunPhoto where Id='" + textId.Text + "'";
SqlCommand cmd = new SqlCommand(str, con);
cmd.Parameters.Add(new SqlParameter("@Name", (object)textName.Text));
cmd.Parameters.Add(new SqlParameter("@Address", (object)textAddress.Text));
cmd.Parameters.Add(new SqlParameter("@Phone", (object)textPhone.Text));
cmd.Parameters.Add(new SqlParameter("@OriginalPath", (object)textPhoto_Path.Text));
cmd.Parameters.Add(new SqlParameter("@gPath", (object)textgpath.Text));
cmd.Parameters.Add(new SqlParameter("@Photo", (object)Photo));
cmd.Parameters.Add(new SqlParameter("@gunPhoto", (object)gPhoto));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Updated Successfully");
show_detail();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void (delete coding)button5_Click(object sender, EventArgs e)
{
try
{
if (textDelete.Text == "")
{
MessageBox.Show("Please enter a valid ID.");
}
else
{
con.Open();
SqlCommand cmd = new SqlCommand("delete from [check] where Id='" + textDelete.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Deleted successfully");
show_detail();
textDelete.Text = "";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void (search coding)textSearch_TextChanged(object sender, EventArgs e)
{
if (textSearch.Text == "")
{
show_detail();
}
else
{
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from [check] where Id LIKE '" + textSearch.Text + "%'", con);
DataSet ds = new DataSet();
da.Fill(ds, "[check]");
dataGridView1.DataSource = ds.Tables["[check]"];
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
private void #(second photo(your_gf_photo) browser coding)#button6_Click(object sender, EventArgs e)
{
OpenFileDialog fl1 = new OpenFileDialog();# object should be change#
DialogResult dll = fl1.ShowDialog();
if (dll != DialogResult.Cancel)
{
pictureBox2.ImageLocation = fl1.FileName;
textgpath.Text = fl1.FileName;
}
}
byte[] ReadFile1(String spath)
{
byte[] data = null;
FileInfo finfo = new FileInfo(spath);
long numbyts = finfo.Length;
FileStream fss = new FileStream(spath, FileMode.Open, FileAccess.Read);
BinaryReader brr = new BinaryReader(fss);
data = brr.ReadBytes((int)numbyts);
return data;
}
}
}
.............................Delete by Id Coding................
try
{
if (txtsearch.Text == "")
{
MessageBox.Show("Please enter a valid ID.");
}
else if (txtid.Text == txtsearch.Text)
{
con.Open();
SqlCommand cmd = new SqlCommand("delete from ImagesStore where Employee_Id='" + txtsearch.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Deleted successfully");
detail();
txtdelete.Text = "";
con.Close();
}
else
{
MessageBox.Show("Id not matched");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
..............................Search by Name Coding....................
try
{
if (comboBox1.Text == "Name")
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from ImagesStore where Employee_Name LIKE '" + txtsearch.Text + "%'", con);
DataSet ds = new DataSet();
da.Fill(ds, "ImagesStore");
dataGridView1.DataSource = ds.Tables["ImagesStore"];
con.Close();
}
else if (comboBox1.Text == "Id")
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from ImagesStore where Employee_Id LIKE '" + txtsearch.Text + "%'", con);
DataSet ds = new DataSet();
da.Fill(ds, "ImagesStore");
dataGridView1.DataSource = ds.Tables["ImagesStore"];
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
..........................................Login Coding.................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Threading;
namespace Login_demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=LOGININFO;Integrated Security = true");
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlCommand cmd = new SqlCommand("Select * from GETGO where USERID ='" + textBox1.Text + "' AND PASSWORD ='" + textBox2.Text + "'", cn);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if ((dr.Read()))
{
hii h1 = new hii();
h1.Show();
this.Hide();
cn.Close();
}
else
{
MessageBox.Show("PLEASE ENTER THE VALID USERID & PASWWORD");
textBox1.Clear();
textBox2.Clear();
}
}
catch(Exception exc)
{
MessageBox.Show(exc.Message);
}
}
}
}
No comments:
Post a Comment