示例#1
0
        private void CrearFacturaComprobante()
        {
            if (checkboxClienteAnonimo.Checked == true)
            {
                facturaEntidad.ClienteID = 1;
            }
            else
            {
                facturaEntidad.ClienteID = Convert.ToInt32(txtClienteID.Text);
            }

            NCF = Properties.Settings.Default.CFiscalSecuencia + 1;
            facturaEntidad.Fecha            = DateTime.Now;
            facturaEntidad.TipoPagoID       = (int)char.GetNumericValue(cbTipoPago.Text[0]);
            facturaEntidad.TipoFacturaID    = (int)char.GetNumericValue(cbTipoFactura.Text[0]);
            facturaEntidad.NCF              = "00000000B01" + NCF.ToString("D8");
            facturaEntidad.UserID           = Login.userID;
            facturaEntidad.RNC              = txtRNC.Text;
            facturaEntidad.Entidad          = txtNombre.Text;
            facturaEntidad.FechaVencimiento = Properties.Settings.Default.FechaVencimiento;

            var result = facturasNegocio.InsertarFactura(facturaEntidad);

            if (result.Item1)
            {
                Properties.Settings.Default.CFiscalSecuencia = NCF;
                Properties.Settings.Default.Save();
                facturaID = result.Item2;
                CrearDetalleFactura();
            }
        }
示例#2
0
        // GET: NCFs1/Create
        public ActionResult Create(int?id)
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Logins"));
            }
            var usuarioid  = Session["userid"].ToString();
            var empresaid  = Session["empresaid"].ToString();
            var usuarioid1 = Convert.ToInt32(usuarioid);
            var empresaid1 = Convert.ToInt32(empresaid);

            if (id == null)
            {
                ViewBag.empresaid = new SelectList(db.Empresa, "IdEmpresa", "Nombre");
                ViewBag.usuarioid = new SelectList(db.Login, "LoginId", "Username");
                return(View());
            }
            NCF ncf = db.NCF.Find(id);

            if (ncf == null)
            {
                return(HttpNotFound());
            }
            if (id != null)
            {
                ViewBag.empresaid = new SelectList(db.Empresa, "IdEmpresa", "Nombre");
                ViewBag.usuarioid = new SelectList(db.Login, "LoginId", "Username");
                ViewBag.id        = "algo";

                return(View(ncf));
            }
            return(View());
        }
        private bool CrearNotaDeCredito()
        {
            notasDeCreditoEntidad.FacturaID        = Convert.ToInt32(txtFacturaID.Text);
            notasDeCreditoEntidad.FacturaAplicarID = Convert.ToInt32(CBFacturasPendientes.Text);
            notasDeCreditoEntidad.Fecha            = System.DateTime.Now;
            notasDeCreditoEntidad.UserID           = Login.userID;
            NCF = Properties.Settings.Default.CNotaDeCredito + 1;
            notasDeCreditoEntidad.NCF = "00000000B04" + NCF.ToString("D8");
            notasDeCreditoEntidad.FechaVencimiento = Properties.Settings.Default.FechaVencimiento;
            notasDeCreditoEntidad.ValorAplicado    = Convert.ToDecimal(txtValorAAplicar.Text);

            var result = notasDeCreditoNegocio.AgregarNotaDeCredito(notasDeCreditoEntidad);

            if (result.Item1)
            {
                notaDeCreditoID = result.Item2;
                MessageBox.Show(string.Format("La nota de credito {0} fue creada exitosamente...", notaDeCreditoID), "Nota De Credito Creada Correctamente", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CrearDetalleNotaDeCredito();
                Properties.Settings.Default.CNotaDeCredito = NCF;
                Properties.Settings.Default.Save();
                return(true);
            }
            else
            {
                MessageBox.Show("Ha ocurrido un error en la crecion de la nota de credito...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
示例#4
0
        public ActionResult DeleteConfirmed(int id)
        {
            NCF nCF = db.NCF.Find(id);

            db.NCF.Remove(nCF);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#5
0
 public IActionResult Delete([FromBody] NCF nfc)
 {
     if (nfc.NCFId > 0)
     {
         return(Ok(_logic.Delete(nfc)));
     }
     return(BadRequest());
 }
示例#6
0
 public IActionResult Post([FromBody] NCF ncf)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     return(Ok(_logic.Insert(ncf)));
 }
示例#7
0
 public IActionResult Put([FromBody] NCF ncf)
 {
     if (ModelState.IsValid && _logic.Update(ncf))
     {
         return(Ok(new { Message = "El ncf se actualizo correctamente" }));
     }
     return(BadRequest());
 }
示例#8
0
        public ActionResult DeleteConfirmed(int id)
        {
            NCF nCF = db.NCF.Find(id);
            var q   = (from a in db.NCF where a.idNCF == id select a).First();

            q.Estatus = "0";
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#9
0
 public ActionResult Edit([Bind(Include = "idNCF,Tipo,Estatus,NoNCF")] NCF nCF)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nCF).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nCF));
 }
示例#10
0
        public ActionResult Create([Bind(Include = "idNCF,NombreComp,Estatus,empresaid,usuarioid,Descripcion,tipodocumento")] NCF nCF)
        {
            var t = (from s in db.NCF where s.idNCF == nCF.idNCF select s.idNCF).Count();

            if (t != 0)
            {
                if (ModelState.IsValid)
                {
                    if (nCF.NombreComp != null)
                    {
                        nCF.NombreComp = nCF.NombreComp.ToUpper();
                    }
                    if (nCF.Descripcion != null)
                    {
                        nCF.Descripcion = nCF.Descripcion.ToUpper();
                    }
                    nCF.Estatus = "1";
                    var usuarioid = Session["userid"].ToString();
                    var empresaid = Session["empresaid"].ToString();
                    nCF.usuarioid       = Convert.ToInt32(usuarioid);
                    nCF.empresaid       = Convert.ToInt32(empresaid);
                    db.Entry(nCF).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            else if (nCF.idNCF <= 0)
            {
                if (ModelState.IsValid)
                {
                    if (nCF.NombreComp != null)
                    {
                        nCF.NombreComp = nCF.NombreComp.ToUpper();
                    }
                    if (nCF.Descripcion != null)
                    {
                        nCF.Descripcion = nCF.Descripcion.ToUpper();
                    }
                    nCF.Estatus       = "1";
                    nCF.tipodocumento = 1;
                    var usuarioid = Session["userid"].ToString();
                    var empresaid = Session["empresaid"].ToString();
                    nCF.usuarioid = Convert.ToInt32(usuarioid);
                    nCF.empresaid = Convert.ToInt32(empresaid);
                    db.NCF.Add(nCF);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.empresaid = new SelectList(db.Empresa, "IdEmpresa", "Nombre", nCF.empresaid);
            ViewBag.usuarioid = new SelectList(db.Login, "LoginId", "Username", nCF.usuarioid);
            return(View(nCF));
        }
示例#11
0
 public ActionResult Edit([Bind(Include = "idNCF,NombreComp,Estatus,empresaid,usuarioid,Descripcion,tipodocumento")] NCF nCF)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nCF).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.empresaid = new SelectList(db.Empresa, "IdEmpresa", "Nombre", nCF.empresaid);
     ViewBag.usuarioid = new SelectList(db.Login, "LoginId", "Username", nCF.usuarioid);
     return(View(nCF));
 }
示例#12
0
        // GET: NCFs1/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NCF nCF = db.NCF.Find(id);

            if (nCF == null)
            {
                return(HttpNotFound());
            }
            return(View(nCF));
        }
示例#13
0
        public ActionResult Create([Bind(Include = "idNCF,Tipo,Estatus,NoNCF")] NCF nCF)
        {
            if (ModelState.IsValid)
            {
                var usuarioid = Session["userid"].ToString();
                var empresaid = Session["empresaid"].ToString();
                nCF.usuarioid = Convert.ToInt32(usuarioid);
                nCF.empresaid = Convert.ToInt32(empresaid);
                db.NCF.Add(nCF);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nCF));
        }
示例#14
0
        // GET: NCFs1/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NCF nCF = db.NCF.Find(id);

            if (nCF == null)
            {
                return(HttpNotFound());
            }
            ViewBag.empresaid = new SelectList(db.Empresa, "IdEmpresa", "Nombre", nCF.empresaid);
            ViewBag.usuarioid = new SelectList(db.Login, "LoginId", "Username", nCF.usuarioid);
            return(View(nCF));
        }
示例#15
0
        // GET: NCFs1/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Logins"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NCF nCF = db.NCF.Find(id);

            if (nCF == null)
            {
                return(HttpNotFound());
            }
            return(View(nCF));
        }
示例#16
0
        private void cmdAgregarNCF_Click(object sender, EventArgs e)
        {
            datos objDato = new datos();

            objDato.Conectar();
            string sql = "";

            sql = ("select n.ncf_ncf from NCF n where n.codigo_tncf = " + this.cmbTipoNCF.SelectedValue.ToString() + " and estado = 1");
            objDato.Consulta_llenar_datos(sql);
            this.txtCantidad.Focus();

            if (objDato.ds.Tables[0].Rows.Count > 0)
            {
                string NCF;
                NCF = objDato.ds.Tables[0].Rows[0][0].ToString();
                this.txtNCF.Text = NCF.ToString();
            }
            else
            {
                MessageBox.Show("No hay NCF disponibles de este tipo");
            }
            objDato.Desconectar();
        }
示例#17
0
 public bool Update(NCF ncf)
 {
     return(_unitOfWork.NCF.Update(ncf));
 }
示例#18
0
 public int Insert(NCF ncf)
 {
     return(_unitOfWork.NCF.Insert(ncf));
 }
示例#19
0
 public bool Delete(NCF nfc)
 {
     return(_unitOfWork.NCF.Delete(nfc));
 }