Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE [dbo].[tblactividad](
- [CodActi] [int] IDENTITY(1,1) NOT NULL,
- [DocRefeA] [varchar](8) NULL,
- [NomActivi] [nvarchar](100) NOT NULL,
- [CodTareas] [int] NULL,
- [CodTipo] [int] NULL,
- [CodPrio] [int] NULL,
- [CodEstad] [int] NULL,
- [CodResp] [int] NULL,
- [FCreacion] [datetime] NOT NULL,
- [FInicio] [datetime] NOT NULL,
- [FFin] [datetime] NOT NULL,
- [HInicio] [time](7) NULL,
- [HFin] [time](7) NULL,
- [Tiempo] AS ((((right('0'+CONVERT([varchar](2),datediff(second,
- [HInicio],[HFin])/(3600)),(2))+':')+right('0'+CONVERT([varchar](2),
- (datediff(second,[HInicio],[HFin])%(3600))/(60)),
- (2)))+':')+right('0'+CONVERT([varchar](2),datediff(second,[HInicio],
- [HFin])%(60)),(2))) PERSISTED,
- [CodComplet] [int] NOT NULL,
- [Notas] [varchar](1000) NULL,)
- private void BtnGuardar_Click(object sender, EventArgs e)
- {
- if (operacion == "Insertar")
- {
- objetask.DocRefeA1 = txtReferencia.Text;
- objetask.NomActivi1 = txtActividad.Text;
- objetask.CodTareas1 = Convert.ToInt32(cmbTarea.SelectedValue);
- objetask.CodTipo1 = Convert.ToInt32(cmbTipo.SelectedValue);
- objetask.CodPrio1 = Convert.ToInt32(cmbPrioridad.SelectedValue);
- objetask.CodEstad1 = Convert.ToInt32(cmbEstado.SelectedValue);
- objetask.CodResp1 = Convert.ToInt32(cmbResponsable.SelectedValue);
- objetask.FCreacion1 = Convert.ToDateTime(dateCreacion.Value);
- objetask.FInicio1 = Convert.ToDateTime(dateInicio.Value);
- objetask.FFin1 = Convert.ToDateTime(dateFin.Value);
- objetask.HInicio1 = Convert.ToDateTime(dateInicio.Value);
- objetask.HFin1 = Convert.ToDateTime(dateFin.Value);
- objetask.CodComplet1 = Convert.ToInt32(cmbCompletado.SelectedValue);
- objetask.Notas1 = txtNotas.Text;
- objetask.InsertarActividad();
- MessageBox.Show("Insertado correctamente");
- this.Close();
- }
- else if (operacion == "Editar")
- {
- objetask.CodActi1 = Convert.ToInt32(CodActi);
- objetask.DocRefeA1 = txtReferencia.Text;
- objetask.NomActivi1 = txtActividad.Text;
- objetask.CodTareas1 = Convert.ToInt32(cmbTarea.SelectedValue);
- objetask.CodTipo1 = Convert.ToInt32(cmbTipo.SelectedValue);
- objetask.CodPrio1 = Convert.ToInt32(cmbPrioridad.SelectedValue);
- objetask.CodEstad1 = Convert.ToInt32(cmbEstado.SelectedValue);
- objetask.CodResp1 = Convert.ToInt32(cmbResponsable.SelectedValue);
- objetask.FCreacion1 = Convert.ToDateTime(dateCreacion.Value);
- objetask.FInicio1 = Convert.ToDateTime(dateInicio.Value);
- objetask.FFin1 = Convert.ToDateTime(dateFin.Value);
- objetask.HInicio1 = Convert.ToDateTime(dateInicio.Value);
- objetask.HFin1 = Convert.ToDateTime(dateFin.Value);
- objetask.CodComplet1 = Convert.ToInt32(cmbCompletado.SelectedValue);
- objetask.Notas1 = txtNotas.Text;
- objetask.ActualizarActividad();
- MessageBox.Show("Se edito correctamente");
- this.Close();
- }
- }
- public void InsertarActividad()
- {
- using (var connection = GetConnection())
- {
- connection.Open();
- using (var command = new SqlCommand())
- {
- command.Connection = connection;
- command.CommandText = "InsertarActividad";
- command.CommandType = CommandType.StoredProcedure;
- command.Parameters.AddWithValue("@DocRefeA", DocRefeA);
- command.Parameters.AddWithValue("@NomActivi", NomActivi);
- command.Parameters.AddWithValue("@Codtareas", CodTareas);
- command.Parameters.AddWithValue("@codtipo", CodTipo);
- command.Parameters.AddWithValue("@codprio", CodPrio);
- command.Parameters.AddWithValue("@codestad", CodEstad);
- command.Parameters.AddWithValue("@codresp", CodResp);
- command.Parameters.AddWithValue("@fcreacion", FCreacion);
- command.Parameters.AddWithValue("@finicio", FInicio);
- command.Parameters.AddWithValue("@ffin", FFin);
- command.Parameters.AddWithValue("@HInicio",HInicio.TimeOfDay);
- command.Parameters.AddWithValue("@HFin", HFin.TimeOfDay);
- command.Parameters.AddWithValue("@CodComplet", CodComplet);
- command.Parameters.AddWithValue("@Notas", Notas);
- command.ExecuteNonQuery();
- command.Parameters.Clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement