internal void DeletePrice(PriceS price) { var p = pricePoolControlList.SingleOrDefault(e => int.Parse(e.idLb.Text) == price.id); pricePoolControlList.Remove(p); this.panel1.Controls.Remove(p); ReplaceElements(); es.DeletePriceAsync(price.id); }
public void Display(PriceS price) { this.price = price; idLb.Text = price.id.ToString(); nameLb.Text = price.name; if(price.image != null) imagePb.Image = Image.FromStream(new MemoryStream(price.image)); }
public void Display(PriceS price) { idLb.Text = price.id.ToString(); nameTb.Text = price.name; descriptionTb.Text = price.description; if (price.image != null) imagePb.Image = Image.FromStream(new MemoryStream(price.image)); assetBundleLb.Text = price.path != null? "ok" : "no asset"; }
public PriceS[] GetPrices() { using (MasterDBDataContext db = new MasterDBDataContext()) { var price = db.Price.ToArray(); if (price != null) { PriceS[] result = new PriceS[price.Length]; for (int i = 0; i < price.Length; i++) { result[i] = new PriceS() { id = price[i].idPrice, name = price[i].Name, description = price[i].Description }; if (!String.IsNullOrEmpty(price[i].Image)) using (FileStream fs = new FileStream(price[i].Image, FileMode.Open, FileAccess.Read)) { byte[] bytes = new byte[fs.Length]; int numBytesToRead = (int)fs.Length; int numBytesRead = 0; while (numBytesToRead > 0) { // Read may return anything from 0 to numBytesToRead. int n = fs.Read(bytes, numBytesRead, numBytesToRead); if (n == 0) break; numBytesRead += n; numBytesToRead -= n; } result[i].image = bytes; } if (!String.IsNullOrEmpty(price[i].Path)) using (FileStream fs = new FileStream(price[i].Path, FileMode.Open, FileAccess.Read)) { byte[] bytes = new byte[fs.Length]; int numBytesToRead = (int)fs.Length; int numBytesRead = 0; while (numBytesToRead > 0) { // Read may return anything from 0 to numBytesToRead. int n = fs.Read(bytes, numBytesRead, numBytesToRead); if (n == 0) break; numBytesRead += n; numBytesToRead -= n; } result[i].path = bytes; } } return result; } return null; } }
public PriceS GetPrice(int id) { using (MasterDBDataContext db = new MasterDBDataContext()) { Price price = db.Price.SingleOrDefault(p => p.idPrice == id); if (price != null) { PriceS result = new PriceS() { id = price.idPrice, name = price.Name, description = price.Description }; if (!String.IsNullOrEmpty(price.Image)) using (FileStream fs = new FileStream(price.Image, FileMode.Open, FileAccess.Read)) { byte[] image = new byte[fs.Length]; int numBytesToRead = (int)fs.Length; int numBytesRead = 0; while (numBytesToRead > 0) { // Read may return anything from 0 to numBytesToRead. int n = fs.Read(image, numBytesRead, numBytesToRead); if (n == 0) break; numBytesRead += n; numBytesToRead -= n; } result.image = image; } if (!String.IsNullOrEmpty(price.Path)) using (FileStream fs = new FileStream(price.Image, FileMode.Open, FileAccess.Read)) { byte[] asset = new byte[fs.Length]; int numBytesToRead = (int)fs.Length; int numBytesRead = 0; while (numBytesToRead > 0) { // Read may return anything from 0 to numBytesToRead. int n = fs.Read(asset, numBytesRead, numBytesToRead); if (n == 0) break; numBytesRead += n; numBytesToRead -= n; } result.path = asset; } return result; } return null; } }
void es_GetPriceCompleted(object sender, GetPriceCompletedEventArgs e) { if (e.Error == null) { if (e.Result != null) { price = e.Result; es.GetEventAsync(pricepool.eventId); } else { MessageBox.Show("Price not exist"); this.Close(); } } else { MessageBox.Show("price ERROR : " + e.Error.Message); this.Close(); } }
public void SetEvent(PriceS price) { this.price = price; priceName.Text = price.name; }
private void openPricesBtn_Click(object sender, EventArgs e) { price = null; PriceSelector s = new PriceSelector(this); s.Show(); }