Exemplo n.º 1
0
        public int updateEmergencia(DTOSolicitud dto)
        {
            try
            {
                StringBuilder SQLString  = new StringBuilder();
                ArrayList     Parametros = new ArrayList();


                SQLString.Append("UPDATE solicitud SET origen=@origen, razon=@razon, codasociado=@codasociado");
                SQLString.Append(" WHERE codigo=@codigo");

                Parametros.Add(new MySqlParameter("@codigo", (object)dto.Codigo));
                Parametros.Add(new MySqlParameter("@origen", (object)dto.Origen));
                Parametros.Add(new MySqlParameter("@razon", (object)dto.Razon));
                Parametros.Add(new MySqlParameter("@codasociado", (object)dto.Codasociado));


                MySqlCommand orden = ObtenerOrdenSqlInsert(SQLString.ToString(), Parametros);
                orden.Connection.Open();
                int x = orden.ExecuteNonQuery();
                orden.Connection.Close();
                return(x);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 2
0
        public DataSet select(DTOSolicitud dto)
        {
            try
            {
                DataSet       ds         = new DataSet();
                StringBuilder SQLString  = new StringBuilder();
                StringBuilder Campos     = new StringBuilder();
                ArrayList     Parametros = new ArrayList();

                SQLString.Append("Select * From Solicitud");
                if (dto == null)
                {
                    throw new NullReferenceException("DAOSolicitud.select(dto)");
                }
                if (dto.Codigo != null)
                {
                    Campos.Append("codigo = @codigo AND ");
                    Parametros.Add(new MySqlParameter("@codigo", (object)dto.Codigo));
                }
                if (Campos.Length > 0)
                {
                    SQLString.Append(" WHERE ");
                    SQLString.Append(Campos.ToString().Substring(0, Campos.ToString().Length - 4));
                }
                MySqlCommand     orden = ObtenerOrdenSql(SQLString.ToString(), Parametros);
                MySqlDataAdapter da    = new MySqlDataAdapter(orden);
                da.Fill(ds);

                return(ds);
            }catch (Exception ex) {
                throw(ex);
            }
        }
Exemplo n.º 3
0
        public int insert(DTOSolicitud dto)
        {
            try
            {
                StringBuilder SQLString  = new StringBuilder();
                ArrayList     Parametros = new ArrayList();

                int cod = MaxSolicitud();

                SQLString.Append("INSERT INTO Solicitud(codigo, fechsolicitud,nomsolicitante, areasolicitante, origen, codasociado, titulo, razon, sociedadafectada, pripropuesta, fecpropuesta, sisafectado, ambafectado, impactoest, indispropuesta, areainvolucrada, reuprevia, descambio, justcambio, criteriosaceptacion) VALUES ");
                SQLString.Append("(@codigo, @fechsolicitud, @nomsolicitante, @areasolicitante, @origen, @codasociado, @titulo, @razon, @sociedadafectada, @pripropuesta, @fecpropuesta, @sisafectado, @ambafectado, @impactoest, @indisponibilidad, @areainvolucrada, @reuprevia, @descambio, @justcambio, @criteriosaceptacion); ");

                Parametros.Add(new MySqlParameter("@codigo", (object)cod));
                Parametros.Add(new MySqlParameter("@fechsolicitud", (object)dto.Fechsolicitud));
                Parametros.Add(new MySqlParameter("@nomsolicitante", (object)dto.Nomsolicitante));
                Parametros.Add(new MySqlParameter("@areasolicitante", (object)dto.Areasolicitante));
                Parametros.Add(new MySqlParameter("@origen", (object)dto.Origen));
                Parametros.Add(new MySqlParameter("@codasociado", (object)dto.Codasociado));
                Parametros.Add(new MySqlParameter("@titulo", (object)dto.Titulo));
                Parametros.Add(new MySqlParameter("@razon", (object)dto.Razon));
                Parametros.Add(new MySqlParameter("@sociedadafectada", (object)dto.Sociedadafectada));
                Parametros.Add(new MySqlParameter("@pripropuesta", (object)dto.Pripropuesta));
                Parametros.Add(new MySqlParameter("@fecpropuesta", (object)dto.Fecpropuesta));
                Parametros.Add(new MySqlParameter("@sisafectado", (object)dto.Sisafectado));
                Parametros.Add(new MySqlParameter("@ambafectado", (object)dto.Ambafectado));
                Parametros.Add(new MySqlParameter("@impactoest", (object)dto.Impactoest));
                Parametros.Add(new MySqlParameter("@indisponibilidad", (object)dto.Indispropuesta));
                Parametros.Add(new MySqlParameter("@areainvolucrada", (object)dto.Areainvolucrada));
                Parametros.Add(new MySqlParameter("@reuprevia", (object)dto.Reuprevia));
                Parametros.Add(new MySqlParameter("@descambio", (object)dto.Descambio));
                Parametros.Add(new MySqlParameter("@justcambio", (object)dto.Justcambio));
                Parametros.Add(new MySqlParameter("@criteriosaceptacion", (object)dto.Criteriosaceptacion));

                MySqlCommand orden = ObtenerOrdenSqlInsert(SQLString.ToString(), Parametros);
                orden.Connection.Open();
                int x = orden.ExecuteNonQuery();
                if (x > 0)
                {
                    dto.Codigo = (Int32?)orden.LastInsertedId;
                }
                orden.Connection.Close();
                return(cod);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 4
0
        public int delete(DTOSolicitud dto)
        {
            try
            {
                StringBuilder SQLString  = new StringBuilder();
                ArrayList     Parametros = new ArrayList();


                SQLString.Append("DELETE FROM solicitud");
                SQLString.Append(" WHERE codigo=@codigo");

                Parametros.Add(new MySqlParameter("@codigo", (object)dto.Codigo));

                MySqlCommand orden = ObtenerOrdenSqlInsert(SQLString.ToString(), Parametros);
                orden.Connection.Open();
                int x = orden.ExecuteNonQuery();
                orden.Connection.Close();
                return(x);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 5
0
        private void btnAprobar_Click(object sender, EventArgs e)
        {
            if (txtcorraporemer.Text == "" && txtcorraporexce.Text == "" && txtcorreocomite.Text == "")
            {
                MessageBox.Show("Adjuntar el Correo de Aprobacion");
                return;
            }
            string targetPath = "";

            if (VariablesGlobales.ambienteDestino == "PRD")
            {
                targetPath = @"\\corjsmsrv1.grupocogesa.gromero.net\Publico\PublicoCSC\#TI\Repositorio-RFC\Correos-Aprobacion";
            }
            else
            {
                targetPath = @"D:\AppCambios\Aprobacion";
            }



            string destFile = System.IO.Path.Combine(targetPath, "RFC" + rq.getCodigo.Text + ".msg");

            if (groupBoxEmergencia.Visible == true)
            {
                if (comboBoxAprobador.SelectedIndex == -1 || txtincidente.Text == "")
                {
                    MessageBox.Show("Porfavor ingresar todo los datos");
                    return;
                }

                rq.guardar();

                DAORFC dao = new DAORFC();
                DTORfc rfc = new DTORfc();
                rfc.Codigo = (Int32)int.Parse(rq.getCodigo.Text);
                rfc.Estado = "Aprobado";
                //rfc.Aprobador = comboBoxAprobador.ValueMember.ToString();
                rfc.Aprobador     = comboBoxAprobador.SelectedItem.ToString();
                rfc.Fecaprobacion = dateTimePickerAprobacion.Value;
                rfc.Motivo        = "Incidente";

                System.IO.File.Copy(txtcorraporemer.Text, destFile, true);
                rfc.Correo_aprobacion = destFile;

                if (dao.updateAprobarMenor(rfc) > 0)
                {
                    rq.getEstado.Text = "Aprobado";

                    DAOSolicitud daosolicitud = new DAOSolicitud();
                    DTOSolicitud solicitud    = new DTOSolicitud();
                    solicitud.Codigo      = rfc.Codigo;
                    solicitud.Origen      = 1;
                    solicitud.Razon       = 4;
                    solicitud.Codasociado = txtincidente.Text;

                    daosolicitud.updateEmergencia(solicitud);


                    rq.FormatodeUI();
                    cac x = (cac)this;
                    x.Close();
                }
            }
            else
            {
                if (getGrupoMedioMayor.Visible == true)
                {
                    rq.guardar();

                    DAORFC dao = new DAORFC();
                    DTORfc rfc = new DTORfc();
                    rfc.Codigo        = (Int32)int.Parse(rq.getCodigo.Text);
                    rfc.Estado        = "Aprobado";
                    rfc.Aprobador     = "CAC";
                    rfc.Fecaprobacion = dateTimePickerCAC.Value;
                    System.IO.File.Copy(txtcorreocomite.Text, destFile, true);
                    rfc.Correo_aprobacion = destFile;

                    if (dao.updateAprobarMenor(rfc) > 0)
                    {
                        rq.getEstado.Text = "Aprobado";
                        rq.FormatodeUI();
                        cac x = (cac)this;
                        x.Close();
                    }
                }
                else
                {
                    rq.guardar();

                    DAORFC dao = new DAORFC();
                    DTORfc rfc = new DTORfc();
                    rfc.Codigo = (Int32)int.Parse(rq.getCodigo.Text);
                    rfc.Estado = "Aprobado";
                    //rfc.Aprobador = comboBoxAprobadorExc.ValueMember.ToString();
                    rfc.Aprobador     = comboBoxAprobadorExc.SelectedItem.ToString();
                    rfc.Fecaprobacion = dateTimePicker1.Value;
                    rfc.Motivo        = cboMotivo.SelectedItem.ToString();
                    System.IO.File.Copy(txtcorraporexce.Text, destFile, true);
                    rfc.Correo_aprobacion = destFile;

                    if (dao.updateAprobarMenor(rfc) > 0)
                    {
                        rq.getEstado.Text = "Aprobado";
                        rq.FormatodeUI();
                        cac x = (cac)this;
                        x.Close();
                    }
                }
            }

            string titulo = rq.getCodigo.Text + " - " + rq.gettxtdescripcion.Text;


            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Coordinador: " + rq.getCoordinador.Text);
            sb.AppendLine(" Descripcion: " + rq.gettxtdescripcioncambio.Text);
            if (rq.Txtlink.Text != "")
            {
                sb.AppendLine(" Ruta del Plan: " + rq.Txtlink.Text);
            }

            if (VariablesGlobales.ambienteDestino == "PRD")
            {
                CreateMeetingRequest("*****@*****.**", titulo, sb.ToString(), rq.getIni.Value, rq.getFin.Value);
            }
        }
Exemplo n.º 6
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            string Chosen_File = "";

            openFileDialog1.Title    = "Ingresa la Solicitud";
            openFileDialog1.FileName = "";
            openFileDialog1.Filter   = "Archivos Excel *.xls|*.xls*";
            openFileDialog1.ShowDialog();

            Chosen_File = openFileDialog1.FileName;

            if (Chosen_File == "")
            {
                MessageBox.Show("No ha Seleccionado ningun Archivo");
            }
            else
            {
                Excel.Application xlApp;
                Excel.Workbook    xlWorkBook;
                Excel.Worksheet   xlWorkSheet;
                object            misValue = System.Reflection.Missing.Value;

                xlApp       = new Excel.Application();
                xlWorkBook  = xlApp.Workbooks.Open(Chosen_File, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

                if (xlWorkSheet.Name != "Formulario")
                {
                    MessageBox.Show("No es un Archivo Valido");
                }
                else
                {
                    DTOSolicitud nuevo = new DTOSolicitud();

                    /*nuevo.Fechsolicitud = xlWorkSheet.get_Range("C5", "C5").Value; //Fechsolicitud
                     * nuevo.Nomsolicitante = xlWorkSheet.get_Range("C10", "C10").Value2.ToString(); //nomsolicitante
                     * nuevo.Areasolicitante = Int32.Parse(xlWorkSheet.get_Range("C11", "C11").Value2.ToString()); //areasolicitante
                     * nuevo.Origen = ValorOrigen(Int32.Parse(xlWorkSheet.get_Range("F10", "F10").Value2.ToString())); //origen
                     * nuevo.Codasociado = xlWorkSheet.get_Range("F11", "F11").Value2.ToString(); //codigoasociado
                     * nuevo.Titulo = xlWorkSheet.get_Range("C16", "C16").Value2.ToString(); //Titulo
                     * nuevo.Razon = ValorOrigen(Int32.Parse(xlWorkSheet.get_Range("C18", "C18").Value2.ToString()));//razon
                     * nuevo.Pripropuesta = xlWorkSheet.get_Range("C20", "C20").Value2.ToString();//pripropuesta
                     * //nuevo.Empafectada = xlWorkSheet.get_Range("C19", "C19").Value2.ToString();//empafectada
                     * nuevo.Indispropuesta = Int32.Parse(xlWorkSheet.get_Range("C21", "C21").Value2.ToString());//indispopropueta
                     * nuevo.Sisafectado = xlWorkSheet.get_Range("F19", "F19").Value2.ToString();//sisafectado
                     * nuevo.Ambafectado = Int32.Parse(xlWorkSheet.get_Range("F20", "F20").Value2.ToString());//ambafectado
                     * nuevo.Fecpropuesta = xlWorkSheet.get_Range("F18", "F18").Value.ToString();//fecpropuesta
                     * nuevo.Impactoest = xlWorkSheet.get_Range("F21", "F21").Value2.ToString();//impactoest
                     * nuevo.Areainvolucrada = xlWorkSheet.get_Range("B27", "B27").Value2.ToString();//Areasinvolucradas
                     * nuevo.Reuprevia = xlWorkSheet.get_Range("F26", "F26").Value2.ToString();//revisionprevia
                     * nuevo.Descambio = limpiar(xlWorkSheet.get_Range("B34", "B34").Value2.ToString());//descambio
                     * nuevo.Justcambio = limpiar(xlWorkSheet.get_Range("B42", "B42").Value2.ToString());//justcambio
                     * nuevo.Criteriosaceptacion = limpiar(xlWorkSheet.get_Range("B48", "B48").Value2.ToString());//criteriosaceptacion*/



                    nuevo.Fechsolicitud   = xlWorkSheet.get_Range("C5", "C5").Value;                            //Fechsolicitud
                    nuevo.Nomsolicitante  = xlWorkSheet.get_Range("C10", "C10").Value2.ToString();              //nomsolicitante
                    nuevo.Areasolicitante = Int32.Parse(xlWorkSheet.get_Range("C11", "C11").Value2.ToString()); //areasolicitante
                    nuevo.Origen          = Int32.Parse(xlWorkSheet.get_Range("F10", "F10").Value2.ToString()); //origen
                    if (xlWorkSheet.get_Range("F11", "F11").Value2.ToString() == null)
                    {
                        nuevo.Codasociado = "";
                    }
                    else
                    {
                        nuevo.Codasociado = xlWorkSheet.get_Range("F11", "F11").Value2.ToString();                  //codigoasociado
                    }
                    nuevo.Titulo              = xlWorkSheet.get_Range("C16", "C16").Value2.ToString();              //Titulo
                    nuevo.Razon               = Int32.Parse(xlWorkSheet.get_Range("C18", "C18").Value2.ToString()); //razon
                    nuevo.Pripropuesta        = Int32.Parse(xlWorkSheet.get_Range("C20", "C20").Value2.ToString()); //pripropuesta
                    nuevo.Sociedadafectada    = Int32.Parse(xlWorkSheet.get_Range("C19", "C19").Value2.ToString()); //empafectada
                    nuevo.Indispropuesta      = Int32.Parse(xlWorkSheet.get_Range("C21", "C21").Value2.ToString()); //indispopropueta
                    nuevo.Sisafectado         = xlWorkSheet.get_Range("F19", "F19").Value2.ToString();              //sisafectado
                    nuevo.Ambafectado         = Int32.Parse(xlWorkSheet.get_Range("F20", "F20").Value2.ToString()); //ambafectado
                    nuevo.Fecpropuesta        = xlWorkSheet.get_Range("F18", "F18").Value;                          //fecpropuesta
                    nuevo.Impactoest          = Int32.Parse(xlWorkSheet.get_Range("F21", "F21").Value2.ToString()); //impactoest
                    nuevo.Areainvolucrada     = xlWorkSheet.get_Range("B27", "B27").Value2.ToString();              //Areasinvolucradas
                    nuevo.Reuprevia           = Int32.Parse(xlWorkSheet.get_Range("F26", "F26").Value2.ToString()); //revisionprevia
                    nuevo.Descambio           = limpiar(xlWorkSheet.get_Range("B34", "B34").Value2.ToString());     //descambio
                    nuevo.Justcambio          = limpiar(xlWorkSheet.get_Range("B42", "B42").Value2.ToString());     //justcambio
                    nuevo.Criteriosaceptacion = limpiar(xlWorkSheet.get_Range("B48", "B48").Value2.ToString());     //criteriosaceptacion



                    DAOSolicitud dao = new DAOSolicitud();

                    int codigo = dao.insert(nuevo);
                    if (codigo > 0)
                    {
                        //nuevo.Codigo = codigo;
                        MessageBox.Show("registrado!");
                        AbrirSolicitud(nuevo.Codigo);
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }


                    xlWorkBook.Close(false, misValue, misValue);
                    xlApp.Quit();

                    releaseObject(xlWorkSheet);
                    releaseObject(xlWorkBook);
                    releaseObject(xlApp);
                }
            }
        }
Exemplo n.º 7
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            DTORfc       rfc        = new DTORfc();
            DTOSolicitud solicitud  = new DTOSolicitud();
            DAORFC       dao        = new DAORFC();
            int          tipoCambio = 0;

            //Estado
            if (cbobusestado.SelectedIndex != 0 && cbobusestado.SelectedIndex != -1)
            {
                rfc.Estado = cbobusestado.SelectedItem.ToString();
            }
            else
            {
                rfc.Estado = null;
            }

            //Indisponibilidad
            if (cbobusindis.SelectedIndex != 0 && cbobusindis.SelectedIndex != -1)
            {
                rfc.Indisponibilidad = (Int32)cbobusindis.SelectedIndex;
            }
            else
            {
                rfc.Indisponibilidad = -1;
            }

            //Tipo de cambio
            if (radioButtonall.Checked)
            {
                tipoCambio = 1;
            }
            if (radioButtonMenor.Checked)
            {
                tipoCambio = 2;
            }
            if (radioButtonMed.Checked)
            {
                tipoCambio = 3;
            }
            if (radioButtonUrg.Checked)
            {
                tipoCambio = 4;
            }

            //Area del Cambio - Categoria Activo
            if (cbobusareacambio.SelectedIndex != 0 && cbobusareacambio.SelectedIndex != -1)
            {
                rfc.Cateinfra = cbobusareacambio.SelectedItem.ToString();
            }
            else
            {
                rfc.Cateinfra = null;
            }

            //Solicitante
            if (txtbussolicitante.Text != "")
            {
                solicitud.Nomsolicitante = txtbussolicitante.Text;
            }
            else
            {
                solicitud.Nomsolicitante = null;
            }

            //Coordinador
            if (txtbuscoordinador.Text != "")
            {
                rfc.Coordinador = txtbuscoordinador.Text;
            }
            else
            {
                rfc.Coordinador = null;
            }

            //Empresa Afectada
            if (cbobusempresa.SelectedIndex != 0 && cbobusempresa.SelectedIndex != -1)
            {
                solicitud.Empresa = cbobusempresa.SelectedItem.ToString();
            }
            else
            {
                solicitud.Sociedadafectada = -1;
            }

            //Area Solicitante
            if (cbobusareasoli.SelectedIndex != 0 && cbobusareasoli.SelectedIndex != -1)
            {
                solicitud.Areasolicitante = (Int32)cbobusareasoli.SelectedIndex;
            }
            else
            {
                solicitud.Areasolicitante = -1;
            }

            if (radioButtonFR.Checked)
            {
                solicitud.Fechsolicitud       = dateTimePickerbusIni.Value;
                solicitud.Fecpropuesta        = dateTimePickerbusFin.Value;
                rfc.Fecprogramadaejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecprogramadafinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecharealejecucion        = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecharealfinalizacion     = new DateTime(1900, 01, 01, 00, 00, 00);
            }
            else
            {
                solicitud.Fechsolicitud = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fecpropuesta  = new DateTime(1900, 01, 01, 00, 00, 00);
            }

            if (radioButtonFIP.Checked)
            {
                rfc.Fecprogramadaejecucion    = dateTimePickerbusIni.Value;
                rfc.Fecprogramadafinalizacion = dateTimePickerbusFin.Value;
                rfc.Fecharealejecucion        = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecharealfinalizacion     = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fechsolicitud       = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fecpropuesta        = new DateTime(1900, 01, 01, 00, 00, 00);
            }
            else
            {
                rfc.Fecprogramadaejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecprogramadafinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);

                if (radioButtonFIR.Checked)
                {
                    rfc.Fecharealejecucion        = dateTimePickerbusIni.Value;
                    rfc.Fecharealfinalizacion     = dateTimePickerbusFin.Value;
                    rfc.Fecprogramadaejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                    rfc.Fecprogramadafinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);
                    solicitud.Fechsolicitud       = new DateTime(1900, 01, 01, 00, 00, 00);
                    solicitud.Fecpropuesta        = new DateTime(1900, 01, 01, 00, 00, 00);
                }
                else
                {
                    rfc.Fecharealejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                    rfc.Fecharealfinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);
                }

                if (VariablesGlobales.TipoRol != "Gestor")
                {
                    rfc.Coordinador = VariablesGlobales.nomUsu;
                }
            }
            DataTable dt = dao.selectCostum(rfc, solicitud, true, false, tipoCambio);



            if (dt == null)
            {
                MessageBox.Show("No Hay Datos");
            }
            else
            {
                //DataGridView dg = new DataGridView();
                //dg.DataSource = dt;
                dataGridView1.DataSource = dt;
            }
        }
Exemplo n.º 8
0
        private void saveFileDialog1_FileOk_1(object sender, CancelEventArgs e)
        {
            // Get file name.
            string name = saveFileDialog1.FileName;

            //DataGrid
            DTORfc       rfc        = new DTORfc();
            DTOSolicitud solicitud  = new DTOSolicitud();
            DAORFC       dao        = new DAORFC();
            int          tipoCambio = 0;


            //Estado
            if (cbobusestado.SelectedIndex != 0 && cbobusestado.SelectedIndex != -1)
            {
                rfc.Estado = cbobusestado.SelectedItem.ToString();
            }
            else
            {
                rfc.Estado = null;
            }

            //Indisponibilidad
            if (cbobusindis.SelectedIndex != 0 && cbobusindis.SelectedIndex != -1)
            {
                rfc.Indisponibilidad = (Int32)cbobusindis.SelectedValue;
            }
            else
            {
                rfc.Indisponibilidad = -1;
            }

            //Tipo de cambio
            if (radioButtonall.Checked)
            {
                tipoCambio = 1;
            }

            if (radioButtonMenor.Checked)
            {
                tipoCambio = 2;
            }
            if (radioButtonMed.Checked)
            {
                tipoCambio = 3;
            }
            if (radioButtonUrg.Checked)
            {
                tipoCambio = 4;
            }

            //Area del Cambio - Categoria Activo
            if (cbobusareacambio.SelectedIndex != 0 && cbobusareacambio.SelectedIndex != -1)
            {
                rfc.Cateinfra = cbobusareacambio.SelectedItem.ToString();
            }
            else
            {
                rfc.Cateinfra = null;
            }

            //Solicitante
            if (txtbussolicitante.Text != "")
            {
                solicitud.Nomsolicitante = txtbussolicitante.Text;
            }
            else
            {
                solicitud.Nomsolicitante = null;
            }

            //Coordinador
            if (txtbuscoordinador.Text != "")
            {
                rfc.Coordinador = txtbuscoordinador.Text;
            }
            else
            {
                rfc.Coordinador = null;
            }

            //Empresa Afectada
            if (cbobusempresa.SelectedIndex != 0 && cbobusempresa.SelectedIndex != -1)
            {
                solicitud.Sociedadafectada = (Int32)cbobusempresa.SelectedValue;
            }
            else
            {
                solicitud.Sociedadafectada = -1;
            }

            //Area Solicitante
            if (cbobusareasoli.SelectedIndex != 0 && cbobusareasoli.SelectedIndex != -1)
            {
                solicitud.Areasolicitante = (Int32)cbobusareasoli.SelectedValue;
            }
            else
            {
                solicitud.Areasolicitante = -1;
            }

            if (radioButtonFR.Checked)
            {
                solicitud.Fechsolicitud       = dateTimePickerbusIni.Value;
                solicitud.Fecpropuesta        = dateTimePickerbusFin.Value;
                rfc.Fecprogramadaejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecprogramadafinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecharealejecucion        = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecharealfinalizacion     = new DateTime(1900, 01, 01, 00, 00, 00);
            }
            else
            {
                solicitud.Fechsolicitud = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fecpropuesta  = new DateTime(1900, 01, 01, 00, 00, 00);
            }

            if (radioButtonFIP.Checked)
            {
                rfc.Fecprogramadaejecucion    = dateTimePickerbusIni.Value;
                rfc.Fecprogramadafinalizacion = dateTimePickerbusFin.Value;
                rfc.Fecharealejecucion        = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecharealfinalizacion     = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fechsolicitud       = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fecpropuesta        = new DateTime(1900, 01, 01, 00, 00, 00);
            }
            else
            {
                rfc.Fecprogramadaejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecprogramadafinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);
            }

            if (radioButtonFIR.Checked)
            {
                rfc.Fecharealejecucion        = dateTimePickerbusIni.Value;
                rfc.Fecharealfinalizacion     = dateTimePickerbusFin.Value;
                rfc.Fecprogramadaejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecprogramadafinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fechsolicitud       = new DateTime(1900, 01, 01, 00, 00, 00);
                solicitud.Fecpropuesta        = new DateTime(1900, 01, 01, 00, 00, 00);
            }
            else
            {
                rfc.Fecharealejecucion    = new DateTime(1900, 01, 01, 00, 00, 00);
                rfc.Fecharealfinalizacion = new DateTime(1900, 01, 01, 00, 00, 00);
            }
            DataGridView dg = new DataGridView();

            if (VariablesGlobales.TipoRol != "Gestor")
            {
                rfc.Coordinador = VariablesGlobales.nomUsu;
            }

            //DataTable dt = dao.selectCostum(rfc, solicitud, false, false);



            DataTable dt = dao.selectMiguel(rfc, solicitud, tipoCambio);



            if (dt == null)
            {
                MessageBox.Show("No Hay Datos");
            }
            else
            {
                // Write to the file name selected.
                // ... You can write the text from a TextBox instead of a string literal.
                Excel.Application xlApp;
                Excel.Workbook    xlWorkBook;
                Excel.Worksheet   xlWorkSheet;
                object            misValue = System.Reflection.Missing.Value;

                xlApp       = new Excel.Application();
                xlWorkBook  = xlApp.Workbooks.Add(misValue);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                int i = 0;
                int j = 0;


                string[] columnNames = dt.Columns.Cast <DataColumn>()
                                       .Select(x => x.ColumnName)
                                       .ToArray();

                for (j = 0; j <= columnNames.Length - 1; j++)
                {
                    xlWorkSheet.Cells[1, j + 1] = columnNames[j];
                }


                for (i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    for (j = 0; j <= dt.Columns.Count - 1; j++)
                    {
                        //DataGridViewCell cell = dt[j, i];
                        xlWorkSheet.Cells[i + 2, j + 1] = dt.Rows[i][j];
                    }
                }

                xlWorkBook.SaveAs(name, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

                xlWorkBook.Close(true, misValue, misValue);
                xlApp.Quit();

                releaseObject(xlWorkSheet);
                releaseObject(xlWorkBook);
                releaseObject(xlApp);
            }
        }
Exemplo n.º 9
0
        public DataTable selectMiguel(DTORfc rfc, DTOSolicitud solicitud, int tipoReporte)
        {
            try
            {
                DataTable     dt         = new DataTable();
                StringBuilder SQLString  = new StringBuilder();
                StringBuilder Campos     = new StringBuilder();
                ArrayList     Parametros = new ArrayList();


                SQLString.Append("Select r.codigo, s.fechsolicitud,s.nomsolicitante,s.titulo,s.descambio,r.fecprogramadaejecucion,r.fecprogramadafinalizacion,s.sisafectado,(select y.nomEmpresa from sociedad x, empresa y where x.idSociedad = s.sociedadafectada and x.idEmpresa = y.idEmpresa) Empresa,(select nomAmbienteCambio from ambientecambio where idAmbienteCambio = s.ambafectado) Ambiente, if(r.fecprogramadaejecucion = null, 0,SEC_TO_TIME(TIMESTAMPDIFF(SECOND,r.fecprogramadaejecucion,r.fecprogramadafinalizacion))) Duracion ,if(r.indisponibilidad = 1 , 'SI', 'NO') as indisponibilidad,r.coordinador,r.rutaplan,IF(r.tipocambio = 'Normal', r.tipocambio_normal, r.tipocambio) as tipocambio, r.estado,r.motivo, r.aprobador From Solicitud s, RFC r ");


                Campos.Append("r.codigo = s.codigo AND ");
                //Campos.Append("r.estado = 'Pendiente' AND ");
                //Campos.Append("(WEEK(DATE_ADD(CURDATE(), INTERVAL 1 WEEK)) = WEEK(r.fecprogramadaejecucion) or r.fecprogramadaejecucion is null) AND");

                if (tipoReporte == 2)
                {
                    Campos.Append("r.tipocambio_normal='Menor' AND ");
                }
                if (tipoReporte == 3)
                {
                    Campos.Append("r.tipocambio_normal in ('Medio','Mayor','Crítico') AND ");
                }
                if (tipoReporte == 4)
                {
                    Campos.Append("r.tipocambio in ('Emergencia','Excepcion') AND ");
                }
                if (rfc.Estado != null)
                {
                    Campos.Append("r.estado ='" + rfc.Estado + "' AND ");
                }

                if (rfc.Indisponibilidad > -1)
                {
                    Campos.Append("r.indisponibilidad='" + rfc.Indisponibilidad + "' AND ");
                }

                if (rfc.Cateinfra != null)
                {
                    Campos.Append("r.cateinfra='" + rfc.Cateinfra + "' AND ");
                }
                if (rfc.Coordinador != null)
                {
                    Campos.Append("r.coordinador like '%" + rfc.Coordinador + "%' AND ");
                }

                if (solicitud.Nomsolicitante != null)
                {
                    Campos.Append("s.nomsolicitante like '%" + solicitud.Nomsolicitante + "%' AND ");
                }

                if (solicitud.Areasolicitante > 0)
                {
                    Campos.Append("s.areasolicitante = '" + solicitud.Areasolicitante + "' AND ");
                }
                if (solicitud.Sociedadafectada > 0)
                {
                    Campos.Append("s.sociedadafectada = '" + solicitud.Sociedadafectada + "' AND ");
                }
                if (solicitud.Fechsolicitud != new DateTime(1900, 01, 01, 00, 00, 00) && solicitud.Fecpropuesta != new DateTime(1900, 01, 01, 00, 00, 00))
                {
                    Campos.Append("(s.fechsolicitud >= '" + solicitud.Fechsolicitud.ToString("yyyy-MM-dd hh:mm:ss") + "' AND s.fechsolicitud <= '" + solicitud.Fecpropuesta.ToString("yyyy-MM-dd hh:mm:ss") + "') AND ");
                }
                if (rfc.Fecprogramadaejecucion != new DateTime(1900, 01, 01, 00, 00, 00) && rfc.Fecprogramadafinalizacion != new DateTime(1900, 01, 01, 00, 00, 00))
                {
                    Campos.Append("(r.fecprogramadaejecucion >= '" + rfc.Fecprogramadaejecucion.ToString("yyyy-MM-dd hh:mm:ss") + "' AND r.fecprogramadaejecucion <= '" + rfc.Fecprogramadafinalizacion.ToString("yyyy-MM-dd hh:mm:ss") + "' ) AND ");
                }
                if (rfc.Fecharealejecucion != new DateTime(1900, 01, 01, 00, 00, 00) && rfc.Fecharealfinalizacion != new DateTime(1900, 01, 01, 00, 00, 00))
                {
                    Campos.Append("(r.fecrealejecucion >= '" + rfc.Fecharealejecucion.ToString("yyyy-MM-dd hh:mm:ss") + "' AND r.fecrealejecucion < '" + rfc.Fecharealfinalizacion.ToString("yyyy-MM-dd hh:mm:ss") + "' ) AND ");
                }

                if (Campos.Length > 0)
                {
                    SQLString.Append(" WHERE ");
                    SQLString.Append(Campos.ToString().Substring(0, Campos.ToString().Length - 4));
                }
                SQLString.Append(" order by r.codigo desc ");
                MySqlCommand     orden = ObtenerOrdenSql(SQLString.ToString(), Parametros);
                MySqlDataAdapter da    = new MySqlDataAdapter(orden);
                //da.Fill(ds);
                da.Fill(dt);
                return(dt);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 10
0
        public DataTable selectCostum(DTORfc rfc, DTOSolicitud solicitud, Boolean vista, Boolean estado, int tipoCambio)
        {
            try
            {
                DataTable     dt         = new DataTable();
                StringBuilder SQLString  = new StringBuilder();
                StringBuilder Campos     = new StringBuilder();
                ArrayList     Parametros = new ArrayList();

                if (vista)
                {
                    SQLString.Append("Select r.codigo, r.estado, IF(r.tipocambio = 'Normal', r.tipocambio_normal, r.tipocambio) as tipocambio, if(r.indisponibilidad = 1 , 'SI', 'NO') as indisponibilidad, s.titulo, r.fecprogramadaejecucion, r.fecprogramadafinalizacion, s.sisafectado, (select nomAmbienteCambio from ambientecambio where idAmbienteCambio = s.ambafectado) as ambiente, (select nomSociedad from sociedad where idSociedad = s.sociedadafectada) as sociedad From Solicitud s, RFC r ");
                }
                else
                {
                    SQLString.Append("Select s.codigo, s.Fechsolicitud,s.titulo, s.nomsolicitante, s.areasolicitante, s.origen, s.razon, (select nomSociedad from sociedad where idSociedad = s.sociedadafectada), s.sisafectado, s.ambafectado, r.* From Solicitud s, RFC r ");
                }


                Campos.Append("r.codigo = s.codigo AND ");

                if (rfc.Estado != null)
                {
                    if (estado)
                    {
                        Campos.Append("r.estado in ('Pendiente','Aceptado','Registrado','Aprobado') AND ");
                    }
                    else
                    {
                        Campos.Append("r.estado ='" + rfc.Estado + "' AND ");
                    }
                }
                if (rfc.Indisponibilidad > -1)
                {
                    Campos.Append("r.indisponibilidad='" + rfc.Indisponibilidad + "' AND ");
                }

                if (tipoCambio == 2)
                {
                    Campos.Append("r.tipocambio_normal='Menor' AND ");
                }
                if (tipoCambio == 3)
                {
                    Campos.Append("r.tipocambio_normal in ('Medio','Mayor','Crítico') AND ");
                }
                if (tipoCambio == 4)
                {
                    Campos.Append("r.tipocambio in ('Emergencia','Excepcion') AND ");
                }


                if (rfc.Cateinfra != null)
                {
                    Campos.Append("r.cateinfra='" + rfc.Cateinfra + "' AND ");
                }
                if (rfc.Coordinador != null)
                {
                    Campos.Append("r.coordinador like '%" + rfc.Coordinador + "%' AND ");
                }

                if (solicitud.Nomsolicitante != null)
                {
                    Campos.Append("s.nomsolicitante like '%" + solicitud.Nomsolicitante + "%' AND ");
                }

                if (solicitud.Areasolicitante > 0)
                {
                    Campos.Append("s.areasolicitante = '" + solicitud.Areasolicitante + "' AND ");
                }
                if (solicitud.Empresa != null)
                {
                    DataSet       dsx         = new DataSet();
                    StringBuilder SQLStringx  = new StringBuilder();
                    StringBuilder Camposx     = new StringBuilder();
                    ArrayList     Parametrosx = new ArrayList();
                    try
                    {
                        SQLStringx.Append("Select * From sociedad where idEmpresa = (select idEmpresa from empresa where nomEmpresa = '" + solicitud.Empresa + "');");

                        MySqlCommand     ordenx = ObtenerOrdenSql(SQLStringx.ToString(), Parametrosx);
                        MySqlDataAdapter dax    = new MySqlDataAdapter(ordenx);
                        dax.Fill(dsx);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }

                    string auxiliarSociedades = null;

                    foreach (DataRow row in dsx.Tables[0].Rows)
                    {
                        auxiliarSociedades = auxiliarSociedades + "" + row[0].ToString() + ", ";
                    }

                    auxiliarSociedades = auxiliarSociedades.Substring(0, auxiliarSociedades.Length - 2);

                    Campos.Append("s.sociedadafectada in (" + auxiliarSociedades + ") AND ");
                }
                if (solicitud.Fechsolicitud != new DateTime(1900, 01, 01, 00, 00, 00) && solicitud.Fecpropuesta != new DateTime(1900, 01, 01, 00, 00, 00))
                {
                    Campos.Append("(s.fechsolicitud >= '" + solicitud.Fechsolicitud.ToString("yyyy-MM-dd hh:mm:ss") + "' AND s.fechsolicitud <= '" + solicitud.Fecpropuesta.ToString("yyyy-MM-dd hh:mm:ss") + "') AND ");
                }
                if (rfc.Fecprogramadaejecucion != new DateTime(1900, 01, 01, 00, 00, 00) && rfc.Fecprogramadafinalizacion != new DateTime(1900, 01, 01, 00, 00, 00))
                {
                    Campos.Append("(r.fecprogramadaejecucion >= '" + rfc.Fecprogramadaejecucion.ToString("yyyy-MM-dd hh:mm:ss") + "' AND r.fecprogramadaejecucion <= '" + rfc.Fecprogramadafinalizacion.ToString("yyyy-MM-dd hh:mm:ss") + "' ) AND ");
                }
                if (rfc.Fecharealejecucion != new DateTime(1900, 01, 01, 00, 00, 00) && rfc.Fecharealfinalizacion != new DateTime(1900, 01, 01, 00, 00, 00))
                {
                    Campos.Append("(r.fecrealejecucion >= '" + rfc.Fecharealejecucion.ToString("yyyy-MM-dd hh:mm:ss") + "' AND r.fecrealejecucion < '" + rfc.Fecharealfinalizacion.ToString("yyyy-MM-dd hh:mm:ss") + "' ) AND ");
                }


                if (Campos.Length > 0)
                {
                    SQLString.Append(" WHERE ");
                    SQLString.Append(Campos.ToString().Substring(0, Campos.ToString().Length - 4));
                }
                SQLString.Append(" order by r.codigo desc ");
                MySqlCommand     orden = ObtenerOrdenSql(SQLString.ToString(), Parametros);
                MySqlDataAdapter da    = new MySqlDataAdapter(orden);
                //da.Fill(ds);
                da.Fill(dt);
                return(dt);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }