hawzze

ManagmentSystem

Feb 17th, 2020
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.Sql;
  11. using System.Data.SqlClient;
  12.  
  13. namespace ManegmentSystem
  14. {
  15.  
  16.     public partial class Form1 : Form
  17.     {
  18.         SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\user\Documents\ManagmentSystem.mdf;Integrated Security=True;Connect Timeout=30");
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.         private void btnInsert_Click(object sender, EventArgs e)
  25.         {
  26.             ManagemenSystemLogging msl = new ManagemenSystemLogging();
  27.             msl.ShowDialog();
  28.  
  29.  
  30.             con.Open();
  31.             SqlCommand cmd = new SqlCommand("INSERT INTO ManagmentSystem_Table VALUES" +
  32.                 "('" + tbID.Text + ",'" + tbbName.Text + "','" + tbSurname.Text + "','"
  33.                 + tbFamily.Text + "','" + tbSalary.Text + "','" + cbDepartment.Text +
  34.                 "','" + cbPosition.Text + "') ", con);
  35.             cmd.ExecuteNonQuery();
  36.             MessageBox.Show("Data is Insert  Successfully");
  37.             con.Close();
  38.         }
  39.  
  40.         private void btnNew_Click(object sender, EventArgs e)
  41.         {
  42.             tbID.Text = tbbName.Text = tbSurname.Text = tbFamily.Text = tbSalary.Text = "";
  43.         }
  44.  
  45.         private void btnUpdate_Click(object sender, EventArgs e)
  46.         {
  47.             con.Open();
  48.             SqlCommand cmd = new SqlCommand("UPDATE  ManagmentSystem_Table set" +
  49.                 " Name'" + tbbName.Text + "'," +
  50.                 " Surname'" + tbSurname.Text + "'," +
  51.                 " Family'" + tbFamily.Text + "'," +
  52.                 "Salary'" + tbSalary.Text + "', WHERE ID is'" + tbID.Text + "'", con);
  53.             cmd.ExecuteNonQuery();
  54.             MessageBox.Show(" Data is Successfully");
  55.             con.Close();
  56.         }
  57.  
  58.         private void btnDelete_Click(object sender, EventArgs e)
  59.         {
  60.             con.Open();
  61.             SqlCommand cmd = new SqlCommand("DELETE  ManagmentSystem_Table Where ID='"+tbID.Text+"',",con);
  62.             cmd.ExecuteNonQuery();
  63.             MessageBox.Show(" Data is  Successfully Deleted");
  64.             con.Close();
  65.         }
  66.  
  67.         private void btnClear_Click(object sender, EventArgs e)
  68.         {
  69.             tbID.Text = tbbName.Text = tbSurname.Text = tbFamily.Text = tbSalary.Text = "";
  70.         }
  71.  
  72.         private void btnExit_Click(object sender, EventArgs e)
  73.         {
  74.             this.Close();
  75.         }
  76.  
  77.         private void newToolStripMenuItem_Click(object sender, EventArgs e)
  78.         {
  79.             tbID.Text = tbbName.Text = tbSurname.Text = tbFamily.Text = tbSalary.Text = "";
  80.         }
  81.  
  82.         private void insertToolStripMenuItem_Click(object sender, EventArgs e)
  83.         {
  84.             ManagemenSystemLogging msl = new ManagemenSystemLogging();
  85.             msl.ShowDialog();
  86.  
  87.  
  88.             con.Open();
  89.             SqlCommand cmd = new SqlCommand("INSERT INTO ManagmentSystem_Table VALUES" +
  90.                 "('" + tbID.Text + ",'" + tbbName.Text + "','" + tbSurname.Text + "','"
  91.                 + tbFamily.Text + "','" + tbSalary.Text + "','" + cbDepartment.Text +
  92.                 "','" + cbPosition.Text + "') ", con);
  93.             cmd.ExecuteNonQuery();
  94.             MessageBox.Show("Data is Insert  Successfully");
  95.             con.Close();
  96.         }
  97.  
  98.         private void exitToolStripMenuItem_Click(object sender, EventArgs e)
  99.         {
  100.             this.Close();
  101.         }
  102.  
  103.         private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
  104.         {
  105.             con.Open();
  106.             SqlCommand cmd = new SqlCommand("DELETE  ManagmentSystem_Table Where ID='" + tbID.Text + "',", con);
  107.             cmd.ExecuteNonQuery();
  108.             MessageBox.Show(" Data is  Successfully Deleted");
  109.             con.Close();
  110.         }
  111.  
  112.         private void updateToolStripMenuItem_Click(object sender, EventArgs e)
  113.         {
  114.             con.Open();
  115.             SqlCommand cmd = new SqlCommand("UPDATE  ManagmentSystem_Table set" +
  116.                 " Name'" + tbbName.Text + "'," +
  117.                 " Surname'" + tbSurname.Text + "'," +
  118.                 " Family'" + tbFamily.Text + "'," +
  119.                 "Salary'" + tbSalary.Text + "', WHERE ID is'" + tbID.Text + "'", con);
  120.             cmd.ExecuteNonQuery();
  121.             MessageBox.Show(" Data is Successfully");
  122.             con.Close();
  123.         }
  124.  
  125.         private void clearToolStripMenuItem_Click(object sender, EventArgs e)
  126.         {
  127.             tbID.Text = tbbName.Text = tbSurname.Text = tbFamily.Text = tbSalary.Text = "";
  128.         }
  129.  
  130.         private void Form1_Load(object sender, EventArgs e)
  131.         {
  132.  
  133.         }
  134.  
  135.         private void tbbName_KeyPress(object sender, KeyPressEventArgs e)
  136.         {
  137.             e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  138.         }
  139.  
  140.         private void tbSurname_KeyPress(object sender, KeyPressEventArgs e)
  141.         {
  142.             e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  143.         }
  144.  
  145.         private void tbFamily_KeyPress(object sender, KeyPressEventArgs e)
  146.         {
  147.             e.Handled = !(char.IsLetter(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  148.         }
  149.  
  150.         private void tbID_KeyPress(object sender, KeyPressEventArgs e)
  151.         {
  152.             e.Handled = !(char.IsNumber(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  153.         }
  154.  
  155.         private void tbSalary_KeyPress(object sender, KeyPressEventArgs e)
  156.         {
  157.             e.Handled = !(char.IsNumber(e.KeyChar) || e.KeyChar == (char)Keys.Back);
  158.         }
  159.  
  160.         private void btnDeleteFromID_Click(object sender, EventArgs e)
  161.         {
  162.             string constring = (@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\user\Documents\ManagmentSystem.mdf;Integrated Security=True;Connect Timeout=30");
  163.             string Query="delete from database.edata set Eid='"+
  164.  
  165.  
  166.         }
  167. }
RAW Paste Data