Advertisement
Guest User

Untitled

a guest
Feb 19th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  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 Oracle.DataAccess.Client;
  11.  
  12. namespace lab2___ado
  13. {
  14. public partial class Form1 : Form
  15. {
  16. string ChaineConnexion;
  17. OracleConnection conn;
  18. DataSet monDataset = new DataSet();
  19.  
  20. public Form1()
  21. {
  22. InitializeComponent();
  23.  
  24. }
  25.  
  26. private void BTN_connect_Click(object sender, EventArgs e)
  27. {
  28. string username = "MORINJER";
  29. string password = "ORACLE1";
  30. string dSource = "(DESCRIPTION="
  31. + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)"
  32. + "(HOST=mercure.clg.qc.ca)(PORT=1521)))"
  33. + "(CONNECT_DATA=(SERVICE_NAME=ORCL.clg.qc.ca))) ";
  34.  
  35. ChaineConnexion = "Data Source =" + dSource + " ;User Id=" + username + ";Password=" + password + ";";
  36.  
  37. conn = new OracleConnection();
  38. conn.ConnectionString = ChaineConnexion;
  39. try
  40. {
  41. conn.Open();
  42. OracleCommand ObTotal = new OracleCommand("GESTIONEMPLOYES", conn);
  43. ObTotal.CommandText = "GestionEmployes.TOTALEMP";
  44. ObTotal.CommandType = CommandType.StoredProcedure;
  45. TB_nbemp.Text = ObTotal.Parameters["TOTALNBEMP"].Value.ToString();
  46. }
  47. catch (Exception ex)
  48. {
  49. MessageBox.Show(ex.Message);
  50. }
  51. }
  52.  
  53. private void BTN_jaibesoindunbouton_Click(object sender, EventArgs e)
  54. {
  55. try
  56. {
  57. OracleCommand oraAjout = new OracleCommand("GESTIONEMPLOYES", conn);
  58. oraAjout.CommandText = "GESTIONEMPLOYES.INSERTION";
  59. oraAjout.CommandType = CommandType.StoredProcedure;
  60.  
  61. OracleParameter orapamNUMEMP = new OracleParameter("PNUMEMP", OracleDbType.Int32);
  62. orapamNUMEMP.Direction = ParameterDirection.Input;
  63. orapamNUMEMP.Value = TB_num.Text;
  64. oraAjout.Parameters.Add(orapamNUMEMP);
  65.  
  66. OracleParameter orapamNOMEMP = new OracleParameter("PNOMEMP", OracleDbType.Varchar2);
  67. orapamNOMEMP.Direction = ParameterDirection.Input;
  68. orapamNOMEMP.Value = TB_Nom.Text;
  69. oraAjout.Parameters.Add(orapamNOMEMP);
  70.  
  71. OracleParameter orapamPRENOMEMP = new OracleParameter("PPRENOMEMP", OracleDbType.Varchar2);
  72. orapamPRENOMEMP.Direction = ParameterDirection.Input;
  73. orapamPRENOMEMP.Value = TB_Prenom.Text;
  74. oraAjout.Parameters.Add(orapamPRENOMEMP);
  75.  
  76. OracleParameter orapamSALAIREEMP = new OracleParameter("PSALAIREEMP", OracleDbType.Int32);
  77. orapamSALAIREEMP.Direction = ParameterDirection.Input;
  78. orapamSALAIREEMP.Value = TB_Prenom.Text;
  79. oraAjout.Parameters.Add(orapamSALAIREEMP);
  80.  
  81. OracleParameter orapamCODEDEP = new OracleParameter("PCODEDEP", OracleDbType.Char);
  82. orapamCODEDEP.Direction = ParameterDirection.Input;
  83. orapamCODEDEP.Value = TB_Prenom.Text;
  84. oraAjout.Parameters.Add(orapamCODEDEP);
  85.  
  86. oraAjout.ExecuteNonQuery();
  87. }
  88. catch(Exception ex)
  89. {
  90. MessageBox.Show(ex.Message);
  91. }
  92.  
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement