예제 #1
0
        private void CargarUsuario(string co_usuario, Profit_RGEntities context)
        {
            var Usuario = context.pSeleccionarUsuario(co_usuario).FirstOrDefault();

            Validador                = Usuario.validador;
            txtCo_usuario.Text       = Usuario.co_usuario.Trim();
            cbo_profit.SelectedValue = Usuario.co_profit;
            txtNombre.Text           = Usuario.nombre.Trim();
            txtClave.Text            = MC.GetString(Usuario.clave).ToString();
            txtClaveR.Text           = MC.GetString(Usuario.clave).ToString();
            cboNivel.SelectedIndex   = Usuario.tipo;
            txtRdv.Text              = Usuario.co_rdv.Trim();
            cbo_department.Text      = Usuario.Departamento;
            chkP_emp.CheckState      = Usuario.p_emp == -1 ? CheckState.Unchecked : Usuario.p_emp == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_nav.CheckState      = Usuario.p_nav == -1 ? CheckState.Unchecked : Usuario.p_nav == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_usu.CheckState      = Usuario.p_usu == -1 ? CheckState.Unchecked : Usuario.p_usu == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_con.CheckState      = Usuario.p_con == -1 ? CheckState.Unchecked : Usuario.p_con == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_emp.CheckState      = Usuario.p_emp == -1 ? CheckState.Unchecked : Usuario.p_emp == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_mco.CheckState      = Usuario.p_mco == -1 ? CheckState.Unchecked : Usuario.p_mco == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_pst.CheckState      = Usuario.p_pst == -1 ? CheckState.Unchecked : Usuario.p_pst == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_art.CheckState      = Usuario.p_art == -1 ? CheckState.Unchecked : Usuario.p_art == 0 ? CheckState.Indeterminate : CheckState.Checked;
            ChkP_clave.CheckState    = Usuario.p_clave == -1 ? CheckState.Unchecked : Usuario.p_clave == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_malm.CheckState     = Usuario.p_malm == -1 ? CheckState.Unchecked : Usuario.p_malm == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_ord.CheckState      = Usuario.p_ord == -1 ? CheckState.Unchecked : Usuario.p_ord == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_pped.CheckState     = Usuario.p_pped == -1 ? CheckState.Unchecked : Usuario.p_pped == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_cxc.CheckState      = Usuario.p_cxc == -1 ? CheckState.Unchecked : Usuario.p_cxc == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_RegRep.CheckState   = Usuario.p_regrep == -1 ? CheckState.Unchecked : Usuario.p_regrep == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_EnvRep.CheckState   = Usuario.p_envrep == -1 ? CheckState.Unchecked : Usuario.p_envrep == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_Rep.CheckState      = Usuario.p_rep == -1 ? CheckState.Unchecked : Usuario.p_rep == 0 ? CheckState.Indeterminate : CheckState.Checked;
            ChkP_lcre.CheckState     = Usuario.p_lcre == -1 ? CheckState.Unchecked : Usuario.p_lcre == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_com.CheckState      = Usuario.p_com == -1 ? CheckState.Unchecked : Usuario.p_com == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_metas.CheckState    = Usuario.p_metas == -1 ? CheckState.Unchecked : Usuario.p_metas == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_ubi.CheckState      = Usuario.p_ubi == -1 ? CheckState.Unchecked : Usuario.p_ubi == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_consu.CheckState    = Usuario.p_cons == -1 ? CheckState.Unchecked : Usuario.p_cons == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_camp_L.CheckState   = Usuario.p_camp_L == -1 ? CheckState.Unchecked : Usuario.p_camp_L == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_acti.CheckState     = Usuario.p_acti == -1 ? CheckState.Unchecked : Usuario.p_acti == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_consum.CheckState   = Usuario.p_consu == -1 ? CheckState.Unchecked : Usuario.p_consu == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkP_caso.CheckState     = Usuario.p_caso == -1 ? CheckState.Unchecked : Usuario.p_caso == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chkJcontrol.CheckState   = Usuario.p_control == -1 ? CheckState.Unchecked : Usuario.p_control == 0 ? CheckState.Indeterminate : CheckState.Checked;
            chksupervi.CheckState    = Usuario.p_supervi == -1 ? CheckState.Unchecked : Usuario.p_supervi == 0 ? CheckState.Indeterminate : CheckState.Checked;
        }
예제 #2
0
 private void Buscar()
 {
     try
     {
         Nuevo = false;
         using (Profit_RGEntities context = new Profit_RGEntities())
         {
             pSeleccionarEmpresa_Result empresa = new pSeleccionarEmpresa_Result();
             var pemp = context.Empresas.Where(em => em.co_empresa == txtBuscar.Text.Trim()).ToList();
             if (pemp.Count > 0)
             {
                 empresa            = context.pSeleccionarEmpresa(pemp[0].co_empresa.Trim().ToUpper()).First();
                 txtCo_empresa.Text = empresa.co_empresa.Trim();
                 txtDes_emp.Text    = empresa.des_emp.Trim();
                 txtEmail.Text      = empresa.email.Trim();
                 txtClave.Text      = MC.GetString(empresa.clave).Trim();
                 txtServidor.Text   = empresa.servidor.Trim();
                 txtPuerto.Value    = empresa.puerto;
                 OptSSL.CheckState  = empresa.ssl == 1 ? CheckState.Checked : CheckState.Unchecked;
                 Validador          = empresa.validador;
                 txtBuscar.Text     = "";
                 txtCo_empresa.Focus();
             }
             else
             {
                 MessageBox.Show("El registro no existe", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtBuscar.Focus();
             }
         }
     }
     catch (EntityException ex)
     {
         MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex1)
     {
         MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (superValidator1.Validate() == true)
                {
                    using (Profit_RGEntities context = new Profit_RGEntities())
                    {
                        var  i          = 0;
                        bool Encontrado = false;
                        while (i <= lstAvatar.Items.Count && Encontrado == false)
                        {
                            if (lstAvatar.Items[i].Selected == true)
                            {
                                avatar     = imageList1.Images[i];
                                Encontrado = true;
                            }
                            i++;
                        }
                        if (Encontrado == false)
                        {
                            MessageBox.Show("Debe seleccionar un imagen de Usuario!", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                        else
                        {
                            if (Nuevo == true)
                            {
                                context.pInsertarUsuario(txtCo_usuario.Text.Trim(), txtNombre.Text.Trim(), cboNivel.SelectedIndex,
                                                         MC.GetBytes(txtClaveR.Text.Trim()), txtRdv.Text.Trim(), ImagenBD.ImagenToByte(avatar),
                                                         P_nav, P_emp, P_con, P_mco, P_usu, P_pst, P_art, P_clave, P_malm, P_ord, P_pped, P_cxc,
                                                         P_regrep, P_envrep, P_rep, P_lcre, P_com, P_metas, P_ubi, P_cons, P_camp_L, P_acti, P_cons,
                                                         P_caso, cbo_profit.SelectedValue.ToString(), P_control, P_supervi, cbo_department.SelectedIndex.ToString(), 0);
                            }
                            else
                            {
                                context.pActualizarUsuarios(txtCo_usuario.Text.Trim(), txtNombre.Text.Trim(), cboNivel.SelectedIndex,
                                                            txtRdv.Text.Trim(), MC.GetBytes(txtClaveR.Text.Trim()), ImagenBD.ImagenToByte(avatar), Validador,
                                                            P_nav, P_emp, P_con, P_mco, P_usu, P_pst, P_art, P_clave, P_malm, P_ord, P_pped, P_cxc,
                                                            P_regrep, P_envrep, P_rep, P_lcre, P_com, P_metas, P_ubi, P_cons, P_camp_L, P_acti, P_cons,
                                                            P_caso, cbo_profit.SelectedValue.ToString(), P_control, P_supervi, cbo_department.SelectedIndex.ToString(), 0);
                            }
                            context.pEliminarUsu_Emp(txtCo_usuario.Text.Trim());
                            foreach (var item in LempresaCA)
                            {
                                context.pInsertarUsu_Emp(txtCo_usuario.Text.Trim(), item.Co_empresa);
                            }
                        }
                    }
                    Navegar(5);
                    FrmPrincipal Fp = new FrmPrincipal();
                    Fp.HabilitarBotones(txtCo_usuario.Text.Trim());

                    MessageBox.Show(this, "Se ha guardado la informacion satisfactoriamente.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (EntityException ex)
            {
                MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (Nuevo == true)
         {
             if (superValidator1.Validate() == true)
             {
                 using (Profit_RGEntities context = new Profit_RGEntities())
                 {
                     context.pInsertarEmpresa(txtCo_empresa.Text.Trim(), txtDes_emp.Text.Trim(), txtEmail.Text.Trim(),
                                              txtServidor.Text.Trim(), txtPuerto.Value, OptSSL.CheckState == CheckState.Checked ? 1 : 0, MC.GetBytes(txtClave.Text.Trim()));
                 }
                 Navegar(5);
             }
         }
         else
         {
             if (superValidator1.Validate() == true)
             {
                 using (Profit_RGEntities context = new Profit_RGEntities())
                 {
                     context.pActualizarEmpresa(txtCo_empresa.Text.Trim(), txtDes_emp.Text.Trim(), txtEmail.Text.Trim(), MC.GetBytes(txtClave.Text.Trim()),
                                                txtServidor.Text.Trim(), txtPuerto.Value, OptSSL.CheckState == CheckState.Checked ? 1 : 0, Validador);
                 }
                 Navegar(5);
             }
         }
     }
     catch (EntityException ex)
     {
         MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex1)
     {
         MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #5
0
        private void Navegar(int p)
        {
            try
            {
                Nuevo = false;
                using (Profit_RGEntities context = new Profit_RGEntities())
                {
                    pSeleccionarEmpresa_Result empresa = new pSeleccionarEmpresa_Result();
                    var pemp = context.pObtenerTablaStr(txtCo_empresa.Text.Trim(), "co_empresa", p, "Empresas").ToList();
                    if (pemp.Count > 0)
                    {
                        empresa            = context.pSeleccionarEmpresa(pemp[0].Trim()).FirstOrDefault();
                        txtCo_empresa.Text = empresa.co_empresa.Trim();
                        txtDes_emp.Text    = empresa.des_emp.Trim();
                        txtEmail.Text      = empresa.email.Trim();
                        txtClave.Text      = MC.GetString(empresa.clave).Trim();
                        txtServidor.Text   = empresa.servidor.Trim();
                        txtPuerto.Value    = empresa.puerto;
                        OptSSL.CheckState  = empresa.ssl == 1 ? CheckState.Checked : CheckState.Unchecked;
                        txtAlma.Text       = empresa.almacen.Trim();
                        txtCo_moneda.Text  = empresa.moneda.Trim();
                        txtFpago.Text      = empresa.forma_pag.Trim();
                        txtCo_tran.Text    = empresa.co_tran.Trim();
                        txtCo_sucu.Text    = empresa.co_sucu.Trim();
                        txtNomina.Text     = empresa.nomina == null ? "" : empresa.nomina.Trim();
                        txtContab.Text     = empresa.contab == null ? "" : empresa.contab.Trim();


                        pSeleccionarAlmacenEmpresa_Result a = context.pSeleccionarAlmacenEmpresa(txtAlma.Text.Trim(), txtCo_empresa.Text.Trim()).FirstOrDefault();
                        txtAlm_des.Text = a == null ? "NO ENCONTRADO" : a.alm_des.Trim();

                        pSeleccionarFormaPago_Result b = context.pSeleccionarFormaPago(txtCo_empresa.Text.Trim(), txtFpago.Text.Trim()).FirstOrDefault();
                        txtFpDescrip.Text = b == null ? "NO ENCONTRADO" : b.cond_des.Trim();

                        pSeleccionarMoneda_Result c = context.pSeleccionarMoneda(txtCo_empresa.Text.Trim(), txtCo_moneda.Text.Trim()).FirstOrDefault();
                        txtMoneda.Text = c == null ? "NO ENCONTRADO" : c.mone_des.Trim();

                        pSeleccionarTransporte_Result d = context.pSeleccionarTransporte(txtCo_empresa.Text.Trim(), txtCo_tran.Text.Trim()).FirstOrDefault();
                        txtDes_tran.Text = d == null ? "NO ENCONTRADO" : d.des_tran.Trim();

                        pSeleccionarSucursal_Result f = context.pSeleccionarSucursal(txtCo_empresa.Text.Trim(), txtCo_sucu.Text.Trim()).FirstOrDefault();
                        txtSucursal.Text = f == null ? "NO ENCONTRADO" : f.sucu_des.Trim();

                        Validador = empresa.validador;
                    }
                    else
                    {
                        if (empresa.validador != null)
                        {
                            LimpiarControles();
                        }
                        else
                        {
                            Validador = null;
                        }
                    }
                }
            }
            catch (EntityException ex)
            {
                MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #6
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (Nuevo == true)
         {
             if (superValidator1.Validate() == true)
             {
                 using (Profit_RGEntities context = new Profit_RGEntities())
                 {
                     context.pInsertarEmpresa(txtCo_empresa.Text.Trim(), txtDes_emp.Text.Trim(), txtEmail.Text.Trim(),
                                              txtServidor.Text.Trim(), txtPuerto.Value, OptSSL.CheckState == CheckState.Checked ? 1 : 0,
                                              MC.GetBytes(txtClave.Text.Trim()),
                                              txtAlma.Text.Trim(),
                                              txtCo_tran.Text.Trim(),
                                              txtFpago.Text.Trim(),
                                              txtCo_moneda.Text.Trim(),
                                              txtCo_sucu.Text.Trim(),
                                              txtNomina.Text.Trim(),
                                              txtContab.Text.Trim());
                 }
                 Navegar(5);
             }
         }
         else
         {
             if (superValidator1.Validate() == true)
             {
                 using (Profit_RGEntities context = new Profit_RGEntities())
                 {
                     context.pActualizarEmpresa(txtCo_empresa.Text.Trim(), txtDes_emp.Text.Trim(), txtEmail.Text.Trim(), MC.GetBytes(txtClave.Text.Trim()),
                                                txtServidor.Text.Trim(), txtPuerto.Value, OptSSL.CheckState == CheckState.Checked ? 1 : 0,
                                                txtAlma.Text.Trim(), Validador,
                                                txtCo_tran.Text.Trim(),
                                                txtFpago.Text.Trim(),
                                                txtCo_moneda.Text.Trim(),
                                                txtCo_sucu.Text.Trim(),
                                                txtNomina.Text.Trim(),
                                                txtContab.Text.Trim());
                 }
                 Navegar(5);
             }
         }
         MessageBox.Show(this, "Se ha guardado la informacion satisfactoriamente.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (EntityException ex)
     {
         MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex1)
     {
         MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }