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"); } } }