Esempio n. 1
0
    public void UpdateStockSize(int id, int productId, int sizeId, int stock)
    {
        if (id < 1 || productId < 1 || sizeId < 1 || stock < 0)
        {
            throw new Exception("No es posible actualizar el Stock, los valores no son válidos");
        }

        StockSizesDAO dao             = new StockSizesDAO();
        StockSize     updateStockSize = dao.GetStockSize(id);

        if (updateStockSize != null)
        {
            updateStockSize.productId = productId;
            updateStockSize.sizeId    = sizeId;
            updateStockSize.stock     = stock;
            int result = dao.UpdateStockSize(updateStockSize);
            if (result < 1)
            {
                throw new Exception("No es posible actualizarel Stock");
            }
        }
        else
        {
            throw new Exception("El id del Stock a actualizar no es válido");
        }
    }
Esempio n. 2
0
 public static Image GetImage(string stock_id, StockSize size)
 {
     IntPtr raw = stock_get_image(stock_id, size);
     if(raw == IntPtr.Zero)
         throw new ArgumentException("Invalid stock ID", stock_id);
     return new Image(raw);
 }
Esempio n. 3
0
    public void InsertStockSize(int productId, int sizeId, int stock)
    {
        try
        {
        }
        catch (Exception)
        {
            throw new Exception("No es posible registrar el Stock");
        }

        StockSizesDAO    dao    = new StockSizesDAO();
        List <StockSize> brands = GetAllStockSizes();

        StockSize newStockSize = new StockSize();

        newStockSize.productId = productId;
        newStockSize.sizeId    = sizeId;
        newStockSize.stock     = stock;
        int result = dao.CreateStockSize(newStockSize);

        if (result < 1)
        {
            throw new Exception("No es posible registrar el Stock");
        }
    }
Esempio n. 4
0
 private void AddParameters(StockSize stockSize, Database database, DbCommand command)
 {
     database.AddInParameter(command, "@pId", DbType.Int32, stockSize.id);
     database.AddInParameter(command, "@pProductId", DbType.Int32, stockSize.productId);
     database.AddInParameter(command, "@pSizeId", DbType.Int32, stockSize.sizeId);
     database.AddInParameter(command, "@pStock", DbType.Int32, stockSize.stock);
     database.AddParameter(command, "@pIdReturn", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, null);
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        int productId = -1;

        if (!IsPostBack)
        {
            try
            {
                productId = Convert.ToInt32(Request.QueryString["productId"]);
                CtrlProducts ctrlProducts = new CtrlProducts();
                Product      product      = ctrlProducts.GetProduct(productId);

                if (product != null && product.id > 0)
                {
                    lblNombreProducto.Text = product.name;
                    lblDescripcion.Text    = product.shortDescription;

                    CtrlProductTypes ctrlProductTypes = new CtrlProductTypes();
                    ProductType      productType      = ctrlProductTypes.GetProductType(product.productTypeId);

                    if (productType != null && productType.id > 0)
                    {
                        CtrlCategorySizes ctrlCategorySizes = new CtrlCategorySizes();
                        CategorySize      categorySize      = ctrlCategorySizes.GetCategorySize(productType.categorySizeId);

                        CtrlSizes   ctrlSizes    = new CtrlSizes();
                        List <Size> listAllSizes = ctrlSizes.GetAllSizes();
                        listAllSizes = listAllSizes.FindAll(s => s.categorySizeId.Equals(categorySize.id));

                        CtrlStockSizes   ctrlStockSizes    = new CtrlStockSizes();
                        List <StockSize> listAllStockSizes = ctrlStockSizes.GetAllStockSizes();
                        listAllStockSizes = listAllStockSizes.FindAll(ss => ss.productId.Equals(product.id));

                        foreach (Size size in listAllSizes)
                        {
                            StockSize stockSize = listAllStockSizes.Find(ss => ss.sizeId.Equals(size.id));
                            if (stockSize == null)
                            {
                                StockSize newStockSize = new StockSize();
                                newStockSize.productId = product.id;
                                newStockSize.sizeId    = size.id;
                                newStockSize.stock     = 0;
                                ctrlStockSizes.InsertStockSize(newStockSize.productId, newStockSize.sizeId, newStockSize.stock);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Response.Redirect("Products.aspx");
            }
        }
    }
Esempio n. 6
0
    public void DeleteStockSize(int id)
    {
        StockSizesDAO dao             = new StockSizesDAO();
        StockSize     deleteStockSize = dao.GetStockSize(id);

        if (deleteStockSize != null)
        {
            int result = dao.DeleteStockSize(deleteStockSize);
            if (result < 1)
            {
                throw new Exception("No es posible eliminar el Stock");
            }
        }
        else
        {
            throw new Exception("El id del Stock a eliminar no es válido");
        }
    }
Esempio n. 7
0
        public int DeleteStockSize(StockSize stockSize)
        {
            int result = -1;

            try
            {
                Database  database = DatabaseFactory.CreateDatabase();
                DbCommand command  = database.GetStoredProcCommand(storedProcedureName);
                database.AddInParameter(command, "@pOperation", DbType.Int32, 5);
                AddParameters(stockSize, database, command);
                result = database.ExecuteNonQuery(command);
            }
            catch (Exception)
            {
                //Crear Exception
            }
            return(result);
        }
Esempio n. 8
0
        public StockSize GetStockSize(int id)
        {
            StockSize stockSize = null;

            try
            {
                Database  database = DatabaseFactory.CreateDatabase();
                DbCommand command  = database.GetStoredProcCommand(storedProcedureName);
                database.AddInParameter(command, "@pOperation", DbType.Int32, 3);
                database.AddInParameter(command, "@pId", DbType.Int32, id);
                DataSet dsStockSize = database.ExecuteDataSet(command);
                if (dsStockSize != null && dsStockSize.Tables.Count > 0)
                {
                    stockSize = DAOUtilities.FillEntities <StockSize>(dsStockSize.Tables[0])
                                .FirstOrDefault();
                }
            }
            catch (Exception)
            {
                //Crear Exception
            }
            return(stockSize);
        }
Esempio n. 9
0
        //after Save For Grid Data
        public List <PRDChemProdReqItem> GetTransactionItemList(long _TransactionID, string _IssueFrom)
        {
            using (var context = new BLC_DEVEntities())
            {
                var StockResult = (from p in context.INV_ChemStockSupplier
                                   where p.StoreID.ToString() == _IssueFrom
                                   group p by new
                {
                    //p.StoreID,
                    p.SupplierID,
                    p.PackSize,
                    p.ItemID,
                    p.SizeUnit,
                    p.UnitID
                } into g
                                   select new
                {
                    TransectionID = g.Max(p => p.TransectionID),
                    //StoreID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.StoreID).FirstOrDefault(),
                    ItemID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.ItemID).FirstOrDefault(),
                    SupplierID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.SupplierID).FirstOrDefault(),
                    //UnitID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.UnitID).FirstOrDefault(),
                    PackSize = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.PackSize).FirstOrDefault(),
                    SizeUnit = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.SizeUnit).FirstOrDefault(),
                    PackQty = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.PackClosingQty).FirstOrDefault(),
                    ClosingQty = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.ClosingQty).FirstOrDefault(),
                    StockUnit = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.UnitID).FirstOrDefault()
                });

                var Data = (from i in context.INV_StoreTransItem
                            where i.TransactionID == _TransactionID

                            // Stock Size
                            from s in StockResult.Where(x => x.ItemID == i.ItemID && x.PackSize == i.PackSize && x.SizeUnit == i.SizeUnit && x.SupplierID == i.SupplierID).DefaultIfEmpty()


                            join si in context.Sys_Size on(s == null ? null : s.PackSize) equals si.SizeID into StockSize
                            from si in StockSize.DefaultIfEmpty()

                            join siu in context.Sys_Unit on(s == null ? null : s.SizeUnit) equals siu.UnitID into StockSizeUnit
                            from siu in StockSizeUnit.DefaultIfEmpty()

                            join su in context.Sys_Unit on(s == null ? null : s.StockUnit) equals su.UnitID into StockUnit
                            from su in StockUnit.DefaultIfEmpty()
                            // Stock Size


                            join it in context.Sys_ChemicalItem on(i == null ? null : i.ItemID) equals it.ItemID into Chemicals
                            from it in Chemicals.DefaultIfEmpty()

                            join sup in context.Sys_Supplier on(i == null ? null : i.SupplierID) equals sup.SupplierID into Suppliers
                            from sup in Suppliers.DefaultIfEmpty()

                            join iu in context.Sys_Unit on(i == null ? null : i.TransactionUnit) equals iu.UnitID into IUnits
                            from iu in IUnits.DefaultIfEmpty()

                            join issuesize in context.Sys_Size on(i == null ? null : i.PackSize) equals issuesize.SizeID into IssueSizes
                            from issuesize in IssueSizes.DefaultIfEmpty()

                            join issuesizeunit in context.Sys_Unit on(i == null ? null : i.SizeUnit) equals issuesizeunit.UnitID into IssueSizeUnit
                            from issuesizeunit in IssueSizeUnit.DefaultIfEmpty()

                            orderby(it == null ? null : it.ItemName)

                            select new PRDChemProdReqItem
                {
                    TransItemID = i.TransItemID,
                    ItemID = i.ItemID,
                    ItemName = (it == null ? null : it.ItemName),
                    SupplierID = i.SupplierID,
                    SupplierName = (sup == null ? null : sup.SupplierName),

                    PackSize = (s == null ? 0 : s.PackSize),
                    PackSizeName = (si == null ? null : si.SizeName),
                    SizeUnit = (s == null ? 0 : s.SizeUnit),
                    SizeUnitName = (siu == null ? null : siu.UnitName),
                    PackQty = (s == null ? 0 : (Int32)(s.PackQty)),

                    StockQty = (s == null ? 0 : s.ClosingQty),
                    StockUnit = (s == null ? 0 : s.StockUnit),
                    StockUnitName = (su == null ? null : su.UnitName),

                    IssuePackSize = i.PackSize,
                    IssuePackSizeName = (issuesize == null ? null : issuesize.SizeName),
                    IssueSizeUnit = i.SizeUnit,
                    IssueSizeUnitName = (issuesizeunit == null ? null : issuesizeunit.UnitName),
                    IssuePackQty = i.PackQty,
                    IssueQty = i.TransactionQty,
                    IssueUnitName = (iu == null ? null : iu.UnitName)
                }).ToList();
                return(Data);
            }
        }
Esempio n. 10
0
 private static extern IntPtr stock_get_image(string stock_id, StockSize size);