Exemplo n.º 1
0
        /// <summary>
        /// Show Pet detail
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDetail_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (petID != "")    //check user is select pet
            {
                DetailPetForm dtPet = new DetailPetForm();
                PetModel      pm    = new PetModel();
                Pet           p     = pm.getPet(petID);

                //set pet data for textbox on PetDetail Form
                dtPet.txt_pID.Text          = p.p_id;
                dtPet.txt_pName.Text        = p.p_name;
                dtPet.txt_pOriginPrice.Text = p.p_prices.ToString();
                dtPet.txt_pPriceSale.Text   = p.p_salePrice.ToString();
                dtPet.txt_Type.Text         = "";

                //Set color for pet status
                if (p.p_status == "Active")
                {
                    dtPet.txt_pStatus.ForeColor = Color.Green;
                }
                else
                {
                    dtPet.txt_pStatus.ForeColor = Color.Red;
                }

                dtPet.txt_pStatus.Text         = p.p_status;
                dtPet.txt_pOriginPrice.Enabled = true;
                dtPet.lblTitle.Text            = p.p_name;

                //get image path, resize and display image to pictureBox
                String projectPath = Path.GetFullPath(Path.Combine(Application.StartupPath, "..\\.."));
                String pathImage   = projectPath + "\\img\\" + p.p_image;
                Image  img         = Image.FromFile(pathImage);
                dtPet.ptbImage.Image = pm.ResizeImage(img, 440, 440);

                //Show PetDetail Form
                dtPet.ShowDialog();
            }
            else
            {
                MessageBox.Show("Please choose a food to view detail !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 2
0
        private void btnViewDetail_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (petID != "")
            {
                DetailPetForm dtPet = new DetailPetForm();
                PetModel      pm    = new PetModel();

                Pet p = pm.getPet(petID);

                dtPet.txt_pID.Text          = p.p_id;
                dtPet.txt_pName.Text        = p.p_name;
                dtPet.txt_pOriginPrice.Text = p.p_prices.ToString();
                dtPet.txt_pPriceSale.Text   = p.p_salePrice.ToString();
                dtPet.txt_Type.Text         = "";

                if (p.p_status == "Active")
                {
                    dtPet.txt_pStatus.ForeColor = Color.Green;
                }
                else
                {
                    dtPet.txt_pStatus.ForeColor = Color.Red;
                }

                dtPet.txt_pStatus.Text         = p.p_status;
                dtPet.txt_pOriginPrice.Enabled = true;
                dtPet.lblTitle.Text            = p.p_name;

                String projectPath = Path.GetFullPath(Path.Combine(Application.StartupPath, "..\\.."));
                String pathImage   = projectPath + "\\img\\" + p.p_image;
                Image  img         = Image.FromFile(pathImage);
                dtPet.ptbImage.Image = pm.ResizeImage(img, 440, 440);

                dtPet.ShowDialog();
            }
            else
            {
                MessageBox.Show("Please choose a food to view detail !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }