protected void Page_Load(object sender, EventArgs e)
        {
            lblWarning.Visible = false;
            var idMuebleToEdit = Session["idMuebleToEdit"];

            try
            {
                if (idMuebleToEdit == null)
                {
                    Response.Redirect("inventory.aspx");
                }
                else
                {
                    Mueble mueble = MuebleController.searchMuebleById(Convert.ToInt32(idMuebleToEdit));
                    txtName.Attributes.Add("placeholder", mueble.nombre);
                    txtColor.Attributes.Add("placeholder", mueble.color);
                    txtAlmacen.Attributes.Add("placeholder", "Almacen 1");
                    txtPrecio.Attributes.Add("placeholder", mueble.precio.ToString());
                    txtCantidad.Attributes.Add("placeholder", mueble.cantidad_stock.ToString());
                    imgMueble.Src = "../assets/images/muebles/" + mueble.image;
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + ex.Message + "');", true);;
            }
        }
예제 #2
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                Mueble mueble = new Mueble();
                mueble.nombre         = txtName.Text;
                mueble.color          = txtColor.Text;
                mueble.categoria      = txtCategory.SelectedValue;
                mueble.precio         = Convert.ToInt32(txtPrecio.Text);
                mueble.cantidad_stock = Convert.ToInt32(txtCantidad.Text);
                mueble.idAlmacen      = 1;
                MuebleController.insertMueble(mueble);

                var savePath = @"D:\Downloads\ITH\7\Desarrollo de Proyectos de Software\oficinas_y_mas\assets\images\muebles\";
                if (FileUpload.HasFile)
                {
                    string extension = System.IO.Path.GetExtension(FileUpload.FileName);

                    if (extension == ".jpg" || extension == ".png")
                    {
                        if (extension == ".jpg")
                        {
                            var fileName = mueble.idMueble + ".jpg";
                            savePath += fileName;
                            FileUpload.SaveAs(savePath);
                            mueble.image = mueble.idMueble + ".jpg";
                        }
                        if (extension == ".png")
                        {
                            var fileName = mueble.idMueble + ".png";
                            savePath += fileName;
                            FileUpload.SaveAs(savePath);
                            mueble.image = mueble.idMueble + ".png";
                        }
                        MuebleController.updateMueble(mueble);
                        Response.Redirect("inventory.aspx");
                    }
                    else
                    {
                        lblWarning.InnerText = "Archivo no válido. Seleccione archivos con extensión .jpg o .png";
                        lblWarning.Visible   = true;
                    }
                }
                else
                {
                    Response.Redirect("inventory.aspx");
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + ex.Message + "');", true);
            }
        }
예제 #3
0
        protected void btnFinalizarVenta_Click(object sender, EventArgs e)
        {
            var muebleVenta = MuebleController.searchMuebleByMultipleId(idList);
            var i           = 0;

            foreach (var item in muebleVenta)
            {
                item.cantidad_stock = item.cantidad_stock - (Convert.ToInt32(((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text));
                MuebleController.updateMueble(item);
                i++;
            }
            Session["idList"] = null;
            Response.Redirect("venta.aspx");
        }
예제 #4
0
        protected void txtCantidad_TextChanged(object sender, EventArgs e)
        {
            var total       = 0;
            var i           = 0;
            var muebleVenta = MuebleController.searchMuebleByMultipleId(idList);

            foreach (var item in muebleVenta)
            {
                total = total + (Convert.ToInt32(item.precio) * Convert.ToInt32(((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text));
                Session["totalVenta"] = total;
                i++;
            }
            lblTotal.InnerText = "$ " + Session["totalVenta"].ToString();
        }
예제 #5
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            var idMuebleToSell = txtSearch.Text;

            if (!idMuebleToSell.All(char.IsDigit))
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Codigo invalido');", true);
                return;
            }
            var mueble = MuebleController.searchMuebleById(Convert.ToInt32(idMuebleToSell));

            if (mueble == null)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Producto inexistente');", true);
                return;
            }
            if (mueble.cantidad_stock == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Producto no disponible en stock');", true);
                return;
            }
            idList.Add(Convert.ToInt32(idMuebleToSell));
            Session["idList"] = idList;
            List <string> cantidades = new List <string>();

            foreach (GridViewRow item in gvMuebles.Rows)
            {
                cantidades.Add(((TextBox)item.FindControl("txtCantidad")).Text);
            }
            var muebleVenta = MuebleController.searchMuebleByMultipleId(idList);

            gvMuebles.DataSource = muebleVenta;
            gvMuebles.DataBind();
            var total = 0;
            var i     = 0;

            foreach (var item in muebleVenta)
            {
                if (cantidades.Count() > i)
                {
                    ((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text = cantidades[i];
                }
                total = total + (Convert.ToInt32(item.precio) * Convert.ToInt32(((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text));
                Session["totalVenta"] = total;
                i++;
            }

            lblTotal.InnerText = "$ " + Session["totalVenta"].ToString();
        }
예제 #6
0
 protected void btnConfirm_Click(object sender, EventArgs e)
 {
     MuebleController.removeMueble(Convert.ToInt32(Session["idMuebleToDelete"]));
     Response.Redirect("inventory.aspx");
 }
예제 #7
0
 private void BindGrid()
 {
     gvMuebles.DataSource = MuebleController.searchMuebleByCriteria("");
     gvMuebles.DataBind();
 }