// **************** ADD NEW Candidate ************************* public bool AddCandidate(CandidateSignUp_Model cnd) { //******************************* Save ImagePath *************************************** //Use Namespacecalled: System.IO string FileName; if (cnd.ImageFile != null) { FileName = Path.GetFileNameWithoutExtension(cnd.ImageFile.FileName); //To Get File Extension string FileExtension = Path.GetExtension(cnd.ImageFile.FileName); //Add Current Date To Attached File Name FileName = DateTime.Now.ToString("yyyyMMdd") + "-" + FileName.Trim() + FileExtension; string ImagePath = Path.Combine(HttpContext.Current.Server.MapPath("~/UserImages/"), FileName); cnd.ImageFile.SaveAs(ImagePath); } else { FileName = "vikas.jpg"; } //**************************************************************************************** Connection(); SqlCommand com = new SqlCommand("sp_InsertDataInto_tblEmployee", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@FirstName", cnd.FirstName); com.Parameters.AddWithValue("@MiddleName", cnd.MiddleName); com.Parameters.AddWithValue("@LastName", cnd.LastName); com.Parameters.AddWithValue("@FatherName", cnd.FatherName); com.Parameters.AddWithValue("@Gender", cnd.Gender); com.Parameters.AddWithValue("@MartialStatus", cnd.MartialStatus); com.Parameters.AddWithValue("@Caste", cnd.Caste); com.Parameters.AddWithValue("@Religion", cnd.Religion); com.Parameters.AddWithValue("@BloodGroup", cnd.BloodGroup); com.Parameters.AddWithValue("@Address", cnd.Address); com.Parameters.AddWithValue("@Email", cnd.Email); com.Parameters.AddWithValue("@HomeState", cnd.HomeState); com.Parameters.AddWithValue("@HomeDistrict", cnd.HomeDistrict); com.Parameters.AddWithValue("@PinCode", cnd.PinCode); com.Parameters.AddWithValue("@Remarks", cnd.Remarks); com.Parameters.AddWithValue("@ImagePath", "/UserImages/" + FileName); com.Parameters.AddWithValue("@PhoneNo", cnd.PhoneNo); com.Parameters.AddWithValue("@Department", cnd.Department); com.Parameters.AddWithValue("@Position", cnd.Position); con.Open(); int i = com.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } }
// ***************** UPDATE STUDENT DETAILS ********************* public bool UpdateCandidate(CandidateSignUp_Model cnd) { if (cnd.ImageFile != null) { string FileName = Path.GetFileNameWithoutExtension(cnd.ImageFile.FileName); //To Get File Extension string FileExtension = Path.GetExtension(cnd.ImageFile.FileName); //Add Current Date To Attached File Name FileName = DateTime.Now.ToString("yyyyMMdd") + "-" + FileName.Trim() + FileExtension; string ImagePath = Path.Combine(HttpContext.Current.Server.MapPath("~/UserImages/"), FileName); cnd.ImageFile.SaveAs(ImagePath); Connection(); SqlCommand cmd = new SqlCommand("UpdatetblEmployee", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", cnd.id); cmd.Parameters.AddWithValue("@FirstName", cnd.FirstName); cmd.Parameters.AddWithValue("@MiddleName", cnd.MiddleName); cmd.Parameters.AddWithValue("@LastName", cnd.LastName); cmd.Parameters.AddWithValue("@FatherName", cnd.FatherName); cmd.Parameters.AddWithValue("@Caste", cnd.Caste); cmd.Parameters.AddWithValue("@Religion", cnd.Religion); cmd.Parameters.AddWithValue("@Bloodgroup", cnd.BloodGroup); cmd.Parameters.AddWithValue("@Remarks", cnd.Remarks); cmd.Parameters.AddWithValue("@ImagePath", "/UserImages/" + FileName); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } } else { Connection(); SqlCommand cmd = new SqlCommand("UpdatetblEmployee", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", cnd.id); cmd.Parameters.AddWithValue("@FirstName", cnd.FirstName); cmd.Parameters.AddWithValue("@MiddleName", cnd.MiddleName); cmd.Parameters.AddWithValue("@LastName", cnd.LastName); cmd.Parameters.AddWithValue("@FatherName", cnd.FatherName); cmd.Parameters.AddWithValue("@Caste", cnd.Caste); cmd.Parameters.AddWithValue("@Religion", cnd.Religion); cmd.Parameters.AddWithValue("@Bloodgroup", cnd.BloodGroup); cmd.Parameters.AddWithValue("@Remarks", cnd.Remarks); //cmd.Parameters.AddWithValue("@ImagePath", cnd.ImagePath); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } } }