예제 #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (superValidator1.Validate() == true)
                {
                    using (Profit_RGEntities context = new Profit_RGEntities())
                    {
                        Image avatar     = null;
                        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);
                            }
                            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);
                            }

                            context.pEliminarUsu_Emp(txtCo_usuario.Text.Trim());
                            foreach (var item in LempresaCA)
                            {
                                context.pInsertarUsu_Emp(txtCo_usuario.Text.Trim(), item.Co_empresa);
                            }
                        }
                    }
                    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);
            }
        }
예제 #2
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);
     }
 }
예제 #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);
     }
 }