Ejemplo n.º 1
0
        public ActionResult DeleteItemPhoto(int id)
        {
            ItemPhoto existingItemPhoto = _itemPhotoRepository.Get(id);

            if (existingItemPhoto == null)
            {
                return(NotFound());
            }

            _itemPhotoRepository.RemoveWithPropertySet(existingItemPhoto);
            _itemPhotoRepository.SaveChanges();

            return(NoContent());
        }
Ejemplo n.º 2
0
        public ActionResult <ItemPhotoDto> PostItemPhoto(ItemPhoto itemPhoto)
        {
            if (itemPhoto == null)
            {
                return(BadRequest());
            }

            ItemPhotoPostDto postedItemPhoto = _mapper.Map <ItemPhotoPostDto>(itemPhoto);
            ItemPhoto        itemPhotoModel  = _mapper.Map <ItemPhoto>(postedItemPhoto);

            _itemPhotoRepository.Add(itemPhotoModel);
            _itemPhotoRepository.SaveChanges();

            var itemPhotoDto = _mapper.Map <ItemPhotoDto>(itemPhotoModel);

            return(CreatedAtAction(nameof(GetItemPhoto), new { itemPhotoDto.Id }, itemPhotoDto));
        }
Ejemplo n.º 3
0
        /*
         #####################################################################
         # Q4
         #              item._Item._ITEMCODE
         #              item._Item._NAME
         #              item._Item._BRAND
         #              item._Item._PRICE
         #              item._Item._DESCRIPTION
         ###############################
         ######################################
         */
        public static List <ItemPhoto> SearchItems(string name, string brand)
        {
            string Q4Query = " select ITEMCODE, NAME, BRAND, PRICE, DESCRIPTION from item " +
                             " where name like '%" + name + "%' and brand like '%" + brand + "%' ";


            List <ItemPhoto> items = new List <ItemPhoto>();

            if (Connect())
            {
                //we are going to call query called Q4
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    sqlCommand.CommandType = CommandType.Text;
                    sqlCommand.CommandText = Q4Query;
                    sqlCommand.Connection  = _Connection;
                    SqlDataReader reader;
                    try
                    {
                        reader = sqlCommand.ExecuteReader();
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                    //Converting query results to PersonPhoneAddress objects
                    while (reader.Read())
                    {
                        ItemPhoto item = new ItemPhoto();
                        item._Item._ITEMCODE    = Convert.ToInt32(reader[0]);
                        item._Item._NAME        = Convert.ToString(reader[1]);
                        item._Item._BRAND       = Convert.ToString(reader[2]);
                        item._Item._PRICE       = Convert.ToDouble(reader[3]);
                        item._Item._DESCRIPTION = Convert.ToString(reader[4]);
                        items.Add(item);
                    }
                    reader.Close();
                }
            }


            return(items);
        }
Ejemplo n.º 4
0
        /*
         #####################################################################
         # Q4
         #              item._Item._ITEMCODE
         #              item._Item._NAME
         #              item._Item._BRAND
         #              item._Item._PRICE
         #              item._Item._DESCRIPTION
         #####################################################################
         */
        public static List <ItemPhoto> SearchItems(string name, string brand)
        {
            List <ItemPhoto> items = new List <ItemPhoto>();
            ItemPhoto        item;

            if (Connect())
            {
                using (SqlCommand sqlCommand = new SqlCommand("Q4", _Connection))
                {
                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.CommandText = "SearchItems";
                    sqlCommand.Parameters.Add("@name", SqlDbType.VarChar).Value  = name;
                    sqlCommand.Parameters.Add("@brand", SqlDbType.VarChar).Value = brand;
                    SqlDataReader reader;
                    try
                    {
                        reader = sqlCommand.ExecuteReader();
                    }
                    catch (Exception ex)
                    {
                        return(null);
                    }
                    while (reader.Read())
                    {
                        item = new ItemPhoto();
                        item._Item._ITEMCODE    = Convert.ToInt32(reader[0]);
                        item._Item._NAME        = Convert.ToString(reader[1]);
                        item._Item._BRAND       = Convert.ToString(reader[2]);
                        item._Item._PRICE       = Convert.ToInt32(reader[3]);
                        item._Item._DESCRIPTION = Convert.ToString(reader[4]);
                        items.Add(item);
                    }
                    reader.Close();
                }
            }


            return(items);
        }
Ejemplo n.º 5
0
        public ActionResult GetItemPhoto(int id)
        {
            ItemPhoto itemPhoto = _itemPhotoRepository.Get(id);

            return(Ok(_mapper.Map <ItemPhotoDto>(itemPhoto)));
        }
Ejemplo n.º 6
0
 public ItemPhoto ToEntity()
 {
     var photo = new ItemPhoto();
     ModelObjectHelper.CopyObject(this, photo);
     return photo;
 }
Ejemplo n.º 7
0
 public ItemPhotoModel(ItemPhoto photo)
     : this()
 {
     ModelObjectHelper.CopyObject(photo, this);
 }
Ejemplo n.º 8
0
        private bool PopulateItemEntry()
        {
            bool   retval       = false;
            string strItemSeqNo = string.Empty;
            string strItemID    = string.Empty;

            lblItemName.Text = string.Empty;
            using (var item = new Item())
            {
                string strBarcodeBuah = txtItemID.Text.Trim();
                if (strBarcodeBuah.Length > 1)
                {
                    if (Program.Left(strBarcodeBuah, 2) == "22" && strBarcodeBuah.Trim().Length == 13)
                    {
                        txtItemID.Text = Program.Left(strBarcodeBuah, 6);
                    }
                    else
                    {
                        strBarcodeBuah = string.Empty;
                    }
                }

                if (item.LoadByItemID(txtItemID.Text))
                {
                    strItemSeqNo     = item.ItemSeqNo.Trim();
                    lblItemName.Text = item.ItemName;
                    strItemID        = item.ItemID.Trim();
                    retval           = true;
                }
                else
                {
                    ClearItemEntry();
                    strItemSeqNo     = string.Empty;
                    strItemID        = string.Empty;
                    lblItemName.Text = "Item not found. Please try again.";
                    retval           = false;
                }
            }

            using (var salesDt = new SalesUnitDt())
            {
                DataTable dtbPriceSalesItem = salesDt.SelectGetPriceItemSalesFOAllByItemSeqNo(strItemSeqNo);

                dtbPriceSalesItem.PrimaryKey = new[] { dtbPriceSalesItem.Columns["ItemUnitID"] };

                grdItemPrice.AutoGenerateColumns = false;
                grdItemPrice.DataSource          = dtbPriceSalesItem;
                grdItemPrice.ResumeLayout();

                dtbPriceSalesItem.Dispose();
                dtbPriceSalesItem = null;
            }

            var oPromotion = new PromotionHd();
            var dv         = new DataView(oPromotion.SelectInformationPromotion(Convert.ToDateTime("2011-01-01"), DateTime.Today.Date));

            dv.RowFilter = "ItemID = '" + strItemID.Trim() + "'";
            dtgPromotion.AutoGenerateColumns = false;
            dtgPromotion.DataSource          = dv;
            dtgPromotion.ResumeLayout();
            dv = null;
            oPromotion.Dispose();
            oPromotion = null;

            var oitemphoto = new ItemPhoto();

            oitemphoto.ItemSeqNo = strItemSeqNo.Trim();
            if (oitemphoto.SelectByItemSeqNo().Rows.Count > 0)
            {
                Byte[] byteBLOBData = new Byte[0];
                byteBLOBData = (Byte[])(oitemphoto.ItemPhoto);
                MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
                picBoxItem.Image = Image.FromStream(stmBLOBData);

                //Byte[] msdt = (Byte[])(oitemphoto.ItemPhoto);
                //MemoryStream ms = new MemoryStream(msdt);
                //ms.Write(msdt, 0, msdt.Length);
                //ms.Position = 0;
                //ms.Seek(0, SeekOrigin.Begin);
                //picBoxItem.Image = Image.FromStream(ms);

                //Byte[] msdt = (Byte[])(oitemphoto.ItemPhoto);
                //MemoryStream ms = new MemoryStream(msdt);
                //Image img = new System.Drawing.Bitmap(ms);
                //picBoxItem.Image = img;
            }
            else
            {
                picBoxItem.Image = null;
            }
            oitemphoto.Dispose();
            oitemphoto = null;


            txtItemID.Text = string.Empty;
            txtItemID.Focus();
            return(retval);
        }