Beispiel #1
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (VerificarDatos())
                {
                    SBDAEGESEntities _Mod  = new SBDAEGESEntities(); //eges
                    SBDARSCEntities  _ModR = new SBDARSCEntities();  //rsc

                    USR_ConceptoSubCuenta _con = new USR_ConceptoSubCuenta();

                    _con.concepto  = _codigoConc;
                    _con.subCuenta = Convert.ToInt32(comboBoxSubCuenta.SelectedValue);

                    if (comboBoxSubCuenta.SelectedIndex == 0)
                    {
                        DialogResult _result = MessageBox.Show("No seleccionó ninguna sub cuenta a este concepto, desea continuar de todos modos ?", "Mensaje", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                        if (_result == System.Windows.Forms.DialogResult.OK)
                        {
                            _con.subCuenta = 0;
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (_idSubCuenta == 0) //ESTOY ASOCIANDO UN NUEVO CONCEPTO A UNA SUBCUENTA
                    {
                        if (Clases.Usuario.EmpresaLogeada.EmpresaIngresada.Trim() == "EGES")
                        {
                            _Mod.USR_ConceptoSubCuenta.Add(_con);

                            _Mod.SaveChanges();
                        }
                        else
                        {
                            _ModR.USR_ConceptoSubCuenta.Add(_con);

                            _ModR.SaveChanges();
                        }
                    }
                    else //ESTOY ACTUALIZANBDO UN CONCEPTO CON UNA NUEVA CUENTA..
                    {
                        _con.Id = _idSubCuenta;

                        if (Clases.Usuario.EmpresaLogeada.EmpresaIngresada.Trim() == "EGES")
                        {
                            _Mod.Entry(_con).State = System.Data.Entity.EntityState.Modified;

                            _Mod.SaveChanges();
                        }
                        else
                        {
                            _ModR.Entry(_con).State = System.Data.Entity.EntityState.Modified;

                            _ModR.SaveChanges();
                        }
                    }

                    MessageBox.Show("La Operación se realizó correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CargarConceptos();
                    _idSubCuenta = 0;
                    _codigoConc  = string.Empty;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxDescripSub.Text != string.Empty)
                {
                    SBDAEGESEntities _Mod = new SBDAEGESEntities();

                    SBDARSCEntities _ModRsc = new SBDARSCEntities();



                    USR_ArticuloSubCuenta _sub = new USR_ArticuloSubCuenta
                    {
                        Descripcion = textBoxDescripSub.Text,
                        //esDeProducto = true
                    }; //TABLA EGES


                    if (_cuentaId == 0)
                    {
                        _Mod.USR_ArticuloSubCuenta.Add(_sub);

                        _Mod.SaveChanges();

                        //ahora grabo en tabla de RSCÇ
                        _ModRsc.USR_ArticuloSubCuenta.Add(_sub);

                        _ModRsc.SaveChanges();


                        textBoxDescripSub.Text = string.Empty;
                        _cuentaId = 0;
                        TraeSubCuentas();
                        MessageBox.Show("Sub Cuenta creada correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    else
                    {
                        _sub.subCuenta         = _cuentaId;
                        _Mod.Entry(_sub).State = System.Data.Entity.EntityState.Modified;

                        _Mod.SaveChanges();

                        //ACTUALIZO EN TABLA RSCÇ
                        _sub.subCuenta            = _cuentaId;
                        _ModRsc.Entry(_sub).State = System.Data.Entity.EntityState.Modified;

                        _ModRsc.SaveChanges();

                        textBoxDescripSub.Text = string.Empty;
                        _cuentaId = 0;
                        TraeSubCuentas();
                        MessageBox.Show("Sub Cuenta actualizada correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Debe ingresar una descripción", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }