Пример #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(TxbIdentificacion.Text.Trim()))
     {
         DialogResult Opcion = MessageBox.Show("Realmente desea eliminar la localización", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
         if (Opcion == DialogResult.Yes)
         {
             try
             {
                 GuardarDatos   Guardar  = new GuardarDatos();
                 SqlParameter[] ParamSQl = GuardarDatos.Parametros_Localizacion("D", TxbIdentificacion.Text.Trim(), TxbNombre.Text.Trim(), ChbEstado.Checked, txtDetail.Text);
                 if (Guardar.booleano("Sp_Guardar_Localizacion", ParamSQl))
                 {
                     Limpiar(1);
                     MessageBox.Show("Localización eliminada con Exito");
                     LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se elimino localización " + TxbIdentificacion.Text.Trim() + " " + TxbNombre.Text.Trim(), "Maestro Localización - Elimino localización");
                 }
                 else
                 {
                     MessageBox.Show("Localización no se elimino debido a que no existe");
                 }
             }
             catch (Exception Ex)
             {
                 MessageBox.Show(Ex.Message);
             }
         }
     }
     else
     {
         MessageBox.Show("Debe de seleccionar una código para eliminar");
     }
 }
Пример #2
0
 private void button2_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();
     }
     if (!string.IsNullOrEmpty(this.ValorPeriodo))
     {
         Frm_Reporte_Liquidacion frm_Reporte_Liquidacion = new Frm_Reporte_Liquidacion();
         LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Impresión reporte Onzas Entergadas", "Impresión Reporte");
         object[] argument = new object[]
         {
             5,
             this.ValorPeriodo
         };
         frm_Reporte_Liquidacion.EjecucionReportes(argument);
         frm_Reporte_Liquidacion.Show();
     }
     else
     {
         MessageBox.Show("Seleccione un periodo a imprimir");
     }
 }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(TxbIdentificacion.Text.Trim()) && !String.IsNullOrEmpty(TxbNombre.Text.Trim()))
            {
                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_Localizacion("", TxbIdentificacion.Text.Trim(), TxbNombre.Text.Trim(), ChbEstado.Checked, txtDetail.Text);
                    if (Guardar.booleano("Sp_Guardar_Localizacion", ParamSQl))
                    {
                        if (ParamSQl[0].Value.ToString() == "I")
                        {
                            MessageBox.Show("La localización se almacenado con Exito");
                            LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se creo localización " + TxbIdentificacion.Text.Trim() + " " + TxbNombre.Text.Trim(), "Maestro Localización - Crear");
                        }
                        else
                        {
                            MessageBox.Show("La localización se ha actualizado con Exito");
                            LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se modifico la localización" + TxbIdentificacion.Text.Trim() + " " + TxbNombre.Text.Trim(), "Maestro Localización - Modificar");
                        }
                    }

                    Limpiar(1);
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message);
                }
            }
            else
            if (String.IsNullOrEmpty(TxbIdentificacion.Text.Trim()))
            {
                MessageBox.Show("Debe de ingresar un código");
            }
            else
            {
                MessageBox.Show("Debe de ingresar un nombre");
            }
        }
Пример #4
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(ValorPeriodo))
            {
                Frm_Reporte_Liquidacion frmReporte = new Frm_Reporte_Liquidacion();
                LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Impresión reporte Onzas Recuperados", "Impresión Reporte");

                object[] argument = new object[] { 6, Ano, Mes, Periodo };
                frmReporte.EjecucionReportes(argument);
                frmReporte.Show();
            }
            else
            {
                MessageBox.Show("Seleccione un periodo a imprimir");
            }
        }
Пример #5
0
 private void CmdExaminar_Click(object sender, EventArgs e)
 {
     if (this.Txtruta.Text == string.Empty)
     {
         MessageBox.Show("Debe seleccionar un archivo para cargar.", "Carga de Análisis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         if (this.CmbTipoIngreso.Text == string.Empty)
         {
             MessageBox.Show("Debe seleccionar un tipo de ingreso para el carge del archivo de carga.", "Carga de Análisis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             if (this.Txtruta.Text != string.Empty)
             {
                 try
                 {
                     Cargar();
                     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();
                     }
                     LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Carga Analisis Laboratorio, Archivo " + this.descripcionArchivo, "Movimiento Muestreo creado");
                 }
                 catch (OleDbException ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
         }
     }
 }
Пример #6
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            string wProyecto = string.Empty;
            string wPeriodo  = string.Empty;

            if (cmbProyecto.SelectedIndex != 0)
            {
                wProyecto = cmbProyecto.Text;
            }

            if (cmbPeriodo.SelectedIndex != 0)
            {
                wPeriodo = cmbPeriodo.Text;
            }

            FrmRptDiarioMuestreo frmReporte = new FrmRptDiarioMuestreo(Convert.ToDateTime(dtpEventInitial.Text).ToString("yyyy-MM-dd"),
                                                                       Convert.ToDateTime(dtpEventEnd.Text).ToString("yyyy-MM-dd"), wProyecto, wPeriodo, txtNumOrden.Text);

            frmReporte.Show();
            string nameReport = "Reporte Diario Muestreo planta Maria Dama";


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

            LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se genera el reporte de " + nameReport, "Generación de Reportes");
        }
Пример #7
0
        private void CmdExaminar_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFD = new OpenFileDialog();
            openFD.Title = "Seleccionar archivos";
            openFD.Filter = "Todos los archivos  (*.xls) | *.xlsx;*.xls";
            openFD.Multiselect = false;
            openFD.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            if (openFD.ShowDialog() == DialogResult.OK)
            {
                Txtruta.Text = openFD.FileName;
            }
            if (Txtruta.Text == "")
            {

            }
            else
            {
                try
                {
                    Cargar(dtgExcel, Txtruta.Text);

                    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();

                    LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Carga Analisis Laboratorio, Archivo " + openFD.FileName, "Movimiento Muestreo creado");

                }
                catch (OleDbException ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult Opcion = MessageBox.Show("Realmente desea eliminar el Personal de Muestreo", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (Opcion == DialogResult.Yes)
            {
                try
                {
                    GuardarDatos   Guardar  = new GuardarDatos();
                    SqlParameter[] ParamSQl = GuardarDatos.Parametros_PersonalMuestreo("D", TxbIdentificacion.Text.Trim(), TxbNombre.Text.Trim(), TxbApellido.Text.Trim(), TxbDireccion.Text.Trim(), TxbTelFijo.Text.Trim(), TxbCelular.Text.Trim(), TxbEmail.Text.Trim(), 1, Convertir.ImagenEnByte(PtbPersonal.Image), ChbEstado.Checked, DateTime.Now);
                    if (Guardar.booleano("Sp_Guardar_PersonalMuestreo", ParamSQl))
                    {
                        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");
                    }
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message);
                }
            }
        }
Пример #9
0
        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);
            }
        }
Пример #10
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");
            }
        }
Пример #11
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            Frm_Reporte_Liquidacion frmReporte = null;

            object[] argument   = null;
            string   nameReport = string.Empty;

            //comboBox1
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                if (dtpEventInitial.Value > dtpEventEnd.Value)
                {
                    MessageBox.Show("La fecha inicial no debe de ser superior a la final");
                    return;
                }
                else
                if (dtpEventEnd.Value < dtpEventInitial.Value)
                {
                    MessageBox.Show("La fecha final no debe de ser inferior a la inicial");
                    return;
                }
                string mina = string.Empty;

                if (!comboMina.SelectedIndex.Equals(comboMina.Items.Count - 1))
                {
                    mina = comboMina.Text.Trim();
                }

                nameReport = "Detalle Mina Día";


                frmReporte = new Frm_Reporte_Liquidacion();
                argument   = new object[] { 1, dtpEventInitial.Value, dtpEventEnd.Value, checkBox1.Checked, mina };

                frmReporte.EjecucionReportes(argument);
                frmReporte.Show();
                break;

            case 1:
                if (dtpEventInitial.Value == null)
                {
                    MessageBox.Show("La fecha inicial no puede ser  Nula");
                    return;
                }
                nameReport = "Resumen Mina Día";
                mina       = string.Empty;

                if (!comboMina.SelectedIndex.Equals(comboMina.Items.Count - 1))
                {
                    mina = comboMina.Text.Trim();
                }

                frmReporte = new Frm_Reporte_Liquidacion();
                argument   = new object[] { 2, dtpEventInitial.Value, dtpEventEnd.Value, checkBox1.Checked, mina };

                frmReporte.EjecucionReportes(argument);
                frmReporte.Show();
                break;

            case 2:
                if (dtpEventInitial.Value == null)
                {
                    MessageBox.Show("La fecha inicial no puede ser  Nula");
                    return;
                }
                nameReport = "Detalle Muestreo";

                mina = string.Empty;

                if (!comboMina.SelectedIndex.Equals(comboMina.Items.Count - 1))
                {
                    mina = comboMina.Text.Trim();
                }

                frmReporte = new Frm_Reporte_Liquidacion();
                argument   = new object[] { 3, dtpEventInitial.Value, dtpEventEnd.Value, checkBox1.Checked, mina };

                frmReporte.EjecucionReportes(argument);
                frmReporte.Show();
                break;

            case -1:
                MessageBox.Show("Selcciona el Reporte a generar");
                break;

            default:
                break;
            }

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

            LlenarLog.Registro(DateTime.Now, this.Usuario, this.IpLocal, this.IpPublica, this.SerialHDD, Environment.MachineName, "Se genera el reporte de " + nameReport, "Generación de Reportes");
        }
Пример #12
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();
        }
Пример #13
0
        private void Save_Click(object sender, EventArgs e)
        {
            SqlConnection conn = Conexion.OpenConexion();

            SqlParameter param;

            foreach (String controlID in PageControls.SelectedItems)
            {
                foreach (DataRowView roleRow in PermissionRoles.SelectedItems)
                {
                    int roleID = Convert.ToInt32(roleRow["RoleID"]);
                    try
                    {
                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection  = conn;
                        cmd.CommandText = "spInsertNewControlToRole";
                        cmd.CommandType = CommandType.StoredProcedure;

                        param           = cmd.Parameters.Add("@RoleID", SqlDbType.Int);
                        param.Value     = roleID;
                        param.Direction = ParameterDirection.Input;

                        param           = cmd.Parameters.Add("@PageName", SqlDbType.VarChar, 50);
                        param.Value     = workingForm.Name.ToString();
                        param.Direction = ParameterDirection.Input;

                        param           = cmd.Parameters.Add("@ControlID", SqlDbType.VarChar, 50);
                        param.Value     = controlID;
                        param.Direction = ParameterDirection.Input;

                        param           = cmd.Parameters.Add("@invisible", SqlDbType.Int);
                        param.Value     = InVisible.Checked ? 1 : 0;
                        param.Direction = ParameterDirection.Input;

                        param           = cmd.Parameters.Add("@disabled", SqlDbType.Int);
                        param.Value     = Disabled.Checked ? 1 : 0;
                        param.Direction = ParameterDirection.Input;

                        param           = cmd.Parameters.Add("@ContenedorPeqMineria", SqlDbType.Int);
                        param.Value     = checkBox1.Checked ? 1 : 0;
                        param.Direction = ParameterDirection.Input;

                        param           = cmd.Parameters.Add("@ContenedorZandor", SqlDbType.Int);
                        param.Value     = checkBox2.Checked ? 1 : 0;
                        param.Direction = ParameterDirection.Input;

                        param           = cmd.Parameters.Add("@ContenedorOtros", SqlDbType.Int);
                        param.Value     = checkBox4.Checked ? 1 : 0;
                        param.Direction = ParameterDirection.Input;
                        //}

                        int rowsInserted = cmd.ExecuteNonQuery();
                        if (rowsInserted < 1 || rowsInserted > 2)
                        {
                            DisplayError(controlID, roleID, "Registros insertados= " + rowsInserted.ToString());
                        }

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

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