Beispiel #1
0
 public Boolean GuardarDB(com_Motivo_Orden_Compra_Info info, ref int IdMotivo, ref string msg)
 {
     try
     {
         using (EntitiesCompras Context = new EntitiesCompras())
         {
             var Address = new com_Motivo_Orden_Compra();
             Address.IdEmpresa   = info.IdEmpresa;
             Address.IdMotivo    = info.IdMotivo = GetId(info.IdEmpresa);
             Address.Cod_Motivo  = info.Cod_Motivo;
             Address.Descripcion = info.Descripcion;
             Address.estado      = info.estado;
             Context.com_Motivo_Orden_Compra.Add(Address);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         string arreglo = ToString();
         tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
         tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                   "", "", "", "", DateTime.Now);
         oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
         mensaje = ex.ToString();
         throw new Exception(ex.ToString());
     }
 }
Beispiel #2
0
        public void set_Info(com_Motivo_Orden_Compra_Info Info_i)
        {
            try
            {
                _Info = Info_i;

                if (_Info == null)
                {
                    _Info = new com_Motivo_Orden_Compra_Info();
                }
                else
                {
                    txtid.Text          = _Info.IdMotivo.ToString();
                    txtcodigo.Text      = _Info.Cod_Motivo;
                    txtdescripcion.Text = _Info.Descripcion;
                    chkEstado.Checked   = (_Info.estado == "A") ? true : false;
                    if (_Info.estado == "I")
                    {
                        lblAnulado.Visible = true;
                    }
                    else
                    {
                        lblAnulado.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        public com_Motivo_Orden_Compra_Info Get_Info_Motivo_Orden_Compra(int IdEmpresa, int idMotivo_oc)
        {
            try
            {
                com_Motivo_Orden_Compra_Info Obj = new com_Motivo_Orden_Compra_Info();

                EntitiesCompras oEnti = new EntitiesCompras();

                var Query = from q in oEnti.com_Motivo_Orden_Compra
                            where q.IdEmpresa == IdEmpresa &&
                            q.IdMotivo == idMotivo_oc
                            select q;
                foreach (var item in Query)
                {
                    Obj.IdEmpresa   = item.IdEmpresa;
                    Obj.IdMotivo    = item.IdMotivo;
                    Obj.Cod_Motivo  = item.Cod_Motivo;
                    Obj.Descripcion = item.Descripcion;
                    Obj.estado      = item.estado;
                }
                return(Obj);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }
Beispiel #4
0
        public bool modificarDB(com_Motivo_Orden_Compra_Info info)
        {
            try
            {
                using (Entities_compras Context = new Entities_compras())
                {
                    com_Motivo_Orden_Compra Entity = Context.com_Motivo_Orden_Compra.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo == info.IdMotivo).FirstOrDefault();
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.Cod_Motivo      = info.Cod_Motivo;
                    Entity.Descripcion     = info.Descripcion;
                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = DateTime.Now;
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #5
0
        public Boolean AnularDB(com_Motivo_Orden_Compra_Info info, ref string msg)
        {
            try
            {
                using (EntitiesCompras context = new EntitiesCompras())
                {
                    var contact = context.com_Motivo_Orden_Compra.FirstOrDefault(var => var.IdEmpresa == info.IdEmpresa && var.IdMotivo == info.IdMotivo);

                    if (contact != null)
                    {
                        contact.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                        contact.MotivoAnulacion = info.MotivoAnulacion;
                        contact.FechaHoraAnul   = DateTime.Now;
                        contact.estado          = "I";
                        context.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }
Beispiel #6
0
        public List <com_Motivo_Orden_Compra_Info> Get_List_Motivo_Orden_Compra(int IdEmpresa)
        {
            try
            {
                List <com_Motivo_Orden_Compra_Info> Lst = new List <com_Motivo_Orden_Compra_Info>();
                EntitiesCompras oEnti = new EntitiesCompras();

                var Query = from q in oEnti.com_Motivo_Orden_Compra
                            where q.IdEmpresa == IdEmpresa
                            select q;
                foreach (var item in Query)
                {
                    com_Motivo_Orden_Compra_Info Obj = new com_Motivo_Orden_Compra_Info();
                    Obj.IdEmpresa   = item.IdEmpresa;
                    Obj.IdMotivo    = item.IdMotivo;
                    Obj.Cod_Motivo  = item.Cod_Motivo;
                    Obj.Descripcion = item.Descripcion;
                    Obj.estado      = item.estado;
                    Obj.SEstado     = (item.estado == "A") ? "ACTIVO" : "*ANULADO*";
                    Lst.Add(Obj);
                }
                return(Lst);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }
Beispiel #7
0
        public Boolean ModificarDB(com_Motivo_Orden_Compra_Info info, ref string msg)
        {
            try
            {
                using (EntitiesCompras context = new EntitiesCompras())
                {
                    var contact = context.com_Motivo_Orden_Compra.FirstOrDefault(var => var.IdEmpresa == info.IdEmpresa && var.IdMotivo == info.IdMotivo);

                    if (contact != null)
                    {
                        contact.Descripcion = info.Descripcion;
                        contact.Cod_Motivo  = info.Cod_Motivo;
                        contact.estado      = info.estado;
                        context.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Beispiel #8
0
        public com_Motivo_Orden_Compra_Info get_info(int IdEmpresa, int IdMotivo)
        {
            try
            {
                com_Motivo_Orden_Compra_Info info = new com_Motivo_Orden_Compra_Info();
                using (Entities_compras Context = new Entities_compras())
                {
                    com_Motivo_Orden_Compra Entity = Context.com_Motivo_Orden_Compra.Where(q => q.IdEmpresa == IdEmpresa && q.IdMotivo == IdMotivo).FirstOrDefault();
                    if (Entity == null)
                    {
                        return(null);
                    }

                    info = new com_Motivo_Orden_Compra_Info
                    {
                        IdEmpresa   = Entity.IdEmpresa,
                        IdMotivo    = Entity.IdMotivo,
                        Cod_Motivo  = Entity.Cod_Motivo,
                        Descripcion = Entity.Descripcion,
                        estado      = Entity.estado
                    };
                }
                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #9
0
        public bool guardarDB(com_Motivo_Orden_Compra_Info info)
        {
            try
            {
                using (Entities_compras Context = new Entities_compras())
                {
                    com_Motivo_Orden_Compra Entity = new com_Motivo_Orden_Compra

                    {
                        IdEmpresa     = info.IdEmpresa,
                        IdMotivo      = info.IdMotivo = get_id(info.IdEmpresa),
                        Cod_Motivo    = info.Cod_Motivo,
                        Descripcion   = info.Descripcion,
                        estado        = "A",
                        Fecha_Transac = DateTime.Now
                    };
                    Context.com_Motivo_Orden_Compra.Add(Entity);
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public ActionResult Nuevo(com_Motivo_Orden_Compra_Info model)
 {
     if (!bus_motivo.guardarDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult Nuevo(int IdEmpresa = 0)
        {
            com_Motivo_Orden_Compra_Info model = new com_Motivo_Orden_Compra_Info
            {
                IdEmpresa = IdEmpresa
            };

            return(View(model));
        }
 public ActionResult Anular(com_Motivo_Orden_Compra_Info model)
 {
     model.IdUsuarioUltAnu = SessionFixed.IdUsuario;
     if (!bus_motivo.anularDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
Beispiel #13
0
        private void Preparar_Formulario(Cl_Enumeradores.eTipo_action iAccion)
        {
            try
            {
                string mensajeFrm = "";

                Info = new com_Motivo_Orden_Compra_Info();

                switch (iAccion)
                {
                case Cl_Enumeradores.eTipo_action.grabar:
                    mensajeFrm = "REGISTRO NUEVO";
                    break;

                case Cl_Enumeradores.eTipo_action.actualizar:
                    mensajeFrm = "MODIFICAR REGISTRO";
                    Info       = (com_Motivo_Orden_Compra_Info)gridViewMotivo.GetFocusedRow();
                    break;

                case Cl_Enumeradores.eTipo_action.Anular:
                    mensajeFrm = "ANULAR REGISTRO";
                    Info       = (com_Motivo_Orden_Compra_Info)gridViewMotivo.GetFocusedRow();
                    break;

                case Cl_Enumeradores.eTipo_action.consultar:
                    mensajeFrm = "CONSULTAR REGISTRO";
                    Info       = (com_Motivo_Orden_Compra_Info)gridViewMotivo.GetFocusedRow();
                    break;

                default:
                    break;
                }



                if (Info != null)
                {
                    frm      = new frmCom_Motivo_Orden_Compra_Mant();
                    frm.Text = frm.Text + "***" + mensajeFrm + "***";
                    frm.set_Accion(iAccion);
                    frm.set_Info(Info);
                    frm.Show();
                    frm.MdiParent = this.MdiParent;
                    frm.Event_frmCom_Motivo_Orden_Compra_Mant_FormClosing += frm_Event_frmCom_Motivo_Orden_Compra_Mant_FormClosing;
                }
                else
                {
                    MessageBox.Show("Seleccione un Registro ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return;
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public ActionResult Anular(int IdEmpresa = 0, int IdMotivo = 0)
        {
            com_Motivo_Orden_Compra_Info model = bus_motivo.get_info(IdEmpresa, IdMotivo);

            if (model == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
 public bool anularDB(com_Motivo_Orden_Compra_Info info)
 {
     try
     {
         return(odata.anularDB(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #16
0
 public Boolean ModificarDB(com_Motivo_Orden_Compra_Info Info, ref string msg)
 {
     try
     {
         return(Odata.ModificarDB(Info, ref msg));
     }
     catch (Exception ex)
     {
         Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
         throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "ModificarDB", ex.Message), ex)
               {
                   EntityType = typeof(com_Motivo_Orden_Compra_Bus)
               };
     }
 }
Beispiel #17
0
 public com_Motivo_Orden_Compra_Info get_MotivoCompra()
 {
     try
     {
         InfoMotivoCompra = listMotivoCompra.FirstOrDefault(v => v.IdMotivo == Convert.ToInt32(cmbMotivo.EditValue));
         return(InfoMotivoCompra);
     }
     catch (Exception ex)
     {
         string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
         MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
         return(new com_Motivo_Orden_Compra_Info());
     }
 }
Beispiel #18
0
        private void LimpiarDatos()
        {
            try
            {
                _Info  = new com_Motivo_Orden_Compra_Info();
                Accion = Cl_Enumeradores.eTipo_action.grabar;
                set_Accion(Accion);

                chkEstado.Checked   = true;
                txtid.Text          = "";
                txtcodigo.Text      = "";
                txtdescripcion.Text = "";

                lblAnulado.Visible = false;
                chkEstado.Checked  = true;
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #19
0
        public com_Motivo_Orden_Compra_Info get_Info()
        {
            try
            {
                _Info = new com_Motivo_Orden_Compra_Info();

                _Info.estado = (chkEstado.Checked == true) ? "A" : "I";
                if (txtid.Text != "")
                {
                    _Info.IdMotivo = Convert.ToInt32(txtid.Text);
                }
                _Info.Cod_Motivo  = txtcodigo.Text;
                _Info.Descripcion = txtdescripcion.Text;
                _Info.IdEmpresa   = param.IdEmpresa;

                return(_Info);
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(new com_Motivo_Orden_Compra_Info());
            }
        }
Beispiel #20
0
        public bool anularDB(com_Motivo_Orden_Compra_Info info)
        {
            try
            {
                using (Entities_compras Context = new Entities_compras())
                {
                    com_Motivo_Orden_Compra Entity = Context.com_Motivo_Orden_Compra.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo == info.IdMotivo).FirstOrDefault();
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.estado          = "I";
                    Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Entity.FechaHoraAnul   = DateTime.Now;
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }