private int UpdatePhoto() { objSQLDB = new SQLDB(); objHrInfo = new HRInfo(); DataTable dt = new DataTable(); int iEcode = 0; try { dt = objSQLDB.ExecuteDataSet("SELECT top 1 HAMH_APPL_NUMBER,HAMH_EORA_CODE FROM temp_hr_photo_upload21112013 " + "INNER JOIN HR_APPL_MASTER_HEAD ON HAMH_EORA_CODE = ecode " + "where HAMH_MY_PHOTO is null").Tables[0]; int iApplNo = Convert.ToInt32(dt.Rows[0]["HAMH_APPL_NUMBER"].ToString()); iEcode = Convert.ToInt32(dt.Rows[0]["HAMH_EORA_CODE"].ToString()); Image loadedImage = Image.FromFile("D:\\Scan Photos\\" + iEcode + ".jpg"); byte[] imageData = { 0 }; imageData = ReadFile("D:\\Scan Photos\\" + iEcode + ".jpg"); objHrInfo.UpdatePhoto(iApplNo, imageData); } catch (Exception ex) { objSQLDB.ExecuteSaveData("DELETE FROM temp_hr_photo_upload21112013 WHERE ecode = " + iEcode); } objHrInfo = null; dt = null; return(iEcode); }
private void btnUpdate_Click(object sender, EventArgs e) { objSQLDB = new SQLDB(); int iRetVal = 0; byte[] imageData = { 0 }; int iPin = 0; if (addressPresent.Pin.Length > 0) { iPin = Convert.ToInt32(addressPresent.Pin); } else { iPin = 0; } if (lblPath.Text != "") { imageData = ReadFile(lblPath.Text); } //else // imageData = (byte)pictureBox1.BackgroundImage; //string sConnVal = ConfigurationSettings.AppSettings["DBCon"].ToString(); //objSecurity = new Security(); //SqlConnection CN = new SqlConnection(objSecurity.GetDecodeString(sConnVal)); try { string sqlStr = "UPDATE HR_APPL_MASTER_HEAD SET HAMH_PD_BLOOD_GROUP_CODE='" + cmbBloodGrp_optional.Text + "',HAMH_ADD_PRES_ADDR_HNO='" + addressPresent.HouseNo + "'," + "HAMH_ADD_PRES_ADDR_LANDMARK='" + addressPresent.LandMark + "',HAMH_ADD_PRES_ADDR_VILL_OR_TOWN='" + addressPresent.Village + "',HAMH_ADD_PRES_ADDR_MANDAL='" + addressPresent.Mondal + "'," + "HAMH_ADD_PRES_ADDR_DISTRICT='" + addressPresent.District + "',HAMH_ADD_PRES_ADDR_STATE='" + addressPresent.State + "',HAMH_ADD_PRES_ADDR_PIN=" + iPin + ",HAMH_ADD_PRES_ADDR_PHONE='" + txtMobileNo.Text + "'"; //if (lblPath.Text != "") // sqlStr += ", HAMH_MY_PHOTO='" + (object)imageData + "'"; sqlStr += " WHERE HAMH_EORA_CODE=" + txtEcodeSearch.Text; //SqlCommand SqlCom = new SqlCommand(sqlStr, CN); //if (lblPath.Text.Length > 1) // SqlCom.Parameters.Add(new SqlParameter("@Photo", (object)imageData)); //CN.Open(); iRetVal = objSQLDB.ExecuteSaveData(sqlStr); if (lblPath.Text != "") { objHrInfo = new HRInfo(); objHrInfo.UpdatePhoto(Convert.ToInt32(lblApplNo.Text), imageData); } //CN.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { objSQLDB = null; } if (iRetVal > 0) { btnClear_Click(null, null); MessageBox.Show("Selected information Has Been Updated", "SSCRM Application", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Selected information not Updated", "SSCRM Application", MessageBoxButtons.OK, MessageBoxIcon.Error); } objSecurity = null; }