private void PopulatePermissionTree()
        {
            string queryString = "	select usr .Name from ControlsToRoles ctr"+

                                 "  join controls c on c.ControlID = ctr.FKControlID and c.Page = ctr.FKPage" +

                                 "  join roles r on r.RoleID = ctr.FKRole" +

                                 "  join UsersToRoles UsTr on UsTr.FKRoleID = ctr.FKRole" +

                                 "  join Users usr on usr.UserID = UsTr.FKUserID" +

                                 "  group by usr.Name  ";

            DataTable dt = null;

            try
            {
                dt = GuardarDatos.GetRoles(queryString);
                DataRow row = dt.NewRow();
                row[0] = "TODOS";
                dt.Rows.Add(row);
                cboCargaUsuario.DataSource    = dt;
                cboCargaUsuario.DisplayMember = "Name";
                cboCargaUsuario.SelectedIndex = cboCargaUsuario.Items.Count - 1;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error al recuperar " + e.Message,
                                "Error al recuperar",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }


            string currentName = string.Empty;
        }
Exemple #2
0
        private void btnBorrar_Click(object sender, EventArgs e)
        {
            DialogResult Opcion = MessageBox.Show("Realmente desea Eliminar la Mina/Proyecto", "Confirmacion", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (Opcion == DialogResult.Yes)
            {
                try
                {
                    SqlParameter[] ParametrosEnt = new SqlParameter[16];
                    ParametrosEnt[0]  = new SqlParameter("@Op", "D");
                    ParametrosEnt[1]  = new SqlParameter("@Codigo", this.TxbCodigo.Text.Trim());
                    ParametrosEnt[2]  = new SqlParameter("@CodigoPM", this.TxbCodigoPM.Text.Trim());
                    ParametrosEnt[3]  = new SqlParameter("@Nombre", this.TxbNombre.Text.Trim());
                    ParametrosEnt[4]  = new SqlParameter("@CodigoContenedor", this.CmbDepende.SelectedValue);
                    ParametrosEnt[5]  = new SqlParameter("@IdMinas", this.CmbMinas.SelectedValue);
                    ParametrosEnt[6]  = new SqlParameter("@IdTipoContrato", this.CmbTipoContrato.SelectedValue);
                    ParametrosEnt[7]  = new SqlParameter("@TenorPromedio", this.CmbTenorPromedio.SelectedIndex);
                    ParametrosEnt[8]  = new SqlParameter("@Area", Convert.ToDouble(this.TxbArea.Text.Trim()));
                    ParametrosEnt[9]  = new SqlParameter("@IdTipoEmpresa", this.CmbTipoEmpresa.SelectedValue);
                    ParametrosEnt[10] = new SqlParameter("@Detalle", this.TxbDetalle.Text.Trim());
                    ParametrosEnt[11] = new SqlParameter("@Plaza", this.TxbCodigoPlaza.Text.Trim());
                    ParametrosEnt[12] = new SqlParameter("@Email", this.TxbEmail.Text.Trim());
                    ParametrosEnt[13] = new SqlParameter("@MostrarEnInformes", this.ChbInformes.Checked);
                    ParametrosEnt[14] = new SqlParameter("@RecuperacionPlanta", this.ChbRecuperacion.Checked);
                    ParametrosEnt[15] = new SqlParameter("@Estado", this.ChbEstado.Checked);

                    GuardarDatos Guardar = new GuardarDatos();
                    Guardar.booleano("Sp_GuardarMinas", ParametrosEnt);

                    MessageBox.Show("Mina/Operador Minero Eliminada satisfactoriamente.", "Informacion del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception Exc)
                {
                    MessageBox.Show(Exc.Message, "Error controlado del Sistema.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult Opcion = MessageBox.Show("Realmente desea eliminar el registro", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading);

            if (Opcion == DialogResult.Yes)
            {
                try
                {
                    SqlParameter[] ParametrosEnt = new SqlParameter[1];
                    ParametrosEnt[0] = new SqlParameter("@Orden", this.TxbOrden.Text);

                    ConsultaEntidades Maestro = new ConsultaEntidades();
                    GuardarDatos      Guardar = new GuardarDatos();

                    Guardar.booleano("Sp_EliminarReporteSGS", ParametrosEnt);
                    MessageBox.Show("Reporte Eliminado satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.btnNuevo.PerformClick();
                }
                catch (Exception Exc)
                {
                    MessageBox.Show(Exc.Message, "SYSTEM ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnExcel_Click(object sender, EventArgs e)
        {
            try
            {
                SqlParameter[] Parametros_Consulta = new SqlParameter[4];
                Parametros_Consulta[0] = new SqlParameter("@Op", "AdjuntosSGS");
                Parametros_Consulta[1] = new SqlParameter("@ParametroChar", this.TxbOrden.Text.Trim());
                Parametros_Consulta[2] = new SqlParameter("@ParametroInt", "0");
                Parametros_Consulta[3] = new SqlParameter("@ParametroNuemric", "0");

                ConsultaEntidades Maestro        = new ConsultaEntidades();
                GuardarDatos      Guardar        = new GuardarDatos();
                Ent_AdjuntosSGS   ReaderConsulta = new Ent_AdjuntosSGS();

                ReaderConsulta = Maestro.AdjuntosSGS("SpConsulta_Tablas", Parametros_Consulta);

                string fichero = Convert.ToString(Path.GetTempPath()) + "Temp_" + ReaderConsulta.Archivo + ReaderConsulta.Extension;

                using (FileStream archivoStream = new FileStream(fichero, FileMode.Create))
                {
                    archivoStream.Write(ReaderConsulta.Archivo, 0, ReaderConsulta.Archivo.Length);
                    archivoStream.Close();
                    if (File.Exists(fichero))
                    {
                        Process process = new Process {
                            StartInfo = { FileName = fichero }
                        };
                        process.Start();
                    }
                }
            }
            catch (Exception aa)
            {
                MessageBox.Show("Error..." + aa.Message);;
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult Opcion = MessageBox.Show("Realmente desea eliminar el registro", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading);

            if (Opcion == DialogResult.Yes)
            {
                try
                {
                    SqlParameter[] ParametrosEnt = new SqlParameter[12];
                    ParametrosEnt[0]  = new SqlParameter("@Op", "D");
                    ParametrosEnt[1]  = new SqlParameter("@Identificacion", this.txbIdentificacion.Text.Trim());
                    ParametrosEnt[2]  = new SqlParameter("@Nombre", this.txbNombre.Text.Trim());
                    ParametrosEnt[3]  = new SqlParameter("@Apellido", this.txbNombre.Text.Trim());
                    ParametrosEnt[4]  = new SqlParameter("@TelFijo", this.txbNombre.Text.Trim());
                    ParametrosEnt[5]  = new SqlParameter("@Extension", this.txbNombre.Text.Trim());
                    ParametrosEnt[6]  = new SqlParameter("@Celular", this.txbNombre.Text.Trim());
                    ParametrosEnt[7]  = new SqlParameter("@email", this.txbNombre.Text.Trim());
                    ParametrosEnt[8]  = new SqlParameter("@Estado", this.ChbEstado.Checked);
                    ParametrosEnt[9]  = new SqlParameter("@FechaCreacion", DateTime.Now.Date);
                    ParametrosEnt[10] = new SqlParameter("@TipoIdentificacion", this.CmbTipoIdentificacion.SelectedIndex);
                    ParametrosEnt[11] = new SqlParameter("@RazonCial", this.TxbRazonCial.Text.Trim());

                    GuardarDatos GuardarDatos = new GuardarDatos();
                    bool         Eliminado    = GuardarDatos.booleano("GrbBascula_Contratistas", ParametrosEnt);

                    if (Eliminado)
                    {
                        MessageBox.Show("Contratista Elimindo satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception Exc)
                {
                    MessageBox.Show(Exc.Message, "System Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.TxbConsecutivo.Text != "0")
            {
                MessageBox.Show("No se puede guardar, reporte ya tiene un consecutivo generado.");
            }
            else
            {
                #region LLenado de DataGrid Auxiliar

                DataTable dt = new DataTable();
                dt.Columns.Add("Incluir");
                dt.Columns.Add("Id");
                dt.Columns.Add("SelloH");
                dt.Columns.Add("SelloP");
                dt.Columns.Add("Tenor");
                dt.Columns.Add("Peso");
                dt.Columns.Add("Cliente");
                dt.Columns.Add("Orden");
                dt.Columns.Add("Muestra");
                dt.Columns.Add("Referencia");
                dt.Columns.Add("Lugar");
                dt.Columns.Add("Recepcion");
                dt.Columns.Add("Reporte");
                DataRow Row = dt.NewRow();

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    bool   incluir    = Convert.ToBoolean(row.Cells[0].Value);
                    int    id         = Convert.ToInt32(row.Cells[1].Value);
                    string sellop     = Convert.ToString(row.Cells[2].Value);
                    string selloh     = Convert.ToString(row.Cells[3].Value);
                    double tenor      = Convert.ToDouble(row.Cells[4].Value);
                    int    peso       = Convert.ToInt32(row.Cells[5].Value);
                    string cliente    = this.TxbCliente.Text.Trim();
                    string orden      = this.TxbOrden.Text.Trim();
                    string muestra    = this.TxbMuestras.Text.Trim();
                    string referencia = this.TxbReferencia.Text.Trim();
                    string lugar      = this.TxbLugar.Text.Trim();
                    string recepcion  = this.TxbRecepcion.Text.Trim();
                    string reporte    = this.TxbReporte.Text.Trim();

                    Row["incluir"]    = incluir;
                    Row["Id"]         = id;
                    Row["Sellop"]     = sellop;
                    Row["Selloh"]     = selloh;
                    Row["Tenor"]      = tenor;
                    Row["Peso"]       = peso;
                    Row["Cliente"]    = cliente;
                    Row["Orden"]      = orden;
                    Row["Muestra"]    = muestra;
                    Row["Referencia"] = referencia;
                    Row["Lugar"]      = lugar;
                    Row["Recepcion"]  = recepcion;
                    Row["Reporte"]    = reporte;
                    dt.Rows.Add(Row);
                    Row = dt.NewRow();
                }
                #endregion

                #region Enviando Parametros para guardar Datos


                try
                {
                    SqlParameter[] ParametroI = new SqlParameter[1];
                    ParametroI[0] = new SqlParameter("@TablaExcelSGS", dt);

                    GuardarDatos Guardar = new GuardarDatos();

                    int Resultado = Guardar.Numerico("Sp_InsertDatosExcelSGS2", ParametroI);
                    this.TxbConsecutivo.Text = Resultado.ToString().Trim();

                    MessageBox.Show("Registros Actualziados con Exito");
                }
                catch (Exception Ext)
                {
                    MessageBox.Show(Ext.Message);
                }
                #endregion

                #region Guardando los Adjuntos

                try
                {
                    FileStream fs = new FileStream(this.TxbPath.Text, FileMode.Open);
                    //Creamos un array de bytes para almacenar los datos leídos por fs.
                    Byte[] data = new byte[fs.Length];
                    //Y guardamos los datos en el array data
                    fs.Read(data, 0, Convert.ToInt32(fs.Length));
                    fs.Close();

                    int PosInicialPath      = this.TxbPath.Text.Trim().LastIndexOf("\\") + 1;
                    int PosFinalPath        = this.TxbPath.Text.Trim().LastIndexOf(".") - 1;
                    int PosInicialExtension = this.TxbPath.Text.Trim().LastIndexOf(".");
                    int NumeroCaracteres    = PosFinalPath - PosInicialPath + 1;
                    int CaracteresExtension = this.TxbPath.Text.Trim().Length - PosInicialExtension;

                    SqlParameter[] ParametrosEnt = new SqlParameter[7];
                    ParametrosEnt[0] = new SqlParameter("@Op", "I");
                    ParametrosEnt[1] = new SqlParameter("@Orden", this.TxbOrden.Text.Trim());
                    ParametrosEnt[2] = new SqlParameter("@Ruta", this.TxbPath.Text.Trim());
                    ParametrosEnt[3] = new SqlParameter("@Nombre", this.TxbPath.Text.Substring(PosInicialPath, NumeroCaracteres));
                    ParametrosEnt[4] = new SqlParameter("@Archivo", data);
                    ParametrosEnt[5] = new SqlParameter("@Extension", this.TxbPath.Text.Substring(PosInicialExtension, CaracteresExtension));
                    ParametrosEnt[6] = new SqlParameter("@Maquina", Environment.MachineName);

                    ConsultaEntidades Maestro = new ConsultaEntidades();
                    GuardarDatos      Guardar = new GuardarDatos();

                    bool Realizado = Guardar.booleano("Sp_Guardar_AdjuntosSGS", ParametrosEnt);
                    MessageBox.Show("Adjunto almacenado con Exito");
                }
                catch (Exception Ext)
                {
                    MessageBox.Show(Ext.Message);
                }


                #endregion
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.IpLocal))
            {
                this.IpLocal = DireccionIP.Local();
            }

            if (string.IsNullOrEmpty(this.IpPublica))
            {
                this.IpPublica = DireccionIP.Publica();
            }

            if (string.IsNullOrEmpty(this.SerialHDD))
            {
                this.SerialHDD = DireccionIP.SerialNumberDisk();
            }

            if (string.IsNullOrEmpty(this.Usuario))
            {
                this.Usuario = DireccionIP.SerialNumberDisk();
            }

            string validar = ValidarRequeridos();

            if (string.IsNullOrEmpty(validar))
            {
                if (dtpEventInitial.Value.Date > dtpDatenEnd.Value.Date)
                {
                    dtpDatenEnd.Value = DateTime.Now;
                    MessageBox.Show("La fecha final debe ser mayor a la inicial!");
                    return;
                }
                string mensaje = string.Empty;

                if (dataHistoryPeriodo.Rows.Count > 0)
                {
                    if (!selccionValor)
                    {
                        DateTime valorAnterior = Convert.ToDateTime(dataHistoryPeriodo.Rows[0].Cells[3].Value);
                        int      resultado     = DateTime.Compare(valorAnterior, Convert.ToDateTime(dtpEventInitial.Text));
                        if (resultado < 0)
                        {
                            resultado = DateTime.Compare(valorAnterior.AddDays(1), Convert.ToDateTime(dtpEventInitial.Text));

                            if (resultado != 0)
                            {
                                mensaje = "El nuevo periodo debe de ser un día posterior al final del anterior periodo";
                            }
                        }
                        else if (resultado == 0)
                        {
                            mensaje = "La fecha inicial del nuevo periodo conincide con la fecha final del anterior periodo";
                        }
                        else
                        {
                            mensaje = "El nuevo periodo esta en el rango de fechas del anterior periodo";
                        }

                        if (dataHistoryPeriodo.Rows[0].Cells[1].Value.ToString().Trim().Contains(string.Concat(cboAno.Text.Trim(), "-", cboMes.Text.Trim(), "-", cboPeriodo.Text.Trim())))
                        {
                            MessageBox.Show("El periodo a crear ya existe en historial, verificar coposición del periodo");
                            return;
                        }
                    }
                }
                if (!String.IsNullOrEmpty(mensaje))
                {
                    MessageBox.Show(mensaje);
                    return;
                }
                GuardarDatos   Guardar  = new GuardarDatos();
                SqlParameter[] ParamSQl = GuardarDatos.Parametros_Insertar_PeriodoPM("", Convert.ToDateTime(dtpEventInitial.Text), Convert.ToDateTime(dtpDatenEnd.Text), Convert.ToInt32(cboAno.Text), Convert.ToInt32(cboMes.Text), cboPeriodo.Text, string.IsNullOrEmpty(txtOnzasFundidas.Text.Trim().TrimEnd(',')) ? Convert.ToDecimal(0.00) : Convert.ToDecimal(txtOnzasFundidas.Text.Trim())
                                                                                     , string.IsNullOrEmpty(txtRecuperacion.Text.Trim().TrimEnd(',')) ? Convert.ToDecimal(0.00) : Convert.ToDecimal(txtRecuperacion.Text.Trim())
                                                                                     , string.IsNullOrEmpty(txtOnzasRecuperadas.Text.Trim().TrimEnd(',')) ? Convert.ToDecimal(0.00) : Convert.ToDecimal(txtOnzasRecuperadas.Text.Trim()), 1);


                if (ParamSQl[0].Value.ToString() == "I")
                {
                    Guardar.booleano("Sp_Guardar_PeriodoLiquidacion", ParamSQl);
                    MessageBox.Show("Periodo almacenado con Exito");
                    LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se creo Registro de Periodo " + string.Concat(cboAno.Text.Trim(), "-", cboMes.Text.Trim(), "-", cboPeriodo.Text.Trim()), "Movimiento Periodo creado");
                }
                else
                {
                    Guardar.booleano("Sp_Modicar_PeriodoLiquidacion", ParamSQl);
                    MessageBox.Show("Periodo actualizado con Exito");
                    LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se modifico Periodo" + string.Concat(cboAno.Text.Trim(), "-", cboMes.Text.Trim(), "-", cboPeriodo.Text.Trim()), "Movimiento Periodo  Modificar");
                }

                LimpiarCampos();
                loadPeriodo(Convert.ToInt32(cboAno.Text));
            }
            else
            {
                MessageBox.Show(validar);
            }
        }
Exemple #8
0
        private void PopulatePermissionTree()
        {
            string queryString = "select ctr .fkpage, controlID, Invisible, Disabled, RoleName,ContenedorPeqMineria,ContenedorZandor,ContenedorOtros " +
                                 "from ControlsToRoles ctr " +
                                 " join controls c on c.ControlID = ctr.FKControlID and c.Page = ctr.FKPage " +
                                 " join roles r on r.RoleID = ctr.FKRole ";

            if (ByControlRB.Checked)
            {
                queryString += " order by ControlID";
            }
            else
            {
                queryString += " order by RoleName";
            }
            DataTable dt = null;

            try

            {
                dt = GuardarDatos.GetRoles(queryString);
            }
            catch (Exception e)
            {
                MessageBox.Show("Incapaz de recuperar permisos: " + e.Message,
                                "Error al recuperar permisos",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            PermissionTree.BeginUpdate();
            PermissionTree.Nodes.Clear();
            TreeNode parentNode = null;
            TreeNode subNode    = null;

            string currentName = string.Empty;

            foreach (DataRow row in dt.Rows)
            {
                string subNodeText = String.Concat(" Formulario: ", row["fkpage"].ToString(), "-", (ByControlRB.Checked ? row["RoleName"].ToString() : row["ControlID"].ToString()));
                subNodeText += ":";
                subNodeText += Convert.ToInt32(row["Invisible"]) == 0 ? " visible " : " no visible ";
                subNodeText += ", ";
                subNodeText += Convert.ToInt32(row["Disabled"]) == 0 ? " Activo " : " Inactivo ";


                if (workingForm != null && workingForm.Name.Trim().ToUpper().Contains("FRM_MUESTREOPM"))
                {
                    if (!String.IsNullOrEmpty(row["ContenedorPeqMineria"].ToString().Trim()))
                    {
                        subNodeText += ", ";

                        subNodeText += Convert.ToInt32(row["ContenedorPeqMineria"]) == 0 ? " No Grabar Peq Min " : " Grabar Peq Min";
                        subNodeText += ", ";
                        subNodeText += Convert.ToInt32(row["ContenedorZandor"]) == 0 ? " No Grabar Cont Zandor" : " Grabar Cont Zandor";
                        subNodeText += ", ";
                        subNodeText += Convert.ToInt32(row["ContenedorOtros"]) == 0 ? " No Grabar Cont Otros" : " Grabar Cont Otros";
                    }
                }

                subNode = new TreeNode(subNodeText);
                string dataName = ByControlRB.Checked ? row["ControlID"].ToString() : row["RoleName"].ToString();
                if (currentName != dataName)
                {
                    parentNode  = new TreeNode(dataName);
                    currentName = dataName;
                    PermissionTree.Nodes.Add(parentNode);
                }

                if (parentNode != null)
                {
                    parentNode.Nodes.Add(subNode);
                }
            }
            PermissionTree.EndUpdate();
        }
Exemple #9
0
        private void button51_Click(object sender, EventArgs e)
        {
            #region Eliminando los datos Adjuntos
            DialogResult Opcion = MessageBox.Show("Desea Eliminar el Contrato Seleccionado oprima el botón SI", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading);
            if (Opcion == DialogResult.Yes)
            {
                try
                {
                    int            IdFile        = Convert.ToInt32(this.DgvContratos.CurrentRow.Cells[0].Value);
                    SqlParameter[] ParametrosEnt = new SqlParameter[16];
                    ParametrosEnt[0]  = new SqlParameter("@Op", "D");
                    ParametrosEnt[1]  = new SqlParameter("@IdMina", IdFile);
                    ParametrosEnt[2]  = new SqlParameter("@CodigoEsquema", this.CmbEsquema.SelectedIndex);
                    ParametrosEnt[3]  = new SqlParameter("@IdContratista", this.CmbContratista.SelectedValue);
                    ParametrosEnt[4]  = new SqlParameter("@Detalle", this.TxbDetalleEsquema.Text.Trim());
                    ParametrosEnt[5]  = new SqlParameter("@Fecha", this.DtpContrato.Text.Trim().Replace("/", ""));
                    ParametrosEnt[6]  = new SqlParameter("@Inscripcion", this.DtpInscriContrato.Text.Trim().Replace("/", ""));
                    ParametrosEnt[7]  = new SqlParameter("@Vencimiento", this.DtpVenciContrato.Text.Trim().Replace("/", ""));
                    ParametrosEnt[8]  = new SqlParameter("@Recuperacion", this.TxbRecuperacion.Text.ToString().Trim());
                    ParametrosEnt[9]  = new SqlParameter("@Fondo", this.TxbFondo.Text.ToString().Trim());
                    ParametrosEnt[10] = new SqlParameter("@Duracion", this.NmrDuracion.Value);
                    ParametrosEnt[11] = new SqlParameter("@Tenores", this.ChbTenores.Checked);
                    ParametrosEnt[12] = new SqlParameter("@AnexoSeguridad", this.ChbAnexos.Checked);
                    ParametrosEnt[13] = new SqlParameter("@Explosivos", this.ChbClausulas.Checked);
                    ParametrosEnt[14] = new SqlParameter("@DevolucionFondo", this.ChbFondo.Checked);
                    ParametrosEnt[15] = new SqlParameter("@Impuestos", Convert.ToDouble(this.TxbPorcImpuestos.Text.ToString().Trim()));

                    GuardarDatos Guardar   = new GuardarDatos();
                    bool         Realizado = Guardar.booleano("Sp_GuardarMinasContratos", ParametrosEnt);
                    if (Realizado)
                    {
                        MessageBox.Show("Contrato Eliminado satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    #region Actualizando el DatGridView Contratos
                    try
                    {
                        SqlParameter[] ParametrosGrid = new SqlParameter[4];
                        ParametrosGrid[0] = new SqlParameter("@Op", "ContratosMinasEspe");
                        ParametrosGrid[1] = new SqlParameter("@ParametroChar", this.TxbCodigo.Text.Trim());
                        ParametrosGrid[2] = new SqlParameter("@ParametroInt", "0");
                        ParametrosGrid[3] = new SqlParameter("@ParametroNuemric", "0");
                        DataSet DS;

                        DS = LlenarGrid.Datos("SpConsulta_Tablas", ParametrosGrid);
                        this.DgvContratos.DataSource = DS;
                        this.DgvContratos.DataMember = "Result";
                        this.DgvContratos.AutoResizeColumns();
                    }
                    catch (Exception Exc)
                    {
                        MessageBox.Show("OCURRIÓ UN ERROR AL CONSULTAR O CARGAR LOS DATOS..: \n\n" + Exc.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    #endregion
                }
                catch (Exception Exc1)
                {
                    MessageBox.Show(Exc1.Message);;
                }
            }

            #endregion
            #region Llenado el DataGrid de los adjuntos
            try
            {
                SqlParameter[] ParametrosGrid = new SqlParameter[4];
                ParametrosGrid[0] = new SqlParameter("@Op", "AdjuntosMinasEspe");
                ParametrosGrid[1] = new SqlParameter("@ParametroChar", this.TxbCodigo.Text.ToString().Trim());
                ParametrosGrid[2] = new SqlParameter("@ParametroInt", "0");
                ParametrosGrid[3] = new SqlParameter("@ParametroNuemric", "0");
                DataSet DS;

                DS = LlenarGrid.Datos("SpConsulta_Tablas", ParametrosGrid);
                this.DtgAdjunto.DataSource = DS;
                this.DtgAdjunto.DataMember = "Result";
                this.DtgAdjunto.AutoResizeColumns();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("OCURRIÓ UN ERROR AL CONSULTAR O CARGAR LOS DATOS..: \n\n" + Exc.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            #endregion
        }
Exemple #10
0
        private void Btn_GuardarAd_Click(object sender, EventArgs e)
        {
            Ent_TblMinas TblMinas = new Ent_TblMinas();

            TblMinas = ConsultaTablas.TblMinas("TblMinasEspe", this.TxbCodigo.Text.Trim(), 0, 0.00);


            #region Insertando Datos Adjuntos
            if (this.TxbAdjuntosPath.Text.Length > 0)
            {
                try
                {
                    FileStream fs = new FileStream(this.TxbAdjuntosPath.Text, FileMode.Open);
                    //Creamos un array de bytes para almacenar los datos leídos por fs.
                    Byte[] data = new byte[fs.Length];
                    //Y guardamos los datos en el array data
                    fs.Read(data, 0, Convert.ToInt32(fs.Length));
                    fs.Close();

                    int PosInicialPath      = this.TxbAdjuntosPath.Text.Trim().LastIndexOf("\\") + 1;
                    int PosFinalPath        = this.TxbAdjuntosPath.Text.Trim().LastIndexOf(".") - 1;
                    int PosInicialExtension = this.TxbAdjuntosPath.Text.Trim().LastIndexOf(".");
                    int NumeroCaracteres    = PosFinalPath - PosInicialPath + 1;
                    int CaracteresExtension = this.TxbAdjuntosPath.Text.Trim().Length - PosInicialExtension;

                    SqlParameter[] ParametrosEnt = new SqlParameter[11];
                    ParametrosEnt[0]  = new SqlParameter("@Op", "I");
                    ParametrosEnt[1]  = new SqlParameter("@Id", "0");
                    ParametrosEnt[2]  = new SqlParameter("@IdMina", TblMinas.Id);
                    ParametrosEnt[3]  = new SqlParameter("@Tipo", "1");
                    ParametrosEnt[4]  = new SqlParameter("@Nombre", this.TxbAdjuntosPath.Text.Substring(PosInicialPath, NumeroCaracteres));
                    ParametrosEnt[5]  = new SqlParameter("@Archivo", data);
                    ParametrosEnt[6]  = new SqlParameter("@Extension", this.TxbAdjuntosPath.Text.Substring(PosInicialExtension, CaracteresExtension));
                    ParametrosEnt[7]  = new SqlParameter("@Detalle", this.TxbAdjuntosDetalle.Text.Trim());
                    ParametrosEnt[8]  = new SqlParameter("@Realizado", DateTime.Now);
                    ParametrosEnt[9]  = new SqlParameter("@Maquina", Environment.MachineName);
                    ParametrosEnt[10] = new SqlParameter("@Usuario", this.IdUsuario);

                    GuardarDatos Guardar   = new GuardarDatos();
                    bool         Realizado = Guardar.booleano("Sp_Guardar_DatosAdjuntosMinas", ParametrosEnt);
                    if (Realizado)
                    {
                        MessageBox.Show("Archivo Adjuntado satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception Exc)
                {
                    MessageBox.Show("OCURRIÓ UN ERROR AL ADJUNTAR LOS DATOS..: \n\n" + Exc.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            #endregion

            #region Llenado el DataGrid de los adjuntos
            try
            {
                DataSet DS;
                DS = ConsultaTablas.Dataset("AdjuntosMinas", "", TblMinas.Id, 0.00);
                this.DtgAdjunto.DataSource = DS;
                this.DtgAdjunto.DataMember = "Result";
                this.DtgAdjunto.AutoResizeColumns();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("OCURRIÓ UN ERROR AL CONSULTAR O CARGAR LOS DATOS..: \n\n" + Exc.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            #endregion
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            this.StsLabel1.Text        = "Guardando...";
            this.StsProgressBar1.Value = 50;
            #region LLenado de DataTable que se enviara en el SP

            DataTable dt = new DataTable();
            dt.Columns.Add("Incluir");
            dt.Columns.Add("Id");
            dt.Columns.Add("Sello");
            dt.Columns.Add("Tenor");
            dt.Columns.Add("Humedad");

            DataRow Row = dt.NewRow();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                bool   incluir = Convert.ToBoolean(row.Cells[0].Value);
                int    id      = Convert.ToInt32(row.Cells[1].Value);
                string sello   = Convert.ToString(row.Cells[2].Value);
                double tenor   = Convert.ToDouble(row.Cells[3].Value);
                double humedad = Convert.ToDouble(row.Cells[4].Value);


                Row["incluir"] = incluir;
                Row["Id"]      = id;
                Row["Sello"]   = sello;
                Row["Tenor"]   = tenor;
                Row["Humedad"] = humedad;
                dt.Rows.Add(Row);
                Row = dt.NewRow();
            }
            #endregion

            #region Enviando Parametros para guardar Datos

            try
            {
                SqlParameter[] ParametroI = new SqlParameter[1];
                ParametroI[0] = new SqlParameter("@TablaExcelPM", dt);

                GuardarDatos Guardar = new GuardarDatos();

                int Resultado = Guardar.Numerico("Sp_InsertDatosPM", ParametroI);
                this.TxbConsecutivo.Text = Resultado.ToString().Trim();

                MessageBox.Show("Registro Actualziado con Exito");
            }
            catch (Exception Ext)
            {
                MessageBox.Show(Ext.Message);
            }


            #endregion


            #region Guardando los Adjuntos

            try
            {
                FileStream fs = new FileStream(this.TxbPath.Text, FileMode.Open);
                //Creamos un array de bytes para almacenar los datos leídos por fs.
                Byte[] data = new byte[fs.Length];
                //Y guardamos los datos en el array data
                fs.Read(data, 0, Convert.ToInt32(fs.Length));
                fs.Close();

                int PosInicialPath      = this.TxbPath.Text.Trim().LastIndexOf("\\") + 1;
                int PosFinalPath        = this.TxbPath.Text.Trim().LastIndexOf(".") - 1;
                int PosInicialExtension = this.TxbPath.Text.Trim().LastIndexOf(".");
                int NumeroCaracteres    = PosFinalPath - PosInicialPath + 1;
                int CaracteresExtension = this.TxbPath.Text.Trim().Length - PosInicialExtension;

                SqlParameter[] ParametrosEnt = new SqlParameter[7];
                ParametrosEnt[0] = new SqlParameter("@Op", "I");
                ParametrosEnt[1] = new SqlParameter("@Orden", this.TxbConsecutivo.Text.Trim());
                ParametrosEnt[2] = new SqlParameter("@Ruta", this.TxbPath.Text.Trim());
                ParametrosEnt[3] = new SqlParameter("@Nombre", this.TxbPath.Text.Substring(PosInicialPath, NumeroCaracteres));
                ParametrosEnt[4] = new SqlParameter("@Archivo", data);
                ParametrosEnt[5] = new SqlParameter("@Extension", this.TxbPath.Text.Substring(PosInicialExtension, CaracteresExtension));
                ParametrosEnt[6] = new SqlParameter("@Maquina", Environment.MachineName);

                ConsultaEntidades Maestro = new ConsultaEntidades();
                GuardarDatos      Guardar = new GuardarDatos();

                bool Realizado = Guardar.booleano("Sp_Guardar_AdjuntosSGS", ParametrosEnt);
                MessageBox.Show("Adjunto almacenado con Exito");
            }
            catch (Exception Ext)
            {
                MessageBox.Show(Ext.Message);
            }


            #endregion

            this.StsLabel1.Text        = "Guardando...";
            this.StsProgressBar1.Value = 100;

            this.StsLabel1.Text        = "Listo";
            this.StsProgressBar1.Value = 0;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            int rol   = 0;
            int Error = 0;

            if (!ChbCuartea.Checked && !ChbEncargado.Checked && !ChbSeguridad.Checked && !ChbTercero.Checked)
            {
                Error = 1;
            }
            else
            if (ChbEncargado.Checked)
            {
                rol = 1;
            }
            else
            {
                if (ChbSeguridad.Checked)
                {
                    rol = 2;
                }
                else
                {
                    if (ChbTercero.Checked)
                    {
                        rol = 3;
                    }
                    else
                    {
                        rol = 4;
                    }
                }
            }


            if (TxbIdentificacion.Text.Trim().Length == 0)
            {
                Error = 2;
            }
            if (Error == 0)
            {
                try
                {
                    if (string.IsNullOrEmpty(this.IpLocal))
                    {
                        this.IpLocal = DireccionIP.Local();
                    }

                    if (string.IsNullOrEmpty(this.IpPublica))
                    {
                        this.IpPublica = DireccionIP.Publica();
                    }

                    if (string.IsNullOrEmpty(this.SerialHDD))
                    {
                        this.SerialHDD = DireccionIP.SerialNumberDisk();
                    }

                    GuardarDatos   Guardar  = new GuardarDatos();
                    SqlParameter[] ParamSQl = GuardarDatos.Parametros_PersonalMuestreo("", TxbIdentificacion.Text.Trim(), TxbNombre.Text.Trim(), TxbApellido.Text.Trim(), TxbDireccion.Text.Trim(), TxbTelFijo.Text.Trim(), TxbCelular.Text.Trim(), TxbEmail.Text.Trim(), rol, Convertir.ImagenEnByte(PtbPersonal.Image), ChbEstado.Checked, DtpCreado.Value);
                    if (Guardar.booleano("Sp_Guardar_PersonalMuestreo", ParamSQl))
                    {
                        Limpiar(1);

                        if (ParamSQl[0].Value.ToString() == "I")
                        {
                            MessageBox.Show("Personal de Muestreo almacenado con Exito");
                            LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se creo Personal de Muestreo " + TxbIdentificacion.Text.Trim() + " " + TxbNombre.Text.Trim() + " " + TxbApellido.Text.Trim(), "Maestros - Crear");
                        }
                        else
                        {
                            MessageBox.Show("Personal de Muestreo actualizado con Exito");
                            LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se modifico Personal de Muestreo " + TxbIdentificacion.Text.Trim() + " " + TxbNombre.Text.Trim() + " " + TxbApellido.Text.Trim(), "Maestros - Modificar");
                        }
                    }
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message);
                }
            }
            if (Error == 1)
            {
                MessageBox.Show("Debe Seleccionar un tipo de Rol del Personal. ( Encargado / Seguridad / Tercero / Cuarte)");
            }
            if (Error == 2)
            {
                MessageBox.Show("Debe reportar una identificacion");
            }
        }
        internal void Cargar(DataGridView dgView, string SLibro)
        {
            try
            {
                System.Data.OleDb.OleDbConnection MyConnection;
                System.Data.DataSet DtSet;
                System.Data.OleDb.OleDbDataAdapter MyCommand;
                MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + SLibro + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1'");
                MyConnection.Open();

                System.Data.DataTable dt = MyConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

                string sheetName = string.Empty;
                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (!dt.Rows[i]["TABLE_NAME"].ToString().ToUpper().Trim().Contains("PRINT_TITLES"))
                        {
                            sheetName = dt.Rows[i]["TABLE_NAME"].ToString().Trim();
                            break;
                        }
                    }
                }
                MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [" + sheetName + "]", MyConnection);
                MyCommand.TableMappings.Add("Table", "TestTable");
                DtSet = new System.Data.DataSet();
                MyCommand.Fill(DtSet);
                dgView.DataSource = DtSet.Tables[0];
                dgView.AutoResizeColumns();
                MyConnection.Close();

                GuardarDatos Guardar = new GuardarDatos();


                if (DtSet.Tables[0].Rows[3][1].ToString().Trim().ToUpper().Contains("PEQUEÑA MINERÍA"))
                {

                    try
                    {

                        LblTitulos.Text = "Análisis Químico Pequeña Minería";

                        typeFile = 0;
                        string sellocontrolCopia = string.Empty;
                        bool contiene = true;
                        string idLab = DtSet.Tables[0].Rows[1][1].ToString().Trim();
                        for (int i = 10; i < DtSet.Tables[0].Rows.Count; i++)
                        {
                            string selloControl = DtSet.Tables[0].Rows[i][0].ToString().Trim();

                            if (String.IsNullOrEmpty(sellocontrolCopia))
                            {
                                contiene = true;
                                sellocontrolCopia = selloControl;
                            }
                            else
                            {
                                if (!selloControl.Contains(sellocontrolCopia))
                                {
                                    contiene = false;
                                    sellocontrolCopia = selloControl;
                                }
                            }

                            System.Globalization.NumberStyles style;
                            System.Globalization.CultureInfo culture;

                            style = System.Globalization.NumberStyles.Number | System.Globalization.NumberStyles.AllowCurrencySymbol;
                            culture = System.Globalization.CultureInfo.CreateSpecificCulture("ES-CO");

                            try
                            {

                                //MessageBox.Show(selloControl, "selloControl");
                                if (!String.IsNullOrEmpty(selloControl) && !selloControl.ToUpper().Trim().Contains("BLANK_PREP") && !selloControl.ToUpper().Trim().Contains("STD") && !selloControl.ToUpper().Trim().Contains("STD") && !selloControl.ToUpper().Trim().Contains("BLANK"))
                                {
                                    //MessageBox.Show("Ingress");
                                    decimal humedad = 0, au = 0, ag = 0, peso = 0;
                                    if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][2].ToString().Trim()))
                                    {
                                        //Forma de capturar decimales y enterior con la cultura de la maquina
                                        //var clone = (System.Globalization.CultureInfo)System.Globalization.CultureInfo.InvariantCulture.Clone();
                                        //clone.NumberFormat.NumberDecimalSeparator = ",";
                                        //clone.NumberFormat.NumberGroupSeparator = ".";
                                        //string s = DtSet.Tables[0].Rows[i][2].ToString().Trim();
                                        //decimal d = decimal.Parse(s, clone);

                                        //MessageBox.Show(DtSet.Tables[0].Rows[i][2].ToString().Trim(), "Mensaje2.1.1");
                                        if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][2].ToString().Trim().Replace(".", ","), style, culture, out humedad))
                                        {
                                            //MessageBox.Show(humedad.ToString(), "MensajeCC2.");

                                            humedad = decimal.Parse(DtSet.Tables[0].Rows[i][2].ToString().Trim());//.Replace(".", ",").Substring(1, DtSet.Tables[0].Rows[i][2].ToString().Length-1));
                                                                                                                  //MessageBox.Show(humedad.ToString(), "MensajeCC2.1.1.2");

                                        }
                                        //MessageBox.Show(humedad.ToString(), "Mensaje2.1.3");
                                    }

                                    if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][3].ToString().Trim()))
                                    {
                                        //MessageBox.Show(DtSet.Tables[0].Rows[i][3].ToString().Trim(), "Mensaje2.1.4.0");

                                        if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][3].ToString().Trim().Replace(".", ","), style, culture, out au))
                                        {
                                            au = decimal.Parse(DtSet.Tables[0].Rows[i][3].ToString().Trim());//.Replace(".", ",").Substring(1, DtSet.Tables[0].Rows[i][3].ToString().Length - 1), style, culture);

                                            //MessageBox.Show(au.ToString(), "Mensaje2.1.4.1");

                                        }
                                    }
                                    //MessageBox.Show(au.ToString(), "Mensaje2.1.4.2");


                                    if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][4].ToString().Trim()))
                                        if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][4].ToString().Trim().Replace(".", ","), style, culture, out ag))

                                            ag = decimal.Parse(DtSet.Tables[0].Rows[i][4].ToString().Trim());//.Replace(".", ",").Substring(1, DtSet.Tables[0].Rows[i][4].ToString().Length - 1));

                                    //MessageBox.Show(ag.ToString(), "Mensaje2.1.5");

                                    if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][5].ToString().Trim()))

                                    {
                                        if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][5].ToString().Trim().Replace(".", ","), style, culture, out peso))
                                        {
                                            peso = decimal.Parse(DtSet.Tables[0].Rows[i][5].ToString().Trim());//.Replace(".", ",").Substring(1, DtSet.Tables[0].Rows[i][5].ToString().Length - 1));
                                        }
                                        //MessageBox.Show(peso.ToString(), "Mensaje2.1.6");

                                    }

                                    //MessageBox.Show("Mensaje2.5");

                                    SqlParameter[] ParamSQl = GuardarDatos.Parametros_DetalleExcelPM("", selloControl, humedad, au, ag, peso, "1", idLab);

                                    Guardar.Numerico("Sp_Moficiar_AnaQuiPM", ParamSQl);

                                    //MessageBox.Show("Mensaje2.6");

                                    if (humedad > 0)
                                    {
                                        ParamSQl = GuardarDatos.Parametros_ToneladaSeca(selloControl, humedad);
                                        Guardar.Numerico("Sp_Moficiar_ToneladasSeca_MuestreoPM", ParamSQl);
                                    }
                                    //MessageBox.Show("Mensaje2.7");

                                }
                            }
                            catch (Exception ms)
                            {
                                MessageBox.Show(string.Concat("Sello:", selloControl, " EX:", ms.Message), "selloControl");
                                throw;
                            }
                            //else
                            //    break;
                        }
                        MessageBox.Show("Importacion Finalizada");

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    if (DtSet.Tables[0].Rows[15][3].ToString().Trim().ToUpper().Contains("HUM"))
                    {
                        MessageBox.Show("Mensaje3");

                        LblTitulos.Text = "Humedad Laboratorio Zandor";
                        typeFile = 2;
                        for (int i = 45; i < DtSet.Tables[0].Rows.Count; i++)
                        {
                            string selloControl = DtSet.Tables[0].Rows[i][0].ToString().Replace(" ", "");

                            if (!String.IsNullOrEmpty(selloControl))
                            {
                                decimal humedad = 0;
                                if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][3].ToString().Trim()))
                                    if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][3].ToString().Trim().Replace(".", ","), out humedad))

                                        humedad = decimal.Parse(DtSet.Tables[0].Rows[i][3].ToString().Trim().Replace(".", ",").Substring(1, DtSet.Tables[0].Rows[i][3].ToString().Length - 1));

                                SqlParameter[] ParamSQl = GuardarDatos.Parametros_DetalleExcelHumedad("", selloControl, humedad, "1");

                                Guardar.Numerico("Sp_Moficiar_AnaQuiHum", ParamSQl);
                            }
                            else
                                break;
                        }
                        MessageBox.Show("Importacion Finalizada");
                    }
                    else
                    {
                        if (DtSet.Tables[0].Rows[0][0].ToString().Trim().ToUpper().Contains("LABORATORIO") && DtSet.Tables[0].Rows[2][0].ToString().Trim().ToUpper().Contains("REPORTE DE ANÁLISIS QUÍMICO"))
                        {
                            MessageBox.Show("Mensaje4");

                            LblTitulos.Text = "Analisis Laboratorio Químico Zandor Capital";
                            typeFile = 1;
                            for (int i = 46; i < DtSet.Tables[0].Rows.Count; i++)
                            {
                                string selloControl = DtSet.Tables[0].Rows[i][0].ToString().Replace(" ", "");

                                if (!String.IsNullOrEmpty(selloControl))
                                {
                                    decimal au = 0, augr = 0;
                                    if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][1].ToString().Trim()))
                                        if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][1].ToString().Trim().Replace(".", ","), out au))

                                            au = decimal.Parse(DtSet.Tables[0].Rows[i][1].ToString().Trim().Replace(".", ",").Substring(1, DtSet.Tables[0].Rows[i][1].ToString().Length - 1));


                                    if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][2].ToString().Trim()))
                                        if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][2].ToString().Trim().Replace(".", ","), out augr))

                                            augr = decimal.Parse(DtSet.Tables[0].Rows[i][2].ToString().Replace(".", ",").Trim().Substring(1, DtSet.Tables[0].Rows[i][2].ToString().Length - 1));


                                    SqlParameter[] ParamSQl = GuardarDatos.Parametros_DetalleExcelZandor("", selloControl, au, augr, "1");

                                    Guardar.Numerico("Sp_Moficiar_AnaQuiZandor", ParamSQl);
                                }
                                else
                                    break;
                            }

                            MessageBox.Show("Importacion Finalizada");
                        }
                        else
                        {
                            if (DtSet.Tables[0].Rows[2][0].ToString().Trim().ToUpper().Contains("REPORTE DE ANÁLISIS QUÍMICO") || DtSet.Tables[0].Rows[1][0].ToString().Trim().ToUpper().Contains("REPORTE DE ANÁLISIS QUÍMICO"))
                            {
                                MessageBox.Show("Mensaje5");

                                LblTitulos.Text = "Reporte de Análisis Químico";
                                typeFile = 1;
                                for (int i = 48; i < DtSet.Tables[0].Rows.Count; i++)
                                {
                                    string selloControl = DtSet.Tables[0].Rows[i][0].ToString().Replace(" ", "");

                                    if (!selloControl.ToUpper().Contains("DUPLIC"))
                                    {
                                        if (selloControl.Contains("+") || selloControl.Contains("-"))
                                        {
                                            int valueSeparator = selloControl.IndexOf("(");

                                            selloControl = selloControl.Substring(0, valueSeparator);

                                            if (DtSet.Tables[0].Rows[i][0].ToString().Contains("-"))
                                                selloControl = string.Concat(selloControl, "A");

                                            if (!String.IsNullOrEmpty(selloControl))
                                            {
                                                decimal au = 0, augr = 0;
                                                if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][1].ToString().Trim()))
                                                    if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][1].ToString().Trim().Replace(",", "."), out au))

                                                        au = decimal.Parse(DtSet.Tables[0].Rows[i][1].ToString().Trim().Replace(".", ",").Substring(0, DtSet.Tables[0].Rows[i][1].ToString().Length));


                                                SqlParameter[] ParamSQl = GuardarDatos.Parametros_DetalleExcelReanalisis(selloControl, au);

                                                Guardar.Numerico("Sp_Moficiar_AnaPMR", ParamSQl);
                                            }
                                            else
                                                break;
                                        }
                                        else
                                        {
                                            if (!String.IsNullOrEmpty(selloControl))
                                            {
                                                decimal au = 0, augr = 0;
                                                if (!String.IsNullOrEmpty(DtSet.Tables[0].Rows[i][1].ToString().Trim()))
                                                    if (!Decimal.TryParse(DtSet.Tables[0].Rows[i][1].ToString().Trim().Replace(".", ","), out au))

                                                        au = decimal.Parse(DtSet.Tables[0].Rows[i][1].ToString().Trim().Replace(".", ",").Substring(1, DtSet.Tables[0].Rows[i][1].ToString().Length - 1));


                                                SqlParameter[] ParamSQl = GuardarDatos.Parametros_DetalleExcelReanalisis(selloControl, au);

                                                Guardar.Numerico("Sp_Moficiar_AnaPMR", ParamSQl);
                                            }
                                            else
                                                break;
                                        }
                                    }
                                }

                            }
                        }
                    }
                }
            }

            catch (Exception oMsg)
            {
                MessageBox.Show(oMsg.Message, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #14
0
        internal void Cargar()
        {
            try
            {
                GuardarDatos guardarDatos = new GuardarDatos();

                // Analisis Lab SGS
                if (dataSet.Tables[0].Rows[2][1].ToString().Trim().ToUpper().Contains("PEQUEÑA MINERÍA"))
                {
                    try
                    {
                        LblTitulos.Text = "Análisis Químico Pequeña Minería";
                        typeFile        = 0;
                        string value = string.Empty;
                        string idLab = dataSet.Tables[0].Rows[0][1].ToString().Trim();
                        for (int j = 9; j < dataSet.Tables[0].Rows.Count; j++)
                        {
                            string text = dataSet.Tables[0].Rows[j][0].ToString().Trim();
                            if (string.IsNullOrEmpty(value))
                            {
                                value = text;
                            }
                            else
                            {
                                if (!text.Contains(value))
                                {
                                    value = text;
                                }
                            }

                            NumberStyles style    = NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowCurrencySymbol;
                            CultureInfo  provider = CultureInfo.CreateSpecificCulture("ES-CO");

                            try
                            {
                                if (!string.IsNullOrEmpty(text) && !text.ToUpper().Trim().Contains("BLANK_PREP") && !text.ToUpper().Trim().Contains("STD") && !text.ToUpper().Trim().Contains("STD") && !text.ToUpper().Trim().Contains("BLANK") &&
                                    !text.ToUpper().Trim().Contains("BLK BLANK"))
                                {
                                    decimal num  = 0m;
                                    decimal au   = 0m;
                                    decimal ag   = 0m;
                                    decimal peso = 0m;
                                    if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[j][2].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[j][2].ToString().Trim(), style, provider, out num))
                                    {
                                        num = decimal.Parse(dataSet.Tables[0].Rows[j][2].ToString().Trim());
                                    }
                                    if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[j][3].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[j][3].ToString(), style, provider, out au))
                                    {
                                        au = decimal.Parse(dataSet.Tables[0].Rows[j][3].ToString().Trim());
                                    }
                                    if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[j][4].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[j][4].ToString().Trim(), style, provider, out ag))
                                    {
                                        ag = decimal.Parse(dataSet.Tables[0].Rows[j][4].ToString().Trim());
                                    }
                                    if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[j][5].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[j][5].ToString().Trim(), style, provider, out peso))
                                    {
                                        peso = decimal.Parse(dataSet.Tables[0].Rows[j][5].ToString().Trim());
                                    }
                                    SqlParameter[] array = GuardarDatos.Parametros_DetalleExcelPM("", text, num, au, ag, peso, "1", idLab, CmbTipoIngreso.Text);
                                    guardarDatos.Numerico("Sp_Moficiar_AnaQuiPM", array);
                                    if (num > decimal.Zero)
                                    {
                                        array = GuardarDatos.Parametros_ToneladaSeca(text, num);
                                        guardarDatos.Numerico("Sp_Moficiar_ToneladasSeca_MuestreoPM", array);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Sello:" + text + " EX:" + ex.Message, "selloControl");
                                throw;
                            }
                        }
                        MessageBox.Show("Importacion Finalizada", "DB Metal", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                    catch (Exception ex2)
                    {
                        MessageBox.Show(ex2.Message);
                    }
                }

                if (CmbTipoIngreso.Text == "Reclamos")
                {
                    if (dataSet.Tables[0].Columns[0].ToString().Trim().ToUpper().Contains("INFORME DE RECLAMOS"))
                    {
                        LblTitulos.Text = "INFORME DE RECLAMOS";
                        typeFile        = 2;
                        for (int k = 44; k < dataSet.Tables[0].Rows.Count; k++)
                        {
                            string selloControl = dataSet.Tables[0].Rows[k][0].ToString().Replace(" ", "");
                            if (string.IsNullOrEmpty(selloControl))
                            {
                                break;
                            }
                            decimal humedad = 0m;
                            if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][3].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[k][3].ToString().Trim(), out humedad))
                            {
                                humedad = decimal.Parse(dataSet.Tables[0].Rows[k][3].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][3].ToString().Length - 1));
                            }
                            SqlParameter[] pparametros = GuardarDatos.Parametros_DetalleExcelHumedad("", selloControl, humedad, "1");
                            guardarDatos.Numerico("Sp_Moficiar_AnaQuiHum", pparametros);
                        }
                        MessageBox.Show("Importacion Finalizada");
                    }

                    if (dataSet.Tables[0].Columns[0].ToString().Trim().ToUpper().Contains("ACTLABS"))
                    {
                        LblTitulos.Text = "ACTLABS Colombia S.A.S.";
                        typeFile        = 2;

                        string IdLab = dataSet.Tables[0].Rows[1][1].ToString();

                        for (int k = 12; k < dataSet.Tables[0].Rows.Count; k++)
                        {
                            string selloControl = dataSet.Tables[0].Rows[k][0].ToString().Replace(" ", "");
                            if (string.IsNullOrEmpty(selloControl))
                            {
                                break;
                            }

                            decimal au   = 0;
                            decimal ag   = 0;
                            decimal peso = 0;

                            if (string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][1].ToString().Trim()))
                            {
                                if (string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][2].ToString().Trim()))
                                {
                                    if (string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][3].ToString().Trim()))
                                    {
                                        if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][11].ToString().Trim()))
                                        {
                                            if (!decimal.TryParse(dataSet.Tables[0].Rows[k][11].ToString().Trim(), out au))
                                            {
                                                au = decimal.Parse(dataSet.Tables[0].Rows[k][11].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][11].ToString().Length - 1));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!decimal.TryParse(dataSet.Tables[0].Rows[k][3].ToString().Trim(), out au))
                                        {
                                            au = decimal.Parse(dataSet.Tables[0].Rows[k][3].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][3].ToString().Length - 1));
                                        }
                                    }
                                }
                                else
                                {
                                    if (!decimal.TryParse(dataSet.Tables[0].Rows[k][2].ToString().Trim(), out au))
                                    {
                                        au = decimal.Parse(dataSet.Tables[0].Rows[k][2].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][2].ToString().Length - 1));
                                    }
                                }
                            }
                            else
                            {
                                /* Modificado Alvaro Araujo 06/06/2019 */
                                string valorEntrada = string.Empty;
                                if (dataSet.Tables[0].Rows[k][1].ToString().Contains("<"))
                                {
                                    valorEntrada = dataSet.Tables[0].Rows[k][1].ToString();
                                    var resultante     = valorEntrada.Trim(new Char[] { ' ', '<' });
                                    var valorCambio    = (Convert.ToDouble(resultante) / 2);
                                    var valoreRedondeo = Math.Round(valorCambio * 1000);
                                    au = Convert.ToDecimal(valoreRedondeo / 1000);
                                }
                                else if (dataSet.Tables[0].Rows[k][1].ToString().Contains(">"))
                                {
                                    valorEntrada = dataSet.Tables[0].Rows[k][1].ToString();
                                    var resultante = valorEntrada.Trim(new Char[] { ' ', '>' });

                                    if (Convert.ToDouble(resultante) == 5.001)
                                    {
                                        if (string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][2].ToString().Trim()))
                                        {
                                            if (string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][3].ToString().Trim()))
                                            {
                                                if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][11].ToString().Trim()))
                                                {
                                                    if (!decimal.TryParse(dataSet.Tables[0].Rows[k][11].ToString().Trim(), out au))
                                                    {
                                                        au = decimal.Parse(dataSet.Tables[0].Rows[k][11].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][11].ToString().Length - 1));
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (!decimal.TryParse(dataSet.Tables[0].Rows[k][3].ToString().Trim(), out au))
                                                {
                                                    au = decimal.Parse(dataSet.Tables[0].Rows[k][3].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][3].ToString().Length - 1));
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (!decimal.TryParse(dataSet.Tables[0].Rows[k][2].ToString().Trim(), out au))
                                            {
                                                au = decimal.Parse(dataSet.Tables[0].Rows[k][2].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][2].ToString().Length - 1));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        var valorCambio = (Convert.ToDouble(resultante) + 0.001);
                                        au = Convert.ToDecimal(valorCambio);
                                    }
                                }
                                else
                                {
                                    if (!decimal.TryParse(dataSet.Tables[0].Rows[k][1].ToString().Trim(), out au))
                                    {
                                        au = decimal.Parse(dataSet.Tables[0].Rows[k][1].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][2].ToString().Length - 1));
                                    }
                                }
                            }


                            if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[k][12].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[k][12].ToString().Trim(), out peso))
                            {
                                peso = decimal.Parse(dataSet.Tables[0].Rows[k][12].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[k][12].ToString().Length - 1));
                            }

                            ag = au;

                            SqlParameter[] pparametros = GuardarDatos.CargaReclamosActLab(selloControl, IdLab, 0, au, ag, peso, CmbTipoIngreso.Text.ToString(), "1");
                            guardarDatos.Numerico("Sp_Moficiar_ReclamosActlabs", pparametros);
                        }
                        MessageBox.Show("Importacion Finalizada");

                        /* ***************************************************************************************  */
                    }
                }
                else
                {
                    if (dataSet.Tables[0].Rows[15][3].ToString().Trim().ToUpper().Contains("HUM"))
                    {
                        LblTitulos.Text = "Humedad Laboratorio Zandor";
                        typeFile        = 2;
                        for (int l = 45; l < dataSet.Tables[0].Rows.Count; l++)
                        {
                            string text3 = dataSet.Tables[0].Rows[l][0].ToString().Replace(" ", "");
                            if (string.IsNullOrEmpty(text3))
                            {
                                break;
                            }
                            decimal humedad2 = 0m;
                            if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[l][3].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[l][3].ToString().Trim(), out humedad2))
                            {
                                humedad2 = decimal.Parse(dataSet.Tables[0].Rows[l][3].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[l][3].ToString().Length - 1));
                            }
                            SqlParameter[] pparametros2 = GuardarDatos.Parametros_DetalleExcelHumedad("", text3, humedad2, "1");
                            guardarDatos.Numerico("Sp_Moficiar_AnaQuiHum", pparametros2);
                        }
                        MessageBox.Show("Importacion Finalizada");
                    }

                    // Renalisis y Retalla
                    if (dataSet.Tables[0].Rows[0][0].ToString().Trim().ToUpper().Contains("LABORATORIO") && dataSet.Tables[0].Rows[1][0].ToString().Trim().ToUpper().Contains("REPORTE DE ANÁLISIS QUÍMICO"))
                    {
                        LblTitulos.Text = "Reporte de Análisis Químico";
                        typeFile        = 1;
                        for (int m = 45; m < dataSet.Tables[0].Rows.Count; m++)
                        {
                            string text4 = dataSet.Tables[0].Rows[m][0].ToString().Replace(" ", "");

                            if (!text4.ToUpper().Contains("DUPLIC"))
                            {
                                if (text4.Contains("+") || text4.Contains("-"))
                                {
                                    int length = text4.IndexOf("(");
                                    text4 = text4.Substring(0, length);

                                    if (dataSet.Tables[0].Rows[m][0].ToString().Contains("-"))
                                    {
                                        text4 += "A";
                                    }

                                    if (string.IsNullOrEmpty(text4))
                                    {
                                        break;
                                    }
                                }

                                decimal au2  = 0m;
                                decimal augr = 0m;
                                decimal peso = 0;
                                if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[m][1].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[m][1].ToString().Trim(), out au2))
                                {
                                    au2 = decimal.Parse(dataSet.Tables[0].Rows[m][1].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[m][1].ToString().Length - 1));
                                }

                                if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[m][2].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[m][2].ToString().Trim(), out augr))
                                {
                                    augr = decimal.Parse(dataSet.Tables[0].Rows[m][2].ToString().Trim().Substring(1, dataSet.Tables[0].Rows[m][2].ToString().Length - 1));
                                }

                                if (!string.IsNullOrEmpty(dataSet.Tables[0].Rows[m][2].ToString().Trim()) && !decimal.TryParse(dataSet.Tables[0].Rows[m][2].ToString().Trim(), out peso))
                                {
                                    peso = decimal.Parse(dataSet.Tables[0].Rows[m][2].ToString().Trim().Substring(0, dataSet.Tables[0].Rows[m][2].ToString().Length));
                                }

                                SqlParameter[] pparametros3 = GuardarDatos.Parametros_DetalleExcelZandor("", text4, au2, augr, peso, "1", CmbTipoIngreso.Text.ToString());
                                guardarDatos.Numerico("Sp_Moficiar_AnaQuiZandor", pparametros3);
                            }
                        }
                        MessageBox.Show("Importacion Finalizada", "DB Metal", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex3)
            {
                MessageBox.Show(ex3.Message, "Mensaje de Execpción", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            #region LLenado de DataGrid Auxiliar

            DataTable dt = new DataTable();
            dt.Columns.Add("Incluir");
            dt.Columns.Add("Id");
            dt.Columns.Add("SelloH");
            dt.Columns.Add("SelloP");
            dt.Columns.Add("Humedad");
            dt.Columns.Add("Tenor");
            dt.Columns.Add("Peso");
            dt.Columns.Add("Cliente");
            dt.Columns.Add("Orden");
            dt.Columns.Add("Muestra");
            dt.Columns.Add("Referencia");
            dt.Columns.Add("Lugar");
            dt.Columns.Add("Recepcion");
            dt.Columns.Add("Reporte");
            DataRow Row = dt.NewRow();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                bool   incluir    = Convert.ToBoolean(row.Cells[0].Value);
                int    id         = Convert.ToInt32(row.Cells[1].Value);
                string sellop     = Convert.ToString(row.Cells[2].Value);
                string selloh     = Convert.ToString(row.Cells[3].Value);
                double humedad    = Convert.ToDouble(row.Cells[4].Value);
                double tenor      = Convert.ToDouble(row.Cells[5].Value);
                int    peso       = Convert.ToInt32(row.Cells[6].Value);
                string cliente    = this.TxbCliente.Text.Trim();
                string orden      = this.TxbOrden.Text.Trim();
                string muestra    = this.TxbMuestras.Text.Trim();
                string referencia = this.TxbReferencia.Text.Trim();
                string lugar      = this.TxbLugar.Text.Trim();
                string recepcion  = this.TxbRecepcion.Text.Trim();
                string reporte    = this.TxbReporte.Text.Trim();

                Row["incluir"]    = incluir;
                Row["Id"]         = id;
                Row["Sellop"]     = sellop;
                Row["Selloh"]     = selloh;
                Row["Humedad"]    = humedad;
                Row["Tenor"]      = tenor;
                Row["Peso"]       = peso;
                Row["Cliente"]    = cliente;
                Row["Orden"]      = orden;
                Row["Muestra"]    = muestra;
                Row["Referencia"] = referencia;
                Row["Lugar"]      = lugar;
                Row["Recepcion"]  = recepcion;
                Row["Reporte"]    = reporte;
                dt.Rows.Add(Row);
                Row = dt.NewRow();
            }
            #endregion

            #region Enviando Parametros para guardar Datos

            try
            {
                SqlParameter[] ParametroI = new SqlParameter[1];
                ParametroI[0] = new SqlParameter("@TablaExcelSGS", dt);

                GuardarDatos Guardar = new GuardarDatos();

                int Resultado = Guardar.Numerico("Sp_InsertDatosExcelSGS", ParametroI);
                this.TxbConsecutivo.Text = Resultado.ToString().Trim();

                MessageBox.Show("Registro Actualziado con Exito");
            }
            catch (Exception Ext)
            {
                MessageBox.Show(Ext.Message);
            }


            #endregion
        }
Exemple #16
0
        private void button3_Click(object sender, EventArgs e)
        {
            string controlID = string.Empty;
            int    roleID    = 0;

            try
            {
                string[] node = PermissionTree.SelectedNode.FullPath.Split(':');
                string[] nameForm;
                if (node.Length > 1)
                {
                    if (!ByRoleRB.Checked)
                    {
                        nameForm = node[1].Split('-');

                        var roleId = this.controlSecurityDataSet1.Roles.Where(u => u.RoleName == nameForm[1].ToString()).Select(s => s.RoleID);

                        foreach (var item in roleId)
                        {
                            roleID = item;
                        }

                        string nameForms = nameForm[0].ToString();

                        nameForm  = node[0].Split('\\');
                        controlID = nameForm[0].ToString();

                        SqlParameter[] ParamSQl = GuardarDatos.Parametros_Update_Rol(roleID, nameForms, controlID, InVisible.Checked ? 1 : 0, Disabled.Checked ? 1 : 0, checkBox1.Checked ? 1 : 0, checkBox2.Checked ? 1 : 0, checkBox4.Checked ? 1 : 0);

                        GuardarDatos Guardar = new GuardarDatos();

                        bool rowsInserted = Guardar.booleano("spUpdateControlToRole", ParamSQl);

                        if (!rowsInserted)
                        {
                            DisplayError(controlID, roleID, "Registros insertados= " + rowsInserted.ToString());
                        }
                        else
                        {
                            MessageBox.Show("Registro actualizado con exito!");
                        }
                    }
                    else
                    {
                        nameForm = node[0].Split('-');
                        string[] nameForm1 = nameForm[0].ToString().Split('\\');
                        var      roleId    = this.controlSecurityDataSet1.Roles.Where(u => u.RoleName == nameForm1[0].ToString()).Select(s => s.RoleID);

                        foreach (var item in roleId)
                        {
                            roleID = item;
                        }

                        string nameForms = nameForm[0].ToString();

                        nameForm  = node[1].Split('-');
                        nameForms = nameForm[0].ToString();
                        controlID = nameForm[1].ToString();

                        SqlParameter[] ParamSQl = GuardarDatos.Parametros_Update_Rol(roleID, nameForms, controlID, InVisible.Checked ? 1 : 0, Disabled.Checked ? 1 : 0, checkBox1.Checked ? 1 : 0, checkBox2.Checked ? 1 : 0, checkBox4.Checked ? 1 : 0);

                        GuardarDatos Guardar = new GuardarDatos();

                        bool rowsInserted = Guardar.booleano("spUpdateControlToRole", ParamSQl);

                        if (!rowsInserted)
                        {
                            DisplayError(controlID, roleID, "Registros insertados= " + rowsInserted.ToString());
                        }
                        else
                        {
                            MessageBox.Show("Registro actualizado con exito!");
                        }
                    }


                    LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Modifiación de permisos", "Asignación de permisos");
                }
            }
            catch (Exception ex)
            {
                DisplayError(controlID, roleID, ex.Message);
            }

            PopulatePermissionTree();
        }
Exemple #17
0
        private void BtnGuardarLiquidacion_Click(object sender, EventArgs e)
        {
            Ent_TblMinas TblMinas = new Ent_TblMinas();

            TblMinas = ConsultaTablas.TblMinas("TblMinasEspe", this.TxbCodigo.Text.Trim(), 0, 0.00);

            #region Insertando Datos
            if (string.IsNullOrEmpty(TblMinas.Codigo))
            {
                MessageBox.Show("Mina/Proyecto No Existe");
            }
            else
            {
                try
                {
                    SqlParameter[] ParametrosEnt = new SqlParameter[16];
                    ParametrosEnt[0]  = new SqlParameter("@Op", "I");
                    ParametrosEnt[1]  = new SqlParameter("@IdMina", TblMinas.Id);
                    ParametrosEnt[2]  = new SqlParameter("@CodigoEsquema", this.CmbEsquema.SelectedValue);
                    ParametrosEnt[3]  = new SqlParameter("@IdContratista", this.CmbContratista.SelectedValue);
                    ParametrosEnt[4]  = new SqlParameter("@Detalle", this.TxbDetalleEsquema.Text.Trim());
                    ParametrosEnt[5]  = new SqlParameter("@Fecha", this.DtpContrato.Text.Trim().Replace("/", ""));
                    ParametrosEnt[6]  = new SqlParameter("@Inscripcion", this.DtpInscriContrato.Text.Trim().Replace("/", ""));
                    ParametrosEnt[7]  = new SqlParameter("@Vencimiento", this.DtpVenciContrato.Text.Trim().Replace("/", ""));
                    ParametrosEnt[8]  = new SqlParameter("@Recuperacion", Convert.ToDouble(this.TxbRecuperacion.Text.ToString().Trim()));
                    ParametrosEnt[9]  = new SqlParameter("@Fondo", Convert.ToDouble(this.TxbFondo.Text.ToString().Trim()));
                    ParametrosEnt[10] = new SqlParameter("@Duracion", this.NmrDuracion.Value);
                    ParametrosEnt[11] = new SqlParameter("@Tenores", this.ChbTenores.Checked);
                    ParametrosEnt[12] = new SqlParameter("@AnexoSeguridad", this.ChbAnexos.Checked);
                    ParametrosEnt[13] = new SqlParameter("@Explosivos", this.ChbClausulas.Checked);
                    ParametrosEnt[14] = new SqlParameter("@DevolucionFondo", this.ChbFondo.Checked);
                    ParametrosEnt[15] = new SqlParameter("@Impuestos", Convert.ToDouble(this.TxbPorcImpuestos.Text.ToString().Trim()));

                    GuardarDatos Guardar = new GuardarDatos();
                    Guardar.booleano("Sp_GuardarMinasContratos", ParametrosEnt);

                    MessageBox.Show("Datos almacenados satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    #region Actualizando el DatGridView Mantenimiento
                    try
                    {
                        DataSet DS;
                        DS = ConsultaTablas.Dataset("ContratosMinasEspe", this.TxbCodigo.Text.Trim(), 0, 0.00);
                        this.DgvContratos.DataSource = DS;
                        this.DgvContratos.DataMember = "Result";
                        this.DgvContratos.AutoResizeColumns();
                    }
                    catch (Exception Exc)
                    {
                        MessageBox.Show("Error al consultar datos..: \n\n" + Exc.Message + " " + Exc.Source, "Informe del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    #endregion
                }

                catch (Exception E)
                {
                    MessageBox.Show("Error al Guardar los datos..: \n\n" + E.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }


            #endregion
        }
Exemple #18
0
    void Update()                               // Update is called once per frame
    {
        if (final >= 6)
        {
            PausarTiempo();
        }
        else
        {
            StartCoroutine("ControlTiempo");
        }


        if (Input.GetMouseButtonDown(0))
        {
            Ray        rayOrigin = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;
            if (Physics.Raycast(rayOrigin, out hitInfo))
            {
                Debug.DrawLine(transform.position, hitInfo.point, Color.red, 0.5f);
                string nom  = hitInfo.collider.gameObject.name;
                string nom2 = nom = nom.Substring(0, nom.Length - 1);

                if (!nom.Equals("GUI") && !nom.Equals("Plane"))
                {
                    txtFind.text = inf.getDescripcion(nom2);
                    Debug.Log("Detectado: " + hitInfo.collider.gameObject.name + ", Objetivo: " + target);
                    if (target.Equals(nom))
                    {
                        consecutivas++;
                        Debug.Log("Encontrada la parte " + consecutivas + " de 2 " + nom + ". Final " + final);
                        puntos += 100;
                        hitInfo.collider.gameObject.GetComponent <Transform> ().localScale = Vector3.zero;

                        inf.getDescripcion(nom2);
                        if (consecutivas == 1)
                        {
                            imgObjetivo.GetComponent <RectTransform> ().localScale = new Vector3(4f, 3f, 4f);
                            CambiarImg(target);
                        }

                        if (consecutivas == 2)
                        {
                            encontradas++;
                            GameObject.Find("txtAciertos").GetComponent <Text> ().text        = encontradas.ToString();
                            GameObject.Find(nom + "A").GetComponent <Transform> ().localScale = Vector3.one;
                            GameObject.Find(nom + "B").GetComponent <Transform> ().localScale = Vector3.one;
                            MostrarPanel(true);
                            txtAviso.text = "Lo lograste, ahora avanza al siguiente objetivo";
                            txtAviso.text = txtAviso.text + " " + txtTarget.text;
                            inf.QuitarElemento(nom);
                            target = inf.getNextItem();
                            if (!target.Contains("Cil") && !quitadas)
                            {
                                quitadas = true;
                                DestruirCilindros();
                            }
                            txtTarget.text = inf.getNextItemCorte();
                            Debug.Log("Cambiaremos de Objetivo a " + target);
                            CambiarImg("nada");
                            imgObjetivo.GetComponent <RectTransform> ().localScale = Vector3.zero;
                            CambiarImgObj();
                            consecutivas = 0;
                            final++;
                            MostrarFigurasObj();
                            PausarJuego();
                        }
                    }
                    else
                    {
                        puntos -= 100;
                        errores = Convert.ToInt32(GameObject.Find("txtErrores").GetComponent <Text>().text);
                        errores++;
                        GameObject.Find("txtErrores").GetComponent <Text>().text = errores.ToString();

                        consecutivas = 0;
                        MostrarPanel(false);
                        txtAviso      = GameObject.Find("txtAviso").GetComponent <Text> ();
                        txtAviso.text = "Incorrecto, se te pide que encuentres los fragmentos para armar la figura ";
                        txtAviso.text = txtAviso.text + " " + inf.getNextItemFigura();                         // + " " + txtTarget.text;
                        Debug.Log("A:  " + nom + "A" + ", " + nom + "B");
                        PausarJuego();
                        VerAyuda(txtTarget.text, target);
                    }

                    if (final > 5)
                    {
                        int aciertos = Convert.ToInt32(GameObject.Find("txtAciertos").GetComponent <Text>().text);
                        int err      = Convert.ToInt32(GameObject.Find("txtErrores").GetComponent <Text>().text);
                        Debug.Log("Errores " + err);
                        GuardarDatos g = new GuardarDatos("3", aciertos, err, puntos, tiempo, 1, "Facil");
                        g.Insert();
                        txtTarget.text = "FIN DEL JUEGO";
                        Debug.Log("Fin del juego");
                        GameObject  [] gmeO = GameObject.FindGameObjectsWithTag("Mov1");
                        foreach (GameObject gme in gmeO)
                        {
                            Destroy(gme, 0);
                        }
                    }
                    GameObject.Find("txtPuntos").GetComponent <Text> ().text       = puntos.ToString();
                    GameObject.Find("txtConsecutivas").GetComponent <Text> ().text = consecutivas.ToString();
                }
            }
        }
    }
Exemple #19
0
        private void Btn_BorrarAd_Click(object sender, EventArgs e)
        {
            #region Eliminando los datos Adjuntos
            DialogResult Opcion = MessageBox.Show("Desea Eliminar el archivo adjunto Seleccionado oprima el botón SI", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.RtlReading);
            if (Opcion == DialogResult.Yes)
            {
                try
                {
                    #region Determinando si se hace insert o update
                    SqlParameter[] ParamTipo = new SqlParameter[4];
                    ParamTipo[0] = new SqlParameter("@Op", "ExisteIdMina");
                    ParamTipo[1] = new SqlParameter("@ParametroChar", this.TxbCodigo.Text.Trim());
                    ParamTipo[2] = new SqlParameter("@ParametroInt", "0");
                    ParamTipo[3] = new SqlParameter("@ParametroNuemric", "0");
                    DataSet DaSet  = LlenarGrid.Datos("SpConsulta_Tablas", ParamTipo);
                    int     IdMina = Convert.ToInt32(DaSet.Tables[0].Rows[0]["Id"]);
                    #endregion

                    GuardarDatos GuardarDatos = new GuardarDatos();

                    int IdFile = Convert.ToInt32(this.DtgAdjunto.CurrentRow.Cells[0].Value);

                    SqlParameter[] ParametrosEnt = new SqlParameter[11];
                    ParametrosEnt[0]  = new SqlParameter("@Op", "D");
                    ParametrosEnt[1]  = new SqlParameter("@Id", IdFile);
                    ParametrosEnt[2]  = new SqlParameter("@Tipo", "1");
                    ParametrosEnt[3]  = new SqlParameter("@IdMina", IdMina);
                    ParametrosEnt[4]  = new SqlParameter("@Nombre", "");
                    ParametrosEnt[5]  = new SqlParameter("@Archivo", Encoding.ASCII.GetBytes(""));
                    ParametrosEnt[6]  = new SqlParameter("@Extension", "");
                    ParametrosEnt[7]  = new SqlParameter("@Detalle", "");
                    ParametrosEnt[8]  = new SqlParameter("@Realizado", DateTime.Now);
                    ParametrosEnt[9]  = new SqlParameter("@Maquina", Environment.MachineName);
                    ParametrosEnt[10] = new SqlParameter("@Usuario", this.IdUsuario);

                    GuardarDatos Guardar   = new GuardarDatos();
                    bool         Realizado = Guardar.booleano("Sp_Guardar_DatosAdjuntosMinas", ParametrosEnt);
                    if (Realizado)
                    {
                        MessageBox.Show("Archivo Eliminado satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    #region Llenado el DataGrid de los adjuntos
                    try
                    {
                        SqlParameter[] ParametrosGrid = new SqlParameter[4];
                        ParametrosGrid[0] = new SqlParameter("@Op", "AdjuntosMinasEspe");
                        ParametrosGrid[1] = new SqlParameter("@ParametroChar", this.TxbCodigo.Text.ToString().Trim());
                        ParametrosGrid[2] = new SqlParameter("@ParametroInt", "0");
                        ParametrosGrid[3] = new SqlParameter("@ParametroNuemric", "0");
                        DataSet DS;

                        DS = LlenarGrid.Datos("SpConsulta_Tablas", ParametrosGrid);
                        this.DtgAdjunto.DataSource = DS;
                        this.DtgAdjunto.DataMember = "Result";
                        this.DtgAdjunto.AutoResizeColumns();
                    }
                    catch (Exception Exc)
                    {
                        MessageBox.Show("OCURRIÓ UN ERROR AL CONSULTAR O CARGAR LOS DATOS..: \n\n" + Exc.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    #endregion
                }
                catch (Exception Exc1)
                {
                    MessageBox.Show(Exc1.Message);;
                }
            }

            #endregion
        }
Exemple #20
0
    // Update is called once per frame
    void Update()
    {
        //mesaje.text = "SCORE: " + punt;



        if (Input.touchCount < 2)
        {
            if (input == true)
            {
                if (player.transform.position.x > 0)
                {
                    coordenadaX = (int)(player.transform.position.x + 0.1);
                }
                else
                {
                    coordenadaX = (int)(player.transform.position.x - 0.1);
                }

                if (player.transform.position.z < 0)
                {
                    coordenadaZ = (int)(player.transform.position.z - 0.1);
                }
                else
                {
                    coordenadaZ = (int)(player.transform.position.z + 0.1);
                }


                if (corx == coordenadaX && cory == coordenadaZ)
                {
                    remplazo02.SetActive(true);
                    complete = true;
                }
                if (cor2x == coordenadaX && cor2y == coordenadaZ)
                {
                    remplazo03.SetActive(true);
                    complete2 = true;
                }
                if (cor3x == coordenadaX && cor3y == coordenadaZ)
                {
                    remplazo01.SetActive(true);
                    complete3 = true;
                }



                Debug.Log("Error");


                if (complete && complete2 && complete3)
                {
                    input = false;

                    elapsed_time_s = DateTime.Now.Second;
                    elapsed_time_m = DateTime.Now.Minute;
                    elapsed_time_h = DateTime.Now.Hour;

                    tiempo_seg = (60 - start_time_s) - (60 - elapsed_time_s);
                    int time_min  = (60) * ((60 - start_time_m) - (60 - elapsed_time_m));
                    int time_hour = (60) * (elapsed_time_h - start_time_h);
                    int segg      = tiempo_seg + time_min + time_hour;

                    guardarDatos = new GuardarDatos(ident, punt, segg);
                    string json = JsonUtility.ToJson(guardarDatos);
                    //string json01 = JsonUtility.ToJson(rol);
                    //string idd = newUser.UserId;

                    Text_text_Nivel.SetActive(true);
                    reference.Child("usersData").Child(ident).Child("Game1").Child("Nivel2").SetRawJsonValueAsync(json);



                    string move = punt.ToString();
                    string time = segg.ToString();

                    setUser       = ident;
                    setNivel      = "1";
                    setDificultad = "2";

                    setTiempo = time;
                    setScore  = move;
                    setGrado  = grado;

                    StartCoroutine(Upload());



                    General.SetActive(true);
                    BtnLink.SetActive(true);



                    Btn_aceptar.SetActive(true);
                }



                Debug.Log("Exactoy ");
                Debug.Log(coordenadaX);
                Debug.Log(coordenadaZ);


                if (flagg == true)
                {
                    if (Input.touchCount > 0 && bander == true)
                    {
                        input = false;

                        flagg = false;
                        //mesaje.text= "ENtrOOOOO";
                        Touch touch1 = Input.GetTouch(0);

                        // Handle finger movements based on TouchPhase
                        switch (touch1.phase)
                        {
                        //When a touch has first been detected, change the message and record the starting position
                        case TouchPhase.Began:
                            // Record initial touch position.
                            startPos1 = touch1.position;
                            endPos1   = touch1.position;
                            xx        = ((int)startPos1.x) % 1000;
                            yy        = ((int)startPos1.y) % 1000;
                            string aux  = " " + xx;
                            string aux2 = aux + yy;
                            //mesaje.text = "Begun " + aux2;
                            break;

                        //Determine if the touch is a moving touch
                        case TouchPhase.Moved:
                            // Determine direction by comparing the current touch position with the initial one
                            direction1 = touch1.position - startPos1;
                            //mesaje.text = "Moving ";
                            break;

                        case TouchPhase.Ended:
                            // Report that the touch has ended when it ends
                            endPos1 = touch1.position;
                            xx      = ((int)endPos1.x) % 1000;
                            yy      = ((int)endPos1.y) % 1000;
                            string aux3 = " " + xx;
                            string aux4 = aux3 + yy;
                            //mesaje.text = "Ending " + yy;
                            break;
                        }
                        int difx = (int)startPos1.x - (int)endPos1.x;
                        int dify = (int)startPos1.y - (int)endPos1.y;
                        if (Mathf.Abs(difx) > Mathf.Abs(dify))
                        {
                            if (Mathf.Abs(difx) > 200)
                            {
                                if (difx > 0)
                                {
                                    StartCoroutine("moveLeft");
                                    //punt++;
                                    //mesaje.text = "SCORE: " + punt;
                                }
                                else
                                {
                                    StartCoroutine("moveRight");
                                    //punt++;
                                    //mesaje.text = "SCORE: " + punt;
                                }
                            }
                        }
                        else
                        {
                            //punt++;
                            //mesaje.text = "SCORE: " + punt;
                            if (Mathf.Abs(dify) > 200)
                            {
                                if (dify > 0)
                                {
                                    StartCoroutine("moveDown");
                                    //punt++;
                                    //mesaje.text = "SCORE: " + punt;
                                }
                                else
                                {
                                    StartCoroutine("moveUp");
                                    //punt++;
                                    //mesaje.text = "SCORE: " + punt;
                                }
                            }
                        }



                        input = true;

                        //mesaje.text = "Touch : " + message1 + "in direction" + direction1;
                    }
                }


                if (input == true)
                {
                    //Debug.Log("DoWhy");
                    if (Input.GetKey(KeyCode.UpArrow))
                    {
                        input = false;
                        StartCoroutine("moveUp");
                    }
                    else if (Input.GetKey(KeyCode.DownArrow))
                    {
                        input = false;
                        StartCoroutine("moveDown");
                    }
                    else if (Input.GetKey(KeyCode.LeftArrow))
                    {
                        input = false;
                        StartCoroutine("moveLeft");
                    }
                    else if (Input.GetKey(KeyCode.RightArrow))
                    {
                        input = false;
                        StartCoroutine("moveRight");
                    }
                }


                if (flagg == false)
                {
                    if (corx == coordenadaX && cory == coordenadaZ && System.Math.Abs(player.transform.position.y - 4) < 1)
                    //if (posVictoriaX == coordenadaX && posVictoriaZ == coordenadaZ)
                    {
                        //mesaje.text = "GANE xD";
                        //n_escenario++;
                        input = false;
                        //lista_aux[17] = lista_aux[16];
                        //puente.SetActive(true);
                        //n_escenario++;
                        Debug.Log(coordenadaX);
                        Debug.Log(coordenadaZ);
                    }

                    if ((int)metas[n_escenario].x == coordenadaX && (int)metas[n_escenario].y == coordenadaZ && System.Math.Abs(player.transform.position.y - 4) < 1)
                    //if (posVictoriaX == coordenadaX && posVictoriaZ == coordenadaZ)
                    {
                        //margen = new Vector2(28, -12); lista_aux.Add(margen);

                        Debug.Log(coordenadaX);
                        Debug.Log(coordenadaZ);
                        //n_escenario++;

                        flagg = true;
                    }
                    else
                    {
                        flagg = true;

                        pushh = true;
                    }
                }
            }
        }
    }
Exemple #21
0
    private void OnTriggerEnter(Collider other)
    {
        if (!terminada && currentAmount < 100f && GameObject.Find("Dropdown").GetComponent <RectTransform>().localScale == Vector3.zero)
        {
            Debug.Log(gameObject.name + " colisiona con " + other.name + "  Tag:" + other.GetComponent <Collider> ().tag + "  Target  " + tar);
            if (other.tag.Equals("Trigger") && other.name.Equals("Arenero") && gameObject.name.Equals("CuboArena"))
            {
                if (tar.Equals(""))
                {
                    tar = "Arenero";
                }

                if (tar.Equals("Arenero"))
                {
                    Debug.Log("Se ha cargado el cucharon de Arena");
                    //GameObject.FindGameObjectWithTag ("Mov1").GetComponent<MeshRenderer> ().material = mtArena;
                    //	GameObject.FindGameObjectWithTag ("Mov1").GetComponent<Transform> ().localScale = new Vector3 (1.2f, 1.2f, 1.1f);
                    cuboArena.GetComponent <MeshRenderer> ().material = mtArena;
                    cuboArena.tag = "Player";
                    tar           = "Contenedor";
                    lista         = true;
                    GameObject.Find("txtInstrucciones").GetComponent <Text>().text = "Colisiona el Marcador Cubo con el Contenedor";
                }
            }
            else if (other.tag.Equals("Player") && other.name.Equals("Contenedor") && lista &&
                     gameObject.name.Equals("CuboArena"))
            {
                Debug.Log("Se ha detectado el Tag " + other.tag + " en " + other.name + ".\t Target: " + tar);

                if (cuboArena.GetComponent <MeshRenderer> ().material.name.Contains("Arena") && tar.Equals("Contenedor"))
                {
                    //if (GameObject.FindGameObjectWithTag ("Mov1").GetComponent<MeshRenderer> ().material.name.Contains ("Arena") && tar.Equals ("Contenedor")) {
                    Debug.Log("Descargando el Cucharon en el Recipiente.");
                    getAltura();
                    BarraProgreso();
                    //	float ff = (currentAmount / 100f);

                    fig4.transform.localScale = new Vector3(4, currentAmount / 10f, 4);
                    //Aqui se cambia la posicion respecto de tablet y windows y mac
                    fig4.transform.localPosition = new Vector3(6.83f, (-6.39f + (currentAmount / 20f)), 24.9f);
                    //Aqui termina
                    cuboArena.tag = "Trigger";
                    tar           = "Arenero";
                    ncolisiones++;
                    cuboArena.GetComponent <MeshRenderer> ().material = blue;
                    //GameObject.FindGameObjectWithTag ("Mov1").GetComponent<MeshRenderer> ().material = null;
                    //GameObject.FindGameObjectWithTag ("Mov1").GetComponent<Transform> ().localScale = Vector3.zero;
                    Debug.Log("Avance  " + currentAmount);
                    lista = false;
                    if (currentAmount >= 100f)
                    {
                        GameObject.Find("pnlAyuda").GetComponent <RectTransform> ().localScale = new Vector3(0.25f, 0.3f, 0.1f);
                        if (excedente != 0)
                        {
                            GameObject.Find("txtAlerta").GetComponent <Text> ().text = "El Contenedor se ha llenado. \n Tu recipiente auxiliar tiene " + excedente + "% de excedente, excediste las dimeinsiones 3x10x3 del contenedor";
                        }
                        GameObject.Find("txtMensaje").GetComponent <Text> ().text = "Bravo. Alcanzaste la meta en " + ncolisiones + " pasos. \n" +
                                                                                    "Comenta con tus amigos que aprendiste.";
                        GameObject.Find("Arenero").GetComponent <Transform> ().localScale = Vector3.zero;
                        GameObject.Find("txtInstrucciones").GetComponent <Text>().text    = "El Contenedor se ha llenado. Lo Lograste.";
                        GameObject.Find("ARCamera").GetComponent <NoARCamera> ().enabled  = true;
                        //	GameObject.Find ("ARCamera").GetComponent<Camera> ().clearFlags = CameraClearFlags.Skybox;
                        Vuforia.CameraDevice.Instance.Stop();
                        GameObject.Find("ARCamera").GetComponent <Camera> ().clearFlags = CameraClearFlags.Skybox;
                        PausarTiempo();
                        GuardarDatos guardar = new GuardarDatos("2", ncolisiones, 0, (ncolisiones * 300), 0, 1, "Facil");
                        guardar.Insert();
                    }
                    else
                    {
                        GameObject.Find("txtInstrucciones").GetComponent <Text>().text = "Colisiona el Marcador Cubo con el Arenero";
                    }
                }
            }
            GameObject.Find("txtOpcion").GetComponent <Text> ().text = tar;
        }
        else if (currentAmount >= 100f)
        {
            GameObject.Find("pnlAyuda").GetComponent <RectTransform> ().localScale = new Vector3(0.25f, 0.3f, 0.1f);
            if (excedente != 0)
            {
                GameObject.Find("txtAlerta").GetComponent <Text> ().text = "El Contenedor se ha llenado. Tu recipiente auxiliar tiene " + excedente + "% de excedente, excediste las dimeinsiones 3x10x3 del contenedor";
            }
            GameObject.Find("txtMensaje").GetComponent <Text> ().text = "Bravo. Alcanzaste la meta en " + ncolisiones + " pasos. \n" +
                                                                        "Comenta con tus amigos que aprendiste.";
            GameObject.Find("Arenero").GetComponent <Transform> ().localScale = Vector3.zero;
            //GameObject.Find ("ARCamera").GetComponent<Camera> ().clearFlags = CameraClearFlags.Skybox;
            Vuforia.CameraDevice.Instance.Stop();
            GameObject.Find("ARCamera").GetComponent <Camera> ().clearFlags = CameraClearFlags.Skybox;
        }
    }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.TxbConsecutivo.Text != "0")
            {
                MessageBox.Show("No se puede guardar, reporte ya tiene un consecutivo generado.");
            }
            else
            {
                #region LLenado de DataGrid Auxiliar

                DataTable dt = new DataTable();
                dt.Columns.Add("Id");
                dt.Columns.Add("Fecha");
                dt.Columns.Add("Muestras");
                dt.Columns.Add("Cliente");
                dt.Columns.Add("AuUnidad");
                dt.Columns.Add("AuMetodo");
                dt.Columns.Add("AgUnidad");
                dt.Columns.Add("AgMetodo");
                dt.Columns.Add("HumedadUnd");
                dt.Columns.Add("HumedadMet");
                dt.Columns.Add("TipoMuestras");
                dt.Columns.Add("Orden");
                dt.Columns.Add("ClienteOrden");
                dt.Columns.Add("NumMuestras");
                dt.Columns.Add("FechaMuestreo");
                dt.Columns.Add("FechaReporte");
                dt.Columns.Add("Notas");
                dt.Columns.Add("CodigoPrepa");
                dt.Columns.Add("DescripcionPrepa");
                dt.Columns.Add("CodigoAnalisis");
                dt.Columns.Add("DescripcionAnalisis");
                dt.Columns.Add("Sello");
                dt.Columns.Add("Humedad");
                DataRow Row = dt.NewRow();

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    int    id      = Convert.ToInt32(row.Cells[0].Value);
                    string sello   = Convert.ToString(row.Cells[1].Value);
                    double humedad = Convert.ToDouble(row.Cells[2].Value);

                    Row["Id"]                  = id;
                    Row["Fecha"]               = this.TxbFecha.Text;
                    Row["Muestras"]            = this.TxbMuestras.Text;
                    Row["Cliente"]             = this.TxbCliente.Text;
                    Row["AuUnidad"]            = this.TxbAuUnidad.Text;
                    Row["AuMetodo"]            = this.TxbAuMetodo.Text;
                    Row["AgUnidad"]            = this.TxbAgUnidad.Text;
                    Row["AgMetodo"]            = this.TxbAgMetodo.Text;
                    Row["HumedadUnd"]          = this.TxbHumeUnidad.Text;
                    Row["HumedadMet"]          = this.TxbHumeMetodo.Text;
                    Row["TipoMuestras"]        = this.TxbTipoMuestra.Text;
                    Row["Orden"]               = this.TxbOrden.Text;
                    Row["ClienteOrden"]        = this.TxbClienteOrden.Text;
                    Row["NumMuestras"]         = this.TxbNumMuestras.Text;
                    Row["FechaMuestreo"]       = this.TxbFechaMuestreo.Text;
                    Row["FechaReporte"]        = this.TxbFechaReporte.Text;
                    Row["Notas"]               = this.TxbNotas.Text;
                    Row["CodigoPrepa"]         = this.TxbCodigoPreparacion.Text;
                    Row["DescripcionPrepa"]    = this.TxbDescripcionPreparacion.Text;
                    Row["CodigoAnalisis"]      = this.TxbCodigoAnalisis.Text;
                    Row["DescripcionAnalisis"] = this.TxbDescripcionAnalisis.Text;
                    Row["Sello"]               = sello;
                    Row["Humedad"]             = humedad;
                    dt.Rows.Add(Row);
                    Row = dt.NewRow();
                }
                #endregion

                #region Enviando Parametros para guardar Datos


                try
                {
                    SqlParameter[] ParametroI = new SqlParameter[1];
                    ParametroI[0] = new SqlParameter("@TablaExcelHumeZandor", dt);

                    GuardarDatos Guardar = new GuardarDatos();

                    int Resultado = Guardar.Numerico("Sp_InsertDatosExcelHumedadZandor", ParametroI);
                    this.TxbConsecutivo.Text = Resultado.ToString().Trim();

                    MessageBox.Show("Registros Actualziados con Exito");
                }
                catch (Exception Ext)
                {
                    MessageBox.Show(Ext.Message);
                }
                #endregion

                #region Guardando los Adjuntos

                try
                {
                    FileStream fs = new FileStream(this.TxbPath.Text, FileMode.Open);
                    //Creamos un array de bytes para almacenar los datos leídos por fs.
                    Byte[] data = new byte[fs.Length];
                    //Y guardamos los datos en el array data
                    fs.Read(data, 0, Convert.ToInt32(fs.Length));
                    fs.Close();

                    int PosInicialPath      = this.TxbPath.Text.Trim().LastIndexOf("\\") + 1;
                    int PosFinalPath        = this.TxbPath.Text.Trim().LastIndexOf(".") - 1;
                    int PosInicialExtension = this.TxbPath.Text.Trim().LastIndexOf(".");
                    int NumeroCaracteres    = PosFinalPath - PosInicialPath + 1;
                    int CaracteresExtension = this.TxbPath.Text.Trim().Length - PosInicialExtension;

                    SqlParameter[] ParametrosEnt = new SqlParameter[7];
                    ParametrosEnt[0] = new SqlParameter("@Op", "I");
                    ParametrosEnt[1] = new SqlParameter("@Orden", this.TxbOrden.Text.Trim());
                    ParametrosEnt[2] = new SqlParameter("@Ruta", this.TxbPath.Text.Trim());
                    ParametrosEnt[3] = new SqlParameter("@Nombre", this.TxbPath.Text.Substring(PosInicialPath, NumeroCaracteres));
                    ParametrosEnt[4] = new SqlParameter("@Archivo", data);
                    ParametrosEnt[5] = new SqlParameter("@Extension", this.TxbPath.Text.Substring(PosInicialExtension, CaracteresExtension));
                    ParametrosEnt[6] = new SqlParameter("@Maquina", Environment.MachineName);

                    ConsultaEntidades Maestro = new ConsultaEntidades();
                    GuardarDatos      Guardar = new GuardarDatos();

                    bool Realizado = Guardar.booleano("Sp_Guardar_AdjuntosSGS", ParametrosEnt);
                    MessageBox.Show("Adjunto almacenado con Exito");
                }
                catch (Exception Ext)
                {
                    MessageBox.Show(Ext.Message);
                }


                #endregion
            }
        }