コード例 #1
0
        public void guardar()
        {
            if (UIID.Text == "")
            {
                try
                {
                    FAC_VENDEDOR m = new FAC_VENDEDOR
                    {
                        ID          = 0,
                        DS_VENDEDOR = UIDS_VENDEDOR.Text,
                        ID_EMPRESA  = _datasistema.empresa.ID,
                        DS_CORREO   = UIDS_CORREO.Text,
                        DS_TELEFONO = UIDS_TELEFONO.Text,
                        CD_VENDEDOR = UICD_VENDEDOR.Text
                    };
                    _datasistema.ContextoVentas.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
                    _datasistema.ContextoVentas.FAC_VENDEDOR.InsertOnSubmit(m);
                    _datasistema.ContextoVentas.SubmitChanges();
                    consultar();
                    MetodosForm.seleccionarFila(uigridview, "ID", m.ID);
                }
                catch (Exception e)
                {
                    MetodosForm.mensajeErrorDefault(e.Message, _datasistema);
                }
            }

            else
            {
                try
                {
                    FAC_VENDEDOR m = (from u in _datasistema.ContextoVentas.FAC_VENDEDOR
                                      where u.ID == int.Parse(UIID.Text)
                                      select u).First();

                    {
                        m.DS_VENDEDOR = UIDS_VENDEDOR.Text;
                        m.DS_TELEFONO = UIDS_TELEFONO.Text;
                        m.DS_CORREO   = UIDS_CORREO.Text;
                        m.CD_VENDEDOR = UICD_VENDEDOR.Text;
                        _datasistema.ContextoVentas.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
                        _datasistema.ContextoVentas.SubmitChanges();
                        consultar();
                        MetodosForm.seleccionarFila(uigridview, "ID", m.ID);
                    }
                }
                catch
                (Exception e)
                {
                    MetodosForm.mensajeErrorDefault(e.Message, _datasistema);
                }
            }
        }
コード例 #2
0
        public void eliminar()
        {
            try
            {
                FAC_VENDEDOR m = (from u in _datasistema.ContextoVentas.FAC_VENDEDOR
                                  where u.ID == int.Parse(UIID.Text)
                                  select u).First();

                _datasistema.ContextoVentas.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
                _datasistema.ContextoVentas.FAC_VENDEDOR.DeleteOnSubmit(m);
                _datasistema.ContextoVentas.SubmitChanges();
                consultar();
            }
            catch (Exception e)
            {
                MetodosForm.mensajeErrorDefault(e.Message, _datasistema);
            }
        }