Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. CREATE TABLE [dbo].[tblactividad](
  2. [CodActi] [int] IDENTITY(1,1) NOT NULL,
  3. [DocRefeA] [varchar](8) NULL,
  4. [NomActivi] [nvarchar](100) NOT NULL,
  5. [CodTareas] [int] NULL,
  6. [CodTipo] [int] NULL,
  7. [CodPrio] [int] NULL,
  8. [CodEstad] [int] NULL,
  9. [CodResp] [int] NULL,
  10. [FCreacion] [datetime] NOT NULL,
  11. [FInicio] [datetime] NOT NULL,
  12. [FFin] [datetime] NOT NULL,
  13. [HInicio] [time](7) NULL,
  14. [HFin] [time](7) NULL,
  15. [Tiempo] AS ((((right('0'+CONVERT([varchar](2),datediff(second,
  16. [HInicio],[HFin])/(3600)),(2))+':')+right('0'+CONVERT([varchar](2),
  17. (datediff(second,[HInicio],[HFin])%(3600))/(60)),
  18. (2)))+':')+right('0'+CONVERT([varchar](2),datediff(second,[HInicio],
  19. [HFin])%(60)),(2))) PERSISTED,
  20. [CodComplet] [int] NOT NULL,
  21. [Notas] [varchar](1000) NULL,)
  22.  
  23. private void BtnGuardar_Click(object sender, EventArgs e)
  24. {
  25. if (operacion == "Insertar")
  26. {
  27. objetask.DocRefeA1 = txtReferencia.Text;
  28. objetask.NomActivi1 = txtActividad.Text;
  29. objetask.CodTareas1 = Convert.ToInt32(cmbTarea.SelectedValue);
  30. objetask.CodTipo1 = Convert.ToInt32(cmbTipo.SelectedValue);
  31. objetask.CodPrio1 = Convert.ToInt32(cmbPrioridad.SelectedValue);
  32. objetask.CodEstad1 = Convert.ToInt32(cmbEstado.SelectedValue);
  33. objetask.CodResp1 = Convert.ToInt32(cmbResponsable.SelectedValue);
  34. objetask.FCreacion1 = Convert.ToDateTime(dateCreacion.Value);
  35. objetask.FInicio1 = Convert.ToDateTime(dateInicio.Value);
  36. objetask.FFin1 = Convert.ToDateTime(dateFin.Value);
  37. objetask.HInicio1 = Convert.ToDateTime(dateInicio.Value);
  38. objetask.HFin1 = Convert.ToDateTime(dateFin.Value);
  39. objetask.CodComplet1 = Convert.ToInt32(cmbCompletado.SelectedValue);
  40. objetask.Notas1 = txtNotas.Text;
  41. objetask.InsertarActividad();
  42. MessageBox.Show("Insertado correctamente");
  43. this.Close();
  44. }
  45. else if (operacion == "Editar")
  46. {
  47. objetask.CodActi1 = Convert.ToInt32(CodActi);
  48. objetask.DocRefeA1 = txtReferencia.Text;
  49. objetask.NomActivi1 = txtActividad.Text;
  50. objetask.CodTareas1 = Convert.ToInt32(cmbTarea.SelectedValue);
  51. objetask.CodTipo1 = Convert.ToInt32(cmbTipo.SelectedValue);
  52. objetask.CodPrio1 = Convert.ToInt32(cmbPrioridad.SelectedValue);
  53. objetask.CodEstad1 = Convert.ToInt32(cmbEstado.SelectedValue);
  54. objetask.CodResp1 = Convert.ToInt32(cmbResponsable.SelectedValue);
  55. objetask.FCreacion1 = Convert.ToDateTime(dateCreacion.Value);
  56. objetask.FInicio1 = Convert.ToDateTime(dateInicio.Value);
  57. objetask.FFin1 = Convert.ToDateTime(dateFin.Value);
  58. objetask.HInicio1 = Convert.ToDateTime(dateInicio.Value);
  59. objetask.HFin1 = Convert.ToDateTime(dateFin.Value);
  60. objetask.CodComplet1 = Convert.ToInt32(cmbCompletado.SelectedValue);
  61. objetask.Notas1 = txtNotas.Text;
  62. objetask.ActualizarActividad();
  63. MessageBox.Show("Se edito correctamente");
  64. this.Close();
  65. }
  66. }
  67.  
  68. public void InsertarActividad()
  69. {
  70. using (var connection = GetConnection())
  71. {
  72. connection.Open();
  73. using (var command = new SqlCommand())
  74. {
  75. command.Connection = connection;
  76. command.CommandText = "InsertarActividad";
  77. command.CommandType = CommandType.StoredProcedure;
  78. command.Parameters.AddWithValue("@DocRefeA", DocRefeA);
  79. command.Parameters.AddWithValue("@NomActivi", NomActivi);
  80. command.Parameters.AddWithValue("@Codtareas", CodTareas);
  81. command.Parameters.AddWithValue("@codtipo", CodTipo);
  82. command.Parameters.AddWithValue("@codprio", CodPrio);
  83. command.Parameters.AddWithValue("@codestad", CodEstad);
  84. command.Parameters.AddWithValue("@codresp", CodResp);
  85. command.Parameters.AddWithValue("@fcreacion", FCreacion);
  86. command.Parameters.AddWithValue("@finicio", FInicio);
  87. command.Parameters.AddWithValue("@ffin", FFin);
  88. command.Parameters.AddWithValue("@HInicio",HInicio.TimeOfDay);
  89. command.Parameters.AddWithValue("@HFin", HFin.TimeOfDay);
  90. command.Parameters.AddWithValue("@CodComplet", CodComplet);
  91. command.Parameters.AddWithValue("@Notas", Notas);
  92. command.ExecuteNonQuery();
  93. command.Parameters.Clear();
  94. }
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement