Beispiel #1
0
        private static void DespliegueControladoDeErroresHiloPrincipal(object sender, ThreadExceptionEventArgs e)
        {
            //MessageBox.Show($"Ha ocurrido un error:{e.Exception.Message}{System.Environment.NewLine}Origen del error:{e.Exception.Source}");
            var frmError = new FrmError(e.Exception);

            frmError.ShowDialog();
        }
        private void btnDeleteDepartment_Click(object sender, EventArgs e)
        {
            try
            {
                if (tableDepartment.SelectedRows.Count > 0)
                {
                    DialogResult dialogResult = new DialogResult();
                    FrmError     frmMessage   = new FrmError("ELIMINAR ESTE REGISTRO?");
                    dialogResult = frmMessage.ShowDialog();

                    if (dialogResult == DialogResult.OK)
                    {
                        //llenamos los campos
                        objEntity.IdDepartment = Convert.ToInt32(tableDepartment.CurrentRow.Cells[1].Value.ToString());
                        objBusiness.DeleteDepartment(objEntity);

                        FrmSuccess.mensajeConfirmacion("REGISTRO ELIMINADO");

                        //actualizamos la tabla
                        ShowDepartments("");
                    }
                }
                else
                {
                    MessageBox.Show("Seleccione el departamento a eliminar!! ", "Algo no anda bien");
                }
            }
            catch (Exception erro)
            {
                MessageBox.Show("Seleccione el departamento a eliminar!! ", " Algo no anda bien" + erro.Message);
            }
        }
Beispiel #3
0
        private static void DespliegueControladoDeErroresOtroshilos(object sender, UnhandledExceptionEventArgs args)
        {
            Exception excepcion = (Exception)args.ExceptionObject;
            //MessageBox.Show($"Ha ocurrido un error:{e.Message}{System.Environment.NewLine}Origen del error:{e.Source}");
            var frmError = new FrmError(excepcion);

            frmError.ShowDialog();
        }
Beispiel #4
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         string respuesta = "";
         //================== INSERTAR ===========================
         if (txtidMarca.Text == "")
         {
             if (txtNombre.Text == string.Empty)
             {
                 Error.SetError(txtNombre, "Ingresa un nombre");
             }
             else
             {
                 respuesta = NMarcas.Insertar(txtNombre.Text.Trim(), txtDescripcion.Text.Trim());
                 if (respuesta.Equals("OK"))
                 {
                     this.Alert("Guardado exitosamente", FrmAlert.alertTypeEnum.Success);
                     this.Limpiar();
                     this.Listar();
                 }
                 else
                 {
                     FrmError.Confirmacion("Error", "Algo salió mal");
                 }
             }
         }
         //======================== ACTUALIZAR ========================
         else
         {
             if (txtNombre.Text == string.Empty)
             {
                 Error.SetError(txtNombre, "Ingresa un nombre");
             }
             else
             {
                 respuesta = NMarcas.Actualizar(Convert.ToInt32(txtidMarca.Text), txtNombre.Text.Trim(), this.nombreAnt, txtDescripcion.Text.Trim());
                 if (respuesta.Equals("OK"))
                 {
                     this.Alert("Actualizado exitosamente", FrmAlert.alertTypeEnum.Success);
                     this.Limpiar();
                     this.Listar();
                 }
                 else
                 {
                     FrmError.Confirmacion("Error", respuesta);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Beispiel #5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (ckSeleccionar.Checked)
            {
                try
                {
                    DialogResult Opcion  = new DialogResult();
                    Form         mensaje = new FrmQuestionSuccess("¿Esta seguro de eliminar la(s) marcas seleccionadas?");
                    Opcion = mensaje.ShowDialog();
                    if (Opcion == DialogResult.OK)
                    {
                        int    codigo;
                        string respuesta = "";

                        foreach (DataGridViewRow row in DgMarcas.Rows)
                        {
                            if (Convert.ToBoolean(row.Cells[0].Value))
                            {
                                codigo    = Convert.ToInt32(row.Cells[1].Value);
                                respuesta = NMarcas.Eliminar(codigo);

                                if (respuesta.Equals("OK"))
                                {
                                    this.Alert("Marca: " + Convert.ToString(row.Cells[2].Value) + " eliminada", FrmAlert.alertTypeEnum.Error);
                                }
                                else
                                {
                                    FrmError.Confirmacion("Error", respuesta);
                                }
                            }
                        }
                        this.Listar();
                        this.Formato();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.StackTrace);
                }
            }
            else
            {
                FrmError.Confirmacion("Error", "No haz seleccionado ninguna marca");
            }
        }
Beispiel #6
0
 private void DgMarcas_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         this.Limpiar();
         txtidMarca.Text          = Convert.ToString(DgMarcas.CurrentRow.Cells[1].Value);
         this.nombreAnt           = Convert.ToString(DgMarcas.CurrentRow.Cells[2].Value);
         txtNombre.Text           = Convert.ToString(DgMarcas.CurrentRow.Cells[2].Value);
         txtDescripcion.Text      = Convert.ToString(DgMarcas.CurrentRow.Cells[3].Value);
         txtNombre.Enabled        = true;
         txtDescripcion.Enabled   = true;
         txtNombre.BaseColor      = Color.White;
         txtDescripcion.BaseColor = Color.White;
     }
     catch (Exception)
     {
         FrmError.Confirmacion("Error", "Seleccione desde la celda nombre.");
     }
 }
Beispiel #7
0
        //evento-metodo- que se encarga de enviar la venta para el insert a la base de datos
        private void pbApplySale_Click(object sender, EventArgs e)
        {
            //realizamos la instancia de nuestra entidad y nuetro negocio.
            N_Sales         applySale         = new N_Sales();
            N_SalesConcepts applySaleConcepts = new N_SalesConcepts();
            E_Sales         entitySale        = new E_Sales();
            E_SalesConcepts entitySaleConcept;

            try
            {
                string noNumber = txtIdCliente.Text;
                int    number   = 0;
                //si el cliente no existe en la venta le agregamos un valor por defecto a nuestro cliente
                //validamos de que la cadena sea un numero
                if (!int.TryParse(noNumber, out number))
                {
                    txtIdCliente.Text = "1003";
                }
                //validamos de que el datagridview(tabla) tenga datos.
                if (dgvTableSales.Rows.Count == 0)
                {
                    txtQuantityToSell.Focus();
                    lblCodeProduct.Text      = "CODIGO PRODUCTO";
                    lblCodeProduct.ForeColor = Color.DarkGray;
                    return;
                }

                //le pasamos los valores a nuestra entidad
                entitySale.IdUser     = SessionUsers.IdUser;
                entitySale.IdClient   = Int32.Parse(txtIdCliente.Text);
                entitySale.Total      = decimal.Parse(txtTotalToPay.Text);
                entitySale.DateOfSale = DateTime.Now;

                //realizamos el envio de los datos para la insercion a la base de datos
                int idSale = applySale.GenerarateSalesInsert(entitySale);


                //si el insert se realiza exitosamente en la tabla ventas
                //se realizara el segundo insert a la tabla detalle de venta.
                if (idSale > 0)

                {
                    //creamos la lista que contendra nuestra entidad E_SalesConcepts
                    List <E_SalesConcepts> list_SalesConcepts = new List <E_SalesConcepts>();
                    //creamos un ciclo para recorrer cada celda de la tabla(datagridview sales)
                    foreach (DataGridViewRow rows in dgvTableSales.Rows)
                    {
                        //creamos el objeto
                        entitySaleConcept = new E_SalesConcepts();

                        //el tomamos el ultimo id insertado
                        entitySaleConcept.IdSale = idSale;
                        //buscamos en la celda a utilizar para el id del producto
                        entitySaleConcept.IdProduct = Int32.Parse(rows.Cells[6].Value.ToString());
                        //buscamos en la celda a utilizar para el precio del producto
                        entitySaleConcept.SalePrice = decimal.Parse(rows.Cells[4].Value.ToString());
                        //buscamos en la celda a utilizar para el total del producto.
                        entitySaleConcept.Amount = Int32.Parse(rows.Cells[2].Value.ToString());
                        //llenamos la lista con nuestra entidad
                        list_SalesConcepts.Add(entitySaleConcept);
                    }
                    //realizamos el segundo insert
                    //insert a la tabla detalle de venta

                    if (list_SalesConcepts.Count > 0)
                    {
                        applySaleConcepts.GenerarateSaleConceptInsert(list_SalesConcepts);
                        //else error
                    }

                    //venta exitosa
                    formSuccess = new FrmSuccess("Venta Exitosa!");
                    formSuccess.ShowDialog();
                    //luego de completar la venta limpiamos la tabla venta.
                    //dgvTableSales.DataSource = "";
                    dgvTableSales.Columns.Clear();
                    CalculateTotal();

                    //limpiamos todos los campos de la venta
                    searchDNI.Text          = "";
                    lblCustomer.Text        = "Cliente al contado";
                    lblAddressCustomer.Text = "Direccion Del Cliente";
                }
                else
                {
                    formErro = new FrmError("Error en la venta.");
                    formErro.ShowDialog();
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("algo no anda bien..." + ex);
            }
        }
Beispiel #8
0
        public static object GetDataSourceStatic(IPagedList <Education_Agent> staticlistPaged)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                object dataSource = staticlistPaged.Select(o => new MyColumnCollectionDGAgentCertification(o)
                {
                    Agent_Matricule        = o.Agent_Matricule,
                    Agent_Fullname         = o.Agent_FullName,
                    Agent_FirstName        = o.Agent_FirstName,
                    Agent_Name             = o.Agent_Name,
                    Agent_Departement      = o.Education_Service.Education_Departement.Departement_Name == null ? null : o.Education_Service.Education_Departement.Departement_Name,
                    Agent_Service          = o.Education_Service.Service_Name,
                    Agent_SousService      = o.Education_SousService.SousService_Name == null ? null : o.Education_SousService.SousService_Name,
                    Agent_Etat             = o.Agent_Etat,
                    Agent_EntryDate        = o.Agent_DateOfEntry,
                    Agent_LastFunctionDate = o.Agent_DateFunction,
                    Agent_Statut           = o.Education_AgentStatus.AgentStatus_Name == null ? null : o.Education_AgentStatus.AgentStatus_Name,
                    Agent_Fonction         = o.Education_Function.Function_Name == null ? null : o.Education_Function.Function_Name,
                    Agent_Admin            = o.Agent_Admin,



                    //Passport Safety
                    PassportSafety_LevelPS = o.Education_AgentPassportSafety == null ? null : o.Education_AgentPassportSafety.FirstOrDefault().AgentPassportSafety_LevelPS,
                    Certif_Hierarchie      = o.Education_AgentPassportSafety == null ? null : o.Education_AgentPassportSafety.FirstOrDefault().AgentPassportSafety_HierarchyCertification,
                    SendingDate            = o.Education_AgentPassportSafety == null ? null : o.Education_AgentPassportSafety.FirstOrDefault().AgentPassportSafety_SendingDate,
                    ReturnDate             = o.Education_AgentPassportSafety == null ? null : o.Education_AgentPassportSafety.FirstOrDefault().AgentPassportSafety_ReturnDate,
                    PassportRemarks        = o.Education_AgentPassportSafety == null ? null : o.Education_AgentPassportSafety.FirstOrDefault().AgentPassportSafety_Remarks,
                    PassportRemarkPay      = o.Education_AgentPassportSafety == null ? null : o.Education_AgentPassportSafety.FirstOrDefault().AgentPassportSafety_PayRemarks,

                    //Passport Business

                    Description = o.Education_AgentPassportBusiness == null ? null : o.Education_AgentPassportBusiness.FirstOrDefault().Education_PassportBusiness.PassportBusiness_Name,
                    SendingDatePassportBusiness       = o.Education_AgentPassportBusiness == null ? null : o.Education_AgentPassportBusiness.FirstOrDefault().AgentPassportBusiness_SendingDate,
                    ReturnDatePassportBusiness        = o.Education_AgentPassportBusiness == null ? null : o.Education_AgentPassportBusiness.FirstOrDefault().AgentPassportBusiness_ReturnDate,
                    Certif_HierarchiePassportBusiness = o.Education_AgentPassportBusiness == null ? null : o.Education_AgentPassportBusiness.FirstOrDefault().AgentPassportBusiness_HierarchyCertification,
                    PassportRemarksPassportBusiness   = o.Education_AgentPassportBusiness == null ? null : o.Education_AgentPassportBusiness.FirstOrDefault().AgentPassportBusiness_Remark,


                    //Certification Electrique Role Function

                    NiveauB = o.Education_AgentCertifElecFunc == null ? null : o.Education_AgentCertifElecFunc.FirstOrDefault().Education_CertifElecFunc.CertifElecFunc_LevelB,
                    SendingDateCertifElecFunc       = o.Education_AgentCertifElecFunc == null ? null : o.Education_AgentCertifElecFunc.FirstOrDefault().AgentCertifElecFunc_SendingDate,
                    ReturnDateCertifElecFunc        = o.Education_AgentCertifElecFunc == null ? null : o.Education_AgentCertifElecFunc.FirstOrDefault().AgentCertifElecFunc_ReceivedDate,
                    Certif_HierarchieCertifElecFunc = o.Education_AgentCertifElecFunc == null ? null : o.Education_AgentCertifElecFunc.FirstOrDefault().AgentCertifElecFunc_IsCertified,
                    ValidityDateCertifElecFunc      = o.Education_AgentCertifElecFunc == null ? null : o.Education_AgentCertifElecFunc.FirstOrDefault().AgentCertifElecFunc_ValidityDate,
                    RemarksCertifElecFunc           = o.Education_AgentCertifElecFunc == null ? null : o.Education_AgentCertifElecFunc.FirstOrDefault().AgentCertifElecFunc_Remark,

                    //Certification Electrique Role OPP

                    NiveauR = o.Education_AgentCertifElecOPP.FirstOrDefault().Education_CertifElecOPP == null ? null : o.Education_AgentCertifElecOPP.FirstOrDefault().Education_CertifElecOPP.CertifElecOPP_LevelR,
                    SendingDateCertifElecOPP       = o.Education_AgentCertifElecOPP == null ? null : o.Education_AgentCertifElecOPP.FirstOrDefault().AgentCertifElecOPP_SendingDate,
                    ReturnDateCertifElecOPP        = o.Education_AgentCertifElecOPP == null ? null : o.Education_AgentCertifElecOPP.FirstOrDefault().AgentCertifElecOPP_ReceivedDate,
                    Certif_HierarchieCertifElecOPP = o.Education_AgentCertifElecOPP == null ? null : o.Education_AgentCertifElecOPP.FirstOrDefault().AgentCertifElecOPP_IsCertified,
                    ValidityDateCertifElecOPP      = o.Education_AgentCertifElecOPP == null ? null : o.Education_AgentCertifElecOPP.FirstOrDefault().AgentCertifElecOPP_ValidityDate,
                    RemarksCertifElecOPP           = o.Education_AgentCertifElecOPP == null ? null : o.Education_AgentCertifElecOPP.FirstOrDefault().AgentCertifElecOPP_Remark,

                    //Passport Design

                    TypePAssport = o.Education_AgentPassportDesign == null ? null : o.Education_AgentPassportDesign.FirstOrDefault().Education_PassportDesign.PassportDesign_Name,
                    SendingDatePassportDesign       = o.Education_AgentPassportDesign == null ? null : o.Education_AgentPassportDesign.FirstOrDefault().AgentPassportDesign_SendingDate,
                    ReturnDatePassportDesign        = o.Education_AgentPassportDesign == null ? null : o.Education_AgentPassportDesign.FirstOrDefault().AgentPassportDesign_ReceivedDate,
                    Certif_HierarchiePassportDesign = o.Education_AgentPassportDesign == null ? null : o.Education_AgentPassportDesign.FirstOrDefault().AgentPassportDesign_IsCertified,
                    RemarksPassportDesign           = o.Education_AgentPassportDesign == null ? null : o.Education_AgentPassportDesign.FirstOrDefault().AgentPassportDesign_Remark,
                }).ToList();


                return(dataSource);
            }
            catch (Exception ex)
            {
                FrmError frmError = new FrmError(ex.Message, ex.StackTrace);
                frmError.ShowDialog();
                return(null);
            }
        }