private void button4_Click(object sender, EventArgs e) { string just = "NO"; if (radsi.Checked == true) { just = "SI"; } DateTime x1 = DateTime.Parse(fecha1.Value.ToString("yyyy-MM-dd")); DateTime x2 = DateTime.Parse(fecha2.Value.ToString("yyyy-MM-dd")); if (x1 > x2) { MessageBox.Show("Fecha Invalida"); } else { if (string.IsNullOrWhiteSpace(descripcion.Text) == false && string.IsNullOrWhiteSpace(departamento.Text) == false) { string cadenasql = @"INSERT INTO [Permiso] ([Descripcion],[FechaInicio],[FechaFinal],[Justificado],[IDEmpleado],[Sala]) VALUES('" + descripcion.Text + "', '" + fecha1.Value.ToString("yyyy-MM-dd") + "', '" + fecha2.Value.ToString("yyyy-MM-dd") + "', '" + just + "', " + frm1.xd + ", '" + departamento.Text + "')"; Mantenimiento.insertar(cadenasql); frm1.updater(); this.Close(); } else { MessageBox.Show("No se permiten espacios en blanco"); } } }
private void button4_Click(object sender, EventArgs e) { string just = "Profilactica"; if (ord.Checked == true) { just = "Ordinaria"; } DateTime x1 = DateTime.Parse(fecha1.Value.ToString("yyyy-MM-dd")); DateTime x2 = DateTime.Parse(fecha2.Value.ToString("yyyy-MM-dd")); double bd = Mantenimiento.GetBusinessDays(x1, x2); if (x1 > x2) { MessageBox.Show("Fecha Invalida"); } else { if (bd <= diasV)// vacaciones warning { string cadenasql = @"INSERT INTO [Vacaciones]([Inicio],[Final],[TipoVacacion],[IDEmpleado]) VALUES('" + fecha1.Value.ToString("yyyy-MM-dd") + "','" + fecha2.Value.ToString("yyyy-MM-dd") + "','" + just + "'," + frm1.xd + ")"; Mantenimiento.insertar(cadenasql); frm1.updater(); this.Close(); } else { MessageBox.Show("Se excedieron los dias disponibles"); } } }
private void button4_Click(object sender, EventArgs e) { string tipo = ""; string compromiso = ""; string compromiso2 = ""; DateTime x1 = fecha1.Value.Date + date3.Value.TimeOfDay; DateTime x2 = fecha2.Value.Date + date4.Value.TimeOfDay; if (especialista.Checked == true) { tipo = especialista.Text; } if (odonto.Checked == true) { tipo = odonto.Text; } if (general.Checked == true) { tipo = general.Text; } if (ss.Checked == true) { tipo = ss.Text; } if (micro.Checked == true) { tipo = micro.Text; } if (guardia.Checked == true) { compromiso = guardia.Text; } if (jornada.Checked == true) { compromiso = jornada.Text; } if (pago.Checked == true) { compromiso2 = pago.Text; } if (tiempo.Checked == true) { compromiso2 = tiempo.Text; } if (x1 > x2) { MessageBox.Show("Fecha Invalida"); } else { if (string.IsNullOrWhiteSpace(servicio.Text) == false && string.IsNullOrWhiteSpace(companero.Text) == false && string.IsNullOrWhiteSpace(servicio2.Text) == false && string.IsNullOrWhiteSpace(motivo.Text) == false) { int permPago = Mantenimiento.returnInt("select count(*) from Convenio where IDEmpleado = " + frm1.xd + " and CompromisoPago = 'PAGO MONETARIO' and month(FechaInicio) = month(GETDATE())"); if (permPago >= 5 && (pago.Checked == true)) { DialogResult dialogResult = MessageBox.Show("Este empleado ya tiene 5 convenios pagados o mas.¿Desea continuar?", "Advertencia", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { string cadenasql = @"INSERT INTO Convenio([IDEmpleado],[TipoMedico],[ServicioSolicitante],[Compromiso] ,[FechaInicio],[FechaFinal],[Companero],[ServicioCompanero],[CompromisoPago] ,[motivo])VALUES ( " + frm1.xd + " ,'" + tipo + "','" + servicio.Text + "','" + compromiso + "','" + x1.ToString("yyyy-MM-dd HH:mm") + "','" + x2.ToString("yyyy-MM-dd HH:mm") + "','" + companero.Text + "','" + servicio2.Text + "','" + compromiso2 + "','" + motivo.Text + "')"; Mantenimiento.insertar(cadenasql); frm1.updater(); this.Close(); } else if (dialogResult == DialogResult.No) { } } else { string cadenasql = @"INSERT INTO Convenio([IDEmpleado],[TipoMedico],[ServicioSolicitante],[Compromiso] ,[FechaInicio],[FechaFinal],[Companero],[ServicioCompanero],[CompromisoPago] ,[motivo])VALUES ( " + frm1.xd + " ,'" + tipo + "','" + servicio.Text + "','" + compromiso + "','" + x1.ToString("yyyy-MM-dd HH:mm") + "','" + x2.ToString("yyyy-MM-dd HH:mm") + "','" + companero.Text + "','" + servicio2.Text + "','" + compromiso2 + "','" + motivo.Text + "')"; Mantenimiento.insertar(cadenasql); frm1.updater(); this.Close(); } } else { MessageBox.Show("No se permiten espacios en blanco"); } } }