/// <summary> /// Open dialog and allow user choose image /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void p_imageTextEdit_Click(object sender, EventArgs e) { //The Filter in open dialog will only accept file .jpg and .png openDialog.Filter = "Image files (*.jpg)|*.jpg|Image files (*.png)|*.png|All files (*.*)|*.*"; openDialog.ShowDialog(); //if file choosen is not empy and is image file //then set image name for image file if (openDialog.FileName != "" && (openDialog.FileName.EndsWith(".jpg") || openDialog.FileName.EndsWith(".png"))) { p_imageTextEdit.Text = openDialog.FileName; PetModel pm = new PetModel(); //set name image file is Pet's ID appends .jpg or .png if (openDialog.FileName.EndsWith(".jpg")) { p_imageTextEdit.Text = pm.SetPetID() + ".jpg"; } else { p_imageTextEdit.Text = pm.SetPetID() + ".png"; } } else { XtraMessageBox.Show("Please choose a image with (*.jpg)/(*.png) file !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void p_idTextEdit_Click(object sender, EventArgs e) { PetModel pm = new PetModel(); p_idTextEdit.Text = pm.SetPetID(); p_statusTextEdit.SelectedItem = "Active"; }