예제 #1
0
 public SampleDesign(PROYECTO project,TSTUDENT tStudent, List<SampleDesignItem> data, double sizeSample, double sizePopulation,int sampleDesignType)
 {
     this.project = project;
     this.data = data;
     this.sizePopulation = sizePopulation;
     this.sizeSample = sizeSample;
     this.sampleDesignType = sampleDesignType;
     this.tStudent = tStudent;
 }
예제 #2
0
        public void InsertTStudent(TSTUDENT TStudent)
        {
            try
            {
                this.sifcaRepository.TSTUDENT.Add(TStudent);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
 public void UpdateTStudent(TSTUDENT TStudent)
 {
     try
     {
         this.sifcaRepository.Entry(TStudent).State = EntityState.Modified;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        public void loadTestStudent(ProgressBar bar)
        {
            try
            {
                bar.Visible = true;
                OpenFileDialog fichero = new OpenFileDialog();
                fichero.Filter = "Excel (*.xls)|*.xls;*.xlsx";
                bar.Visible = true;

                ProjectBL pyBl = new ProjectBL(Program.ContextData);
                FormBL formBl = new FormBL(Program.ContextData);
                InventoryLineBL lineInvBl = new InventoryLineBL(Program.ContextData);
                listStratumsAdded = new ArrayList();

                if (fichero.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {

                        excel.Application aplicacion;
                        excel.Workbook libros_trabajo;
                        excel.Worksheet hojas_trabajo;
                        excel.Range exlRange;
                        aplicacion = new excel.Application();

                        //Asignamos el libro que sera abierot
                        libros_trabajo = aplicacion.Workbooks.Open(fichero.FileName, 0, true, 5, "", "", true, excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

                        hojas_trabajo = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(1);
                        exlRange = hojas_trabajo.UsedRange;
                        //Recorremos el archivo excel como si fuera una matriz
                        //leemos las especies que se encuentran en la hoja
                        TStudentBL tStudentBL = new TStudentBL(Program.ContextData);
                        bar.Maximum = exlRange.Rows.Count;
                        bar.Value = 0;
                        string n = "", alpha = "", valor = "";
                        for (int i = 2; i <= exlRange.Rows.Count; i++)
                        {
                            TSTUDENT tableTstudent = new TSTUDENT();
                            n = (exlRange.Cells[i, 1] as excel.Range).Value + "";
                            alpha = (exlRange.Cells[i, 2] as excel.Range).Value + "";
                            valor = (exlRange.Cells[i, 3] as excel.Range).Value + "";

                            tableTstudent.N = int.Parse(n);
                            tableTstudent.ALPHA = decimal.Parse(alpha);
                            tableTstudent.VALOR = decimal.Parse(valor);
                            tStudentBL.InsertTStudent(tableTstudent);
                            string result = tStudentBL.SaveChanges();
                            if (result != "")
                            {
                                if (!result.Equals(""))
                                {
                                    Error_Form errorForm = new Error_Form(result);
                                    errorForm.MdiParent = (Form)bar.Parent.Parent;
                                    errorForm.Show();
                                    return;
                                }
                            }
                            bar.Increment(1);
                        }
                        MessageBox.Show("Los datos se cargaron correctamente.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                }
                bar.Visible = false;
            }
            catch (Exception ex)
            {
                Error_Form errorForm = new Error_Form(ex.Message);
                errorForm.MdiParent = (Form)bar.Parent.Parent;
                errorForm.Show();
                bar.Visible = false;
            }
        }
예제 #5
0
        /// <summary>
        /// Capturamos el click que se de en el alguna de las opciones editar o eliminar y se procede con la accion
        /// si es modificar se redimensiona la ventana para cargar el panel de editar, si se va a eliminar se pide la 
        /// confirmacion del usuario y se procede a eliminar el registro
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Listado_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                //
                // Solo se trabaja ante los cambios en la columan de los checkbox
                //
                if (ListadoTStudent.Columns[e.ColumnIndex].Name == "Editar")
                {
                    //
                    // Se toma la fila seleccionada
                    //
                    DataGridViewRow row = ListadoTStudent.Rows[e.RowIndex];

                    //
                    // Se selecciona la celda del boton
                    //

                    Tst = new TSTUDENT();

                    Tst = TstBl.GetTStudent((Decimal)row.Cells[0].Value, (Decimal)row.Cells[1].Value);

                    updateN_txt.Text = Tst.N.ToString();
                    updateValor_txt.Text = Tst.VALOR.ToString();
                    updateAlpha_txt.Text = Tst.ALPHA.ToString();
                    pn_listado.Hide();
                    pn_crear.Hide();
                    pn_editar.Show();
                    this.Width = editarGbx.Width;
                    this.Height = editarGbx.Height;
                    this.CenterToScreen();
                }

                if (ListadoTStudent.Columns[e.ColumnIndex].Name == "Eliminar")
                {
                    //
                    // Se toma la fila seleccionada
                    //
                    DataGridViewRow row = ListadoTStudent.Rows[e.RowIndex];

                    //
                    // Se selecciona la celda del boton
                    //

                    Tst = new TSTUDENT();

                    Tst = TstBl.GetTStudent((Decimal)row.Cells[0].Value, (Decimal)row.Cells[1].Value);

                    DialogResult result = MessageBox.Show("Esta seguro de eliminar el registro", "Confirmar Eliminar", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                    // Process message box resultados
                    switch (result)
                    {
                        case DialogResult.OK:
                            TstBl.DeleteTStudent((Decimal)Tst.ALPHA, (Decimal)Tst.N);
                            string resultD = TstBl.SaveChanges();
                            if (resultD == "")
                            {
                                MessageBox.Show("Se elimino correctamente.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                Error_Form errorForm = new Error_Form(resultD);
                                errorForm.MdiParent = ParentForm;
                                errorForm.Show();
                            }
                            try
                            {
                                TStudentBSource.DataSource = TstBl.GetTStudents();
                                ListadoTStudent.Refresh();
                                pn_listado.Show();
                                pn_crear.Hide();
                                pn_editar.Hide();
                                break;
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }

                        case DialogResult.Cancel:
                            // User pressed Cancel button
                            // ...
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Error_Form errorForm = new Error_Form(ex.Message);
                errorForm.MdiParent = ParentForm;
                errorForm.Show();
            }
        }
예제 #6
0
        /// <summary>
        /// Funcion que valida que los campos del formulario crear no esten vacios si pasa las validaciones entonces se inserta 
        /// el nuevo registro y se alerta al usuario con un mensaje de exito, si ocurre un mensaje durante el proceso se notifica al usuario con un mensaje de mensaje
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Crear_Click(object sender, EventArgs e)
        {
            try
            {
                bool Error = false;
                decimal N = 0, VALOR = 0, ALPHA = 0;

                if (!decimal.TryParse(crearN_txt.Text.Replace('.', ','), out N) || crearN_txt.Text == "")
                {
                    Error = true;
                    eP_errors.SetError(crearN_txt, "Este campo es numérico y obligatorio");
                }
                if (!decimal.TryParse(crearValor_txt.Text.Replace('.', ','), out VALOR) || crearValor_txt.Text == "")
                {
                    Error = true;
                    eP_errors.SetError(crearValor_txt, "Este campo es numérico y obligatorio");
                }
                if (!decimal.TryParse(crearAlpha_txt.Text.Replace('.', ','), out ALPHA) || crearAlpha_txt.Text == "")
                {
                    Error = true;
                    eP_errors.SetError(crearAlpha_txt, "Este campo es numérico y obligatorio");
                }
                if (!Error)
                {
                    eP_errors.Clear();
                    try
                    {
                        Tst = new TSTUDENT();
                        Tst.N = N;
                        Tst.VALOR = VALOR;
                        Tst.ALPHA = ALPHA;
                        TstBl.InsertTStudent(Tst);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    string result = TstBl.SaveChanges();
                    if (result == "")
                    {
                        MessageBox.Show("Los datos fueron actualizados de manera exitosa.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        Error_Form errorForm = new Error_Form(result);
                        errorForm.MdiParent = ParentForm;
                        errorForm.Show();
                    }
                    TStudentBSource.DataSource = TstBl.GetTStudents();
                    ListadoTStudent.Refresh();
                    crearN_txt.Text = "";
                    pn_crear.Hide();
                    pn_listado.Show();
                    pn_editar.Hide();
                    this.Width = pn_listado.Width;
                    this.Height = pn_listado.Height;
                    this.CenterToScreen();

                }
            }
            catch (Exception ex)
            {
                Error_Form errorForm = new Error_Form(ex.Message);
                errorForm.MdiParent = ParentForm;
                errorForm.Show();
            }
        }