protected void btnUpload_Click(object sender, EventArgs e) { string filename = Path.GetFileName(fileUpload1.PostedFile.FileName); Stream stream = fileUpload1.PostedFile.InputStream; string extension = Path.GetExtension(filename); //Write Save Logic to file/ BinaryReader br = new BinaryReader(stream); Byte[] size = br.ReadBytes((int)stream.Length); //SaveToFolder(stream, filename); //Database already here List<UploadFile> L = ResolveList(); using (ROPAEntities obj = new ROPAEntities()) { Guid G = Guid.NewGuid(); UploadFile upld = new UploadFile(); upld.GUID = G.ToString(); upld.FIleFor = filename; upld.SurApp_Id = null; obj.AddToUploadFiles(upld); obj.SaveChanges(); L.Add(upld); } UpdateSession(L); BindGridviewData(); }
protected void btnUpload_Click(object sender, EventArgs e) { string filename = Path.GetFileName(fileUpload1.PostedFile.FileName); string GetExts = Path.GetExtension(filename); Stream str = fileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(str); Byte[] size = br.ReadBytes((int)str.Length); using (ROPAEntities obj = new ROPAEntities()) { UploadFile upld = new UploadFile(); upld.GUID = Guid.NewGuid().ToString(); //upld.FIleFor=100; upld.FIleFor = filename; upld.SurApp_Id = 47; upld.fileext = GetExts; obj.AddToUploadFiles(upld); obj.SaveChanges(); } BindGridviewData(); }
protected void btnUpload_Click(object sender, EventArgs e) { try { var filename = Path.GetFileName(fileUpload1.PostedFile.FileName); var getExts = Path.GetExtension(filename); var str = fileUpload1.PostedFile.InputStream; var br = new BinaryReader(str); var size = br.ReadBytes((int) str.Length); using (var obj = new ROPAEntities()) { var upld = new UploadFile(); upld.GUID = Guid.NewGuid().ToString(); upld.AppVersion = (decimal) 2.30; upld.FIleFor = filename; upld.SurApp_Id = 47; upld.fileext = getExts; obj.AddToUploadFiles(upld); obj.SaveChanges(); } BindGridviewData(); } catch (Exception) { } }
public int Deleteuser(string FirstName) { int result = 0; using (ROPAEntities context = new ROPAEntities()) { var UserName = (from u in context.UpcmomingSurveyors where u.FirstName == FirstName select new { u.LastName }).FirstOrDefault(); var deleteQuery = (from u in context.UpcmomingSurveyors where u.FirstName == FirstName select u).FirstOrDefault(); context.DeleteObject(deleteQuery); result=context.SaveChanges(); return result; } }
public int insertRecord(string FName, string EmailId, string PhoneNumb, string Address, string CuntryCode, string commnts) { using (var cont = new ROPAEntities()) { var obj = new FeedBackForm{ FirstName = FName, EmailId = EmailId, PhoneNumber = PhoneNumb, Addres = Address, countrycode = CuntryCode, Commments = commnts, insertDate = DateTime.Now }; cont.AddToFeedBackForms(obj); int result = cont.SaveChanges(); return result; } }
public int insertRecord(string FName, string EmailId, string PhoneNumb, string Address, string CuntryCode, string commnts) { int result = 0; using (ROPAEntities cont = new ROPAEntities()) { FeedBackForm obj = new FeedBackForm(); obj.FirstName = FName; obj.EmailId = EmailId; obj.PhoneNumber = PhoneNumb; obj.Addres = Address; obj.countrycode = CuntryCode; obj.Commments = commnts; obj.insertDate = DateTime.Now; cont.AddToFeedBackForms(obj); result = cont.SaveChanges(); return result; } }
protected void Button1_Click(object sender, EventArgs e) { string emailid; emailid = txtInt.Text.Trim(); ROPAEntities context = new ROPAEntities(); var Query = (from a in context.UpcmomingSurveyors where a.EMAILID == emailid select a).FirstOrDefault(); if (Query != null) { ROPAUtil obj = new ROPAUtil(); Query.FirstName = txtFrstName.Text.Trim(); Query.LastName = txtLastName.Text.Trim(); Query.ApplyAsRole = Convert.ToInt32(ddlRoleId.SelectedValue); Query.Password = txtpsswrd.Text.Trim(); Query.EMAILID = txtEmailId.Text.Trim(); Query.ModifedDate = DateTime.Now; Query.AppId = 2; context.SaveChanges(); } }
protected void btnUpload_Click(object sender, EventArgs e) { string filename = Path.GetFileName(fileUpload1.PostedFile.FileName); Stream stream = fileUpload1.PostedFile.InputStream; int fileSize = fileUpload1.PostedFile.ContentLength; string extension = Path.GetExtension(filename); //Write Save Logic to file/ BinaryReader br = new BinaryReader(stream); Byte[] size = br.ReadBytes((int)stream.Length); //SaveToFolder(stream, filename); //Database already here List<UploadFile> L = ResolveList(); if (L.Count > 0) { //If file is Already Exist or not if exist skip this step bool flag; flag = IsFileExistOrNot(L, filename); if (IsFileExistOrNot(L, filename) == false) { using (ROPAEntities obj = new ROPAEntities()) { Guid G = Guid.NewGuid(); UploadFile upld = new UploadFile(); upld.GUID = G.ToString(); upld.FIleFor = filename; upld.SurApp_Id = null; upld.filecc = size; obj.AddToUploadFiles(upld); obj.SaveChanges(); L.Add(upld); } UpdateSession(L); BindGridviewData(); } } else { //Not there here first time using (ROPAEntities obj = new ROPAEntities()) { Guid G = Guid.NewGuid(); UploadFile upld = new UploadFile(); upld.GUID = G.ToString(); upld.FIleFor = filename; upld.filecc = size; obj.AddToUploadFiles(upld); obj.SaveChanges(); L.Add(upld); } UpdateSession(L); BindGridviewData(); } }
void Clear() { txtEmailId.Text = ""; txtFrstName.Text = ""; txtLastName.Text = ""; txtpsswrd.Text = ""; ddlRoleId.ClearSelection(); using (ROPAEntities context = new ROPAEntities()) { var deleteQuery = (from u in context.UploadFiles where u.SurApp_Id == null select u).ToList(); context.DeleteObject(deleteQuery); context.SaveChanges(); } ClearSession(); }
protected void gvDetails_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { e.Cancel = true; int UploadId = Convert.ToInt32(gvDetails.DataKeys[e.RowIndex].Value); List<UploadFile> L = ResolveList(); using (ROPAEntities contxt = new ROPAEntities()) { var entity = (from surapp in contxt.UploadFiles where surapp.UPloadId == UploadId select surapp).FirstOrDefault(); contxt.UploadFiles.DeleteObject(entity); contxt.SaveChanges(); foreach (UploadFile item in L) { if (item.UPloadId == UploadId) { L.Remove(item); break; } } } UpdateSession(L); BindGridviewData(); } catch (Exception ex) { // ACR.Framework.Common.Utilities.WriteToLogFile(new StackFrame(true), "LinkButtonDelete_Click", LoginUser.UserID.ToString(), TraceEventType.Error); } }
public void UpdateRecord(string FirstName, string Lastname, int applyAsrole, string password, string emailId) { // int result = 0; using (ROPAEntities context = new ROPAEntities()) { UpcmomingSurveyor obj = new UpcmomingSurveyor(); obj.FirstName = FirstName; obj.LastName = Lastname; obj.ApplyAsRole = applyAsrole; obj.Password = password; obj.EMAILID = emailId; obj.ModifedDate = DateTime.Now; obj.AppId = 2; // context.AddToUpcmomingSurveyors(obj); // result= context.SaveChanges(); // return result; } }
public void UPdateFeedbackdetails(int number, string Comments) { using (ROPAEntities obj = new ROPAEntities()) { var query = (from a in obj.FeedBackForms where a.FeedBackId == number select a).FirstOrDefault(); if (query != null) { query.Commments = Comments.Trim(); query.insertDate = DateTime.Now; obj.SaveChanges(); } } }
public int InsertRecord(string FirstName, string Lastname, int applyAsrole, string password, string emailId, List<UploadFile> L) { int result = 0; using (ROPAEntities context = new ROPAEntities()) { UpcmomingSurveyor obj = new UpcmomingSurveyor(); obj.FirstName = FirstName; obj.LastName = Lastname; obj.ApplyAsRole = applyAsrole; obj.Password = password; obj.AppId = 1; obj.ModifedDate = DateTime.Now; obj.EMAILID = emailId; context.AddToUpcmomingSurveyors(obj); foreach (UploadFile G in L) { UploadFiles Upld = new UploadFiles(); string s = G.GUID; var Q = (from u in context.UploadFiles where u.GUID ==s select u).FirstOrDefault(); Q.SurApp_Id = obj.SurApp_Id; } context.SaveChanges(); return result; } }