Ejemplo n.º 1
0
 private void btnViewDetail_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (IDSelected != "")
     {
         DetailPetFoodForm vdf = new DetailPetFoodForm();
         PetFoodModel      pfm = new PetFoodModel();
         PetFood           f   = pfm.getPetFood(IDSelected);
         vdf.te_pfID.Text        = f.pf_id;
         vdf.te_pfName.Text      = f.pf_name;
         vdf.te_pfPriceSale.Text = f.pf_salePrice.ToString();
         vdf.te_pfAmount.Text    = f.pf_amount.ToString();
         vdf.te_Type.Text        = "Pet's Food";
         if (f.pf_status == "Active")
         {
             vdf.te_pfStatus.ForeColor = Color.Green;
         }
         else
         {
             vdf.te_pfStatus.ForeColor = Color.Red;
         }
         vdf.te_pfStatus.Text   = f.pf_status;
         vdf.te_pfPrice.Enabled = false;
         vdf.lblTitle.Text      = "Pet's Food detail for '" + f.pf_name + "'";
         String projectPath = Path.GetFullPath(Path.Combine(Application.StartupPath, "..\\.."));
         String pathImage   = projectPath + "\\img\\" + f.pf_image;
         Image  img         = Image.FromFile(pathImage);
         vdf.ptbImage.Image = pfm.ResizeImage(img, 440, 440);
         vdf.ShowDialog();
     }
     else
     {
         MessageBox.Show("Please choose a food to view detail !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 private void btnDetail_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (pfIDSelected != "")
     {
         //declare
         DetailPetFoodForm vdf = new DetailPetFoodForm();
         PetFoodModel      pfm = new PetFoodModel();
         var     db            = new PetStoreEntities();
         PetFood f             = db.PetFoods.Find(pfIDSelected);
         var     type          = db.Types.Find(f.t_id);
         //set data to Detail pet food form
         vdf.te_pfID.Text        = f.pf_id;
         vdf.te_pfName.Text      = f.pf_name;
         vdf.te_pfPriceSale.Text = f.pf_salePrice.ToString();
         vdf.te_pfAmount.Text    = f.pf_amount.ToString();
         vdf.te_Type.Text        = type.t_name;
         //change text color with status
         if (f.pf_status == "Active")
         {
             vdf.te_pfStatus.ForeColor = Color.Green;
         }
         else
         {
             vdf.te_pfStatus.ForeColor = Color.Red;
         }
         //set data to detail form
         vdf.te_pfStatus.Text   = f.pf_status;
         vdf.te_pfPrice.Enabled = true;
         vdf.te_pfPrice.Text    = f.pf_prices.ToString();
         vdf.lblTitle.Text      = f.pf_name;
         //get image of item
         String projectPath = Path.GetFullPath(Path.Combine(Application.StartupPath, "..\\.."));
         String pathImage   = projectPath + "\\img\\" + f.pf_image;
         Image  img         = Image.FromFile(pathImage);
         //Resize image 440x440 and set to picture box
         vdf.ptbImage.Image = pfm.ResizeImage(img, 440, 440);
         //show detail form
         vdf.ShowDialog();
     }
     else
     {
         MessageBox.Show("Please choose a food to view detail !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }