/// <summary> /// Procedura salveaza poza adaugata /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSalveaza_Click(object sender, System.EventArgs e) { try { if ((filePozaAngajat.PostedFile.FileName != "") || (filePozaAngajat.PostedFile.ContentLength != 0)) { string contentFile = filePozaAngajat.PostedFile.ContentType.ToString(); if (contentFile.Substring(0, 5) == "image") { FileStream fp = new FileStream(filePozaAngajat.PostedFile.FileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fp); byte[] buffer = br.ReadBytes((int)fp.Length); br.Close(); fp.Close(); Salaries.Business.Angajat angajat = new Salaries.Business.Angajat(); angajat.AngajatId = AngajatID; angajat.UpdatePoza(buffer); } else { throw new Exception("Se pot salva numai fisiere de tip image (gif, jpg, jpeg...)!"); } } else { throw new Exception("Invalid file name or file length zero!"); } } catch (Exception ex) { litError.Text = "The following error occurred: <br>"; litError.Text += ex.Message; } }