private void btnGuardar_Click(object sender, EventArgs e) { try { SqlParameter[] ParametrosEnt = new SqlParameter[16]; 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); Ent_TblMinas TblMinas = new Ent_TblMinas(); TblMinas = ConsultaTablas.TblMinas("TblMinasEspe", this.TxbCodigo.Text.Trim(), 0, 0.00); if (string.IsNullOrEmpty(TblMinas.Codigo)) { ParametrosEnt[0] = new SqlParameter("@Op", "I"); } else { ParametrosEnt[0] = new SqlParameter("@Op", "U"); } GuardarDatos Guardar = new GuardarDatos(); Guardar.booleano("Sp_GuardarMinas", ParametrosEnt); if (string.IsNullOrEmpty(TblMinas.Codigo)) { MessageBox.Show("Mina/Operador Minero creada satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Mina/Operador Minero actualizado satisfactoriamente.", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception Exc) { MessageBox.Show(Exc.Message, "Error controlado del Sistema.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static Ent_TblMinas TblMinas(string Op, string ParametroChar, int ParametroInt, double ParametroNumeric) { SqlParameter[] ParamSQL = new SqlParameter[4]; ParamSQL[0] = new SqlParameter("@Op", Op); ParamSQL[1] = new SqlParameter("@ParametroChar", ParametroChar); ParamSQL[2] = new SqlParameter("@ParametroInt", ParametroInt); ParamSQL[3] = new SqlParameter("@ParametroNuemric", ParametroNumeric); ConsultaEntidades Maestro = new ConsultaEntidades(); Ent_TblMinas Entidad = new Ent_TblMinas(); Entidad = Maestro.TblMina("SpConsulta_Tablas", ParamSQL); return(Entidad); }
public static Ent_TblMinas TblMinas(string Op, string ParametroChar, int ParametroInt, double ParametroNumeric) { SqlParameter[] sP_Parametros = new SqlParameter[] { new SqlParameter("@Op", Op), new SqlParameter("@ParametroChar", ParametroChar), new SqlParameter("@ParametroInt", ParametroInt), new SqlParameter("@ParametroNuemric", ParametroNumeric) }; ConsultaEntidades consultaEntidades = new ConsultaEntidades(); Ent_TblMinas ent_TblMinas = new Ent_TblMinas(); return(consultaEntidades.TblMina("SpConsulta_Tablas", sP_Parametros)); }
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 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 }
private void TxbCodigo_Leave(object sender, EventArgs e) { Ent_TblMinas TblMinas = new Ent_TblMinas(); TblMinas = ConsultaTablas.TblMinas("TblMinasEspe", this.TxbCodigo.Text.Trim(), 0, 0.00); if (string.IsNullOrEmpty(TblMinas.Codigo)) { #region LLenando el Combo de las Minas List <Ent_VwMinas> Lista1 = new List <Ent_VwMinas>(); Lista1 = ConsultaTablas.ListaVwMinas("VwMinas", "", 0, 0.00); this.CmbMinas.DataSource = Lista1; this.CmbMinas.DisplayMember = "Nombre"; this.CmbMinas.ValueMember = "Id"; this.CmbMinas.SelectedIndex = -1; #endregion #region Limpiando Datos generales Contratos Operaciones this.TxbCodigoPM.Text = ""; this.TxbNombre.Text = ""; this.TxbExpediente.Text = ""; this.CmbDepende.SelectedIndex = -1; this.CmbTenorPromedio.SelectedIndex = -1; this.TxbArea.Text = ""; this.CmbMinas.SelectedIndex = -1; this.CmbTipoContrato.SelectedIndex = -1; this.TxbEste.Text = ""; this.TxbNorte.Text = ""; this.TxbElevacion.Text = ""; this.TxbDetalle.Text = ""; this.TxbCodigoPlaza.Text = ""; this.TxbDetallePlaza.Text = ""; this.TxbEmail.Text = ""; this.ChbInformes.Checked = false; #endregion #region Limpiando Page Contratos y Liquidacion this.CmbEsquema.SelectedIndex = -1; this.CmbContratista.SelectedIndex = -1; this.DtpContrato.Text = ""; this.DtpInscriContrato.Text = ""; this.DtpVenciContrato.Text = ""; this.TxbRecuperacion.Text = ""; this.TxbFondo.Text = ""; this.NmrDuracion.Value = 0; this.ChbTenores.Checked = false; this.ChbAnexos.Checked = false; this.ChbClausulas.Checked = false; this.ChbFondo.Checked = false; #endregion ConsultaEntidades Maestro = new ConsultaEntidades(); #region LLenando el Combo de los Tipo de Contratos List <Ent_VwTipoContrato> Lista2 = new List <Ent_VwTipoContrato>(); Lista2 = ConsultaTablas.ListaVwTipoContrato("VwTipoContrato", "", 0, 0.00); this.CmbTipoContrato.DataSource = Lista2; this.CmbTipoContrato.DisplayMember = "Nombre"; this.CmbTipoContrato.ValueMember = "Id"; this.CmbTipoContrato.SelectedIndex = 0; #endregion #region LLenando el Combo de los Contenedores List <Ent_Contenedores> Lista3 = new List <Ent_Contenedores>(); Lista3 = ConsultaTablas.ListaContenedores("Contenedores", "", 0, 0.00); this.CmbDepende.DataSource = Lista3; this.CmbDepende.DisplayMember = "Nombre"; this.CmbDepende.ValueMember = "Codigo"; this.CmbDepende.SelectedIndex = -1; #endregion #region LLenando el Combo de los Tipo de Empresas List <Ent_TiposDeEmpresa> Lista4 = new List <Ent_TiposDeEmpresa>(); Lista4 = ConsultaTablas.ListaTipoEmpresas("TipoEmpresas", "", 0, 0.00); this.CmbTipoEmpresa.DataSource = Lista4; this.CmbTipoEmpresa.DisplayMember = "Nombre"; this.CmbTipoEmpresa.ValueMember = "Id"; this.CmbTipoEmpresa.SelectedIndex = -1; #endregion } else { #region LLenando los Combo de la page principal this.CmbMinas.SelectedValue = TblMinas.IdMina; this.CmbTenorPromedio.SelectedIndex = Convert.ToInt32(TblMinas.TenorPromedio); this.CmbDepende.SelectedValue = TblMinas.CodigoContenedor; this.CmbTipoContrato.SelectedValue = TblMinas.IdTipoContrato; this.CmbTipoEmpresa.SelectedValue = TblMinas.IdTipoEmpresa; #endregion #region Llenando Datos generales Contratos Operaciones this.TxbCodigoPM.Text = TblMinas.CodigoPM; this.TxbNombre.Text = TblMinas.NombreMina; this.TxbExpediente.Text = TblMinas.Expediente; this.TxbArea.Text = Convert.ToString(TblMinas.Area); this.TxbEste.Text = Convert.ToDouble(TblMinas.Este).ToString("###,###,##0.#0"); this.TxbNorte.Text = Convert.ToDouble(TblMinas.Norte).ToString("###,###,##0.#0"); this.TxbElevacion.Text = Convert.ToDouble(TblMinas.Elevacion).ToString("###,###,##0.#0"); this.TxbDetalle.Text = TblMinas.Detalle; this.TxbCodigoPlaza.Text = TblMinas.CodigoPlaza; this.TxbDetallePlaza.Text = TblMinas.NombrePlaza; this.TxbEmail.Text = TblMinas.Email; this.ChbInformes.Checked = TblMinas.MostrarEnInformes; this.ChbRecuperacion.Checked = TblMinas.RecuperacionPlanta; this.ChbEstado.Checked = TblMinas.Estado; if (this.ChbEstado.Checked) { this.ChbEstado.Text = "Activo"; } else { this.ChbEstado.Text = "Bloqueado"; } #endregion #region Llenado el DataGrid de los Contratos try { DataSet 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("OCURRIÓ UN ERROR AL CONSULTAR O CARGAR LOS DATOS..: \n\n" + Exc.Message, "Error del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error); } #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 #region Limpiando Page Contratos y Liquidacion this.CmbEsquema.SelectedIndex = -1; this.CmbContratista.SelectedIndex = -1; this.DtpContrato.Text = ""; this.DtpInscriContrato.Text = ""; this.DtpVenciContrato.Text = ""; this.TxbRecuperacion.Text = "0.00"; this.TxbFondo.Text = "0.00"; this.NmrDuracion.Value = 0; this.ChbTenores.Checked = false; this.ChbAnexos.Checked = false; this.ChbClausulas.Checked = false; this.ChbFondo.Checked = false; this.TxbDetalleEsquema.Text = ""; #endregion } }