protected void AF_UserExcel_FileUpload(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { if (GSTIN.Text.Length == 15) { System.Threading.Thread.Sleep(1000); if (AF_UserExcel_Upload.HasFile) { string strFileExt = Path.GetExtension(e.FileName); string strFileName = MaheshAF18.Utility.DateHelper.DateYearPrefix("YYMMDD") + "" + Path.GetExtension(e.FileName); string strPath_DB = MABL.BL.AppVariable.Customer_Document_Location("UExcel") + "/" + strFileName; string strPath = MapPath(strPath_DB); AF_UserExcel_Upload.SaveAs(strPath); string varSQL = " TRUNCATE TABLE M_AT_Upload_File " + " TRUNCATE TABLE M_AT_Upload_File_BDTL " + " INSERT INTO M_AT_Upload_File " + " (GSTIN,UserFileName,FileExt,FilePath) " + " SELECT '" + GSTIN.Text + "','" + strFileName + "','" + strFileExt + "','" + strPath_DB + "'"; MaheshAF18.Application.MEF.DA_ExecuteQuery(varSQL); } } }
protected void txtFileuploaded(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { if (state != "false" && Session["user"] != null) { //string txtfileName = System.IO.Path.GetFileName(e.FileName); ; string fileName = System.IO.Path.GetFileName(e.FileName); string txtfileExtn = System.IO.Path.GetExtension(fileName); if (txtfileExtn == ".txt" && fileName.Length > 0) { txtserverPath = "Attachments/" + fileName; AsyncFileUpload1.PostedFile.SaveAs(Server.MapPath(txtserverPath)); bccIds = System.IO.File.ReadAllText(Server.MapPath(txtserverPath)); //calling method for splitting and validating email ids one by one Session["bccIds"] = validate_eMaillist(bccIds); if (inValidCount != 0) { Session["inValidCount"] = inValidCount; Session["INvalidrecp"] = INvalidrecp; } System.IO.File.Delete(Server.MapPath(txtserverPath)); } } }
/// <summary> /// Handles the UploadedComplete event of the fileOnq control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="AjaxControlToolkit.AsyncFileUploadEventArgs"/> instance containing the event data.</param> protected void fileOnq_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { Session["_bytesCargados"] = PostedFileToBytes(fileOnq.PostedFile); Session["_dtFacturas"] = null; }
protected void MyFile_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { //validate file if (!MyFile.HasFile) { lblError.Text = "Please select a picture file to upload."; return; } //Grab the file name from its fully qualified path at client String strFileFullPathName = MyFile.PostedFile.FileName; // only the attched file name not its path String strFileName = System.IO.Path.GetFileName(strFileFullPathName); String strFileExt = System.IO.Path.GetExtension(strFileName); switch (strFileExt.ToUpper()) { case ".PNG": case ".JPG": case ".JPEG": case ".JP2": case ".TIF": case ".TIFF": case ".GIF": case ".BMP": break; default: lblError.Text = "Sorry, the file you selected is not a known image type."; return; } if (strFileName.IndexOf("'") >= 0 | strFileName.IndexOf("\"") >= 0) { lblError.Text = "Sorry, the file name is not valid. Please remove spacial characters (e.g. qoutes, double quotes) from the file name and try again."; return; } System.Diagnostics.Debug.WriteLine("Document ext: " + strFileExt); //Calculating Save File name //Tablename_ObjectID_RunningNumber String baseFileName = TableName + "_" + KeyValue; if (!ServerImagePath.EndsWith(@"\")) { ServerImagePath += @"\"; } if (!HttpImagePath.EndsWith("/")) { HttpImagePath += "/"; } String saveFileName = baseFileName + strFileExt; String saveFileNameFullPath = ServerImagePath + saveFileName; int fileRunning = 0; while (System.IO.File.Exists(saveFileNameFullPath)) { fileRunning++; saveFileName = baseFileName + "-" + fileRunning.ToString() + strFileExt; saveFileNameFullPath = ServerImagePath + saveFileName; } //Update data table OleDbConnection Conn = new OleDbConnection(ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString); String strUpdateCommand = String.Format("UPDATE [{0}] SET [{1}] = '{2}' WHERE [{3}] = {4}{5}{4}", TableName, ImageField, System.IO.Path.GetFileName(saveFileName), KeyField, KeyFieldType == KeyFieldTypeEnum.String ? "'" : "", KeyValue); OleDbCommand objCommand = new OleDbCommand(strUpdateCommand, Conn); objCommand.Connection.Open(); objCommand.ExecuteNonQuery(); System.Diagnostics.Debug.WriteLine("Record updated"); //Save uploaded file to server try { //Upload the file MyFile.SaveAs(saveFileNameFullPath); lblMessage.Text = "Your File was Uploaded Sucessfully."; CurrentImageFile = System.IO.Path.GetFileName(saveFileName); } catch (Exception Exp) { lblError.Text = "OOPS! The server has encountered an error. Please check your file and try again."; } String js = String.Format("$(\"{0}\").attr(\"src\",\"{1}\")", imgCurrentPhoto.ClientID, getImgTag(HttpImagePath, CurrentImageFile, true)); ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "newimg", js, true); ajaxlabel.Text = js; UpdatePanel1.Update(); }
protected void AsyncFileUploadCustomerAttachment_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { if (Convert.ToInt32(Session["UploadFileCountProspect"]) == 0) { string fileNameall = ""; if (Convert.ToString(Session["ProspectAttachment"]) != null) { fileNameall = Convert.ToString(Session["ProspectAttachment"]); } string fileName = Path.GetFileName(AsyncFileUploadCustomerAttachment.FileName); fileName = Convert.ToString(DateTime.Now) + fileName; fileName = fileName.Replace("/", ""); fileName = fileName.Replace(":", ""); fileName = fileName.Replace(" ", ""); AsyncFileUploadCustomerAttachment.SaveAs(Server.MapPath("~/UploadedFiles/" + fileName)); if (Session["ProspectAttachment"] != null) { Session["ProspectAttachment"] = null; fileName = fileNameall + "," + fileName; Session["ProspectAttachment"] = fileName; } else { Session["ProspectAttachment"] = fileName; } } else { Session["UploadFileCountProspect"] = 0; } }
protected void asyncFileUpload_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { }
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { }
protected void fileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { lblmessage.Text = "Import file size is oversized."; }
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { try { Page.Validate(); bool datadone = (bool)Session["datadone"]; if (Page.IsValid && !datadone) { Session["datadone"] = true; string filePath = "~/Offline/" + e.FileName; GST_TRN_OFFLINE_INVOICE_AUDIT_TRAIL Auditrail; GST_TRN_OFFLINE offlineupload; string xml = string.Empty; if (AsyncFileUpload1.FailedValidation) { uc_sucess.ErrorMessage = "Your File Have Some Errors"; uc_sucess.Visible = true; } else if (!AsyncFileUpload1.HasFile) { uc_sucess.ErrorMessage = "Please Select File First"; uc_sucess.Visible = true; } else { Auditrail = new GST_TRN_OFFLINE_INVOICE_AUDIT_TRAIL(); offlineupload = new GST_TRN_OFFLINE(); Auditrail.ExcelName = e.FileName; Auditrail.JobName = e.FileName; Auditrail.CreatedBy = Common.LoggedInUserID(); Auditrail.CreatedDate = DateTime.Now; int MonthId = Convert.ToInt32(Session["MonthId"]); Auditrail.Month = Convert.ToByte(MonthId); Auditrail.Status = 1; Auditrail.UserID = unitOfwork.AspnetRepository.Find(x => x.GSTNNo == txtGstNo.Text).Id; Auditrail.InvoiceDate = DateTime.Now; var audittrailSaved = unitOfwork.OfflineAudittrailRepository.Create(Auditrail); //// getting the max audit trailID based on logged in user //// placed into // Session[""]=unitOfwork.OfflineAudittrailRepository.Find(a=>a.AuditTrailID wherer unitOfwork.Save(); Session["AuditTrailId"] = audittrailSaved.AuditTrailID; uc_B2B_Invoices.AuditTrailId = Convert.ToInt16(Session["AuditTrailId"].ToString()); //xml = ds.GetXml(); offlineupload.CreatedBy = Common.LoggedInUserID(); offlineupload.CreatedDate = DateTime.Now; offlineupload.AggregateTurnover = Convert.ToDecimal(txtTurnover.Text.Trim()); offlineupload.AggregateTurnoverQuater = Convert.ToDecimal(txtTurnoverAToJ.Text.Trim()); offlineupload.FileType = Convert.ToByte(ddlGST.SelectedValue.ToString()); offlineupload.SupplierGSTIN = txtGstNo.Text.Trim(); offlineupload.Month = Convert.ToByte(MonthId); offlineupload.Fin_ID = Convert.ToInt32(ddlfinYear.SelectedValue.ToString()); offlineupload.UploadedBy = Common.LoggedInUserID(); offlineupload.UploadStatus = 1; offlineupload.Section = 0; offlineupload.AuditTrailID = Auditrail.AuditTrailID; // finyear.ExcelData = xml; unitOfwork.OfflineRepository.Create(offlineupload); unitOfwork.Save(); filePath = "~/Offline/" + AsyncFileUpload1.FileName; //ds = cls_ExcelReader.ExcelReadDataSet(Server.MapPath(filePath)); uc_sucess.SuccessMessage = "Import file return successfully."; uc_sucess.Visible = true; AsyncFileUpload1.SaveAs(Server.MapPath(filePath)); // SaveOfflineData(filePath) ; // offlineObj.SaveOfflineData(ds, txtGstNo.Text.Trim(), Common.LoggedInUserID()); DataSet ds = cls_ExcelReader.ExcelReadDataSet(Server.MapPath(filePath)); ofline.SaveExcelOffLineData(ds, txtGstNo.Text.Trim(), Common.LoggedInUserID(), offlineupload.OfflineID.ToString()); } } else { throw new Exception(); } } catch (Exception ex) { cls_ErrorLog ob = new cls_ErrorLog(); cls_ErrorLog.LogError(ex, Common.LoggedInUserID()); } }
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { string filePath = "~/Offline/" + e.FileName; AsyncFileUpload1.SaveAs(Server.MapPath(filePath)); }
/*private void PopulateTreeView(List<disaggregation> parentList, int? parentId, TreeNode treeNode) * { * foreach(var disagData in parentList) * { * TreeNode child = new TreeNode * { * Text = disagData.disaggregation_name, * Value = disagData.id.ToString(), * ToolTip = disagData.id.ToString() * }; * * var _data2 = (from data in db.disaggregations * where data.disaggregation_id == disagData.id * select data).ToList(); * * if (parentId == null) * { * TreeView1.Nodes.Add(child); * * PopulateTreeView(_data2, disagData.id, child); * * } * else * { * treeNode.ChildNodes.Add(child); * * foreach (var myData in _data2) * { * TreeNode myChild = new TreeNode * { * Text = myData.disaggregation_name, * Value = myData.id.ToString(), * ToolTip = "3rd level " + myData.id.ToString() * }; * * var _data3 = (from data in db.disaggregations * where data.disaggregation_id == myData.id * select data).ToList(); * * PopulateTreeView(_data3, myData.id, myChild); * * child.ChildNodes.Add(myChild); * } * } * } * }*/ /*private string display(int indicator_id) * { * var _indi = from data in db.project_indicator_disaggregation * where data.project_indicator_id == indicator_id * select data; * * * string text = string.Empty; * * foreach (var indi in _indi) * { * var _dat = (from data in db.disaggregations * where data.id == indi.disaggregation_id * select data).Single(); * * System.Text.StringBuilder sData = new System.Text.StringBuilder(); * int? myId = _dat.disaggregation_id; * * sData.Insert(0, _dat.disaggregation_name); * * while (myId != null) * { * var _datq = (from data in db.disaggregations * where data.id == myId * select data).Single(); * * myId = _datq.disaggregation_id; * sData.Insert(0, _datq.disaggregation_name + " > "); * } * //sData.AppendLine().Append(" || ").AppendLine(); * text += sData + " || "; * } * * return text; * }*/ protected void FSUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { string fileName = System.IO.Path.GetFileName(FSUpload.FileName); FSUpload.SaveAs(Server.MapPath("ReportUploads/") + fileName); }
protected void fileExcelUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { if (fileExcelUpload.PostedFile == null || fileExcelUpload.PostedFile.ContentLength == 0) { return; } var msPath1 = Path.GetPathRoot(fileExcelUpload.PostedFile.FileName); var fileName = (Path.GetFileName(fileExcelUpload.PostedFile.FileName)); string strFileType = Path.GetExtension(fileName).ToLower(); if (msPath1 == string.Empty) { msPath1 = Server.MapPath(Constants.UserExcelFileDirectory); new DirectoryInfo(msPath1).CreateDirectory(); fileExcelUpload.PostedFile.SaveAs(Path.Combine(msPath1, fileName)); return; } string path = Path.Combine(msPath1); string connString = ""; //Connection String to Excel Workbook if (strFileType.Trim() == ".xls") { connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\""; } else if (strFileType.Trim() == ".xlsx") { //connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;"; } string query = "SELECT Code,Name,ContactPerson,Address,Location,Country,State,Zip,Email,Phone,Mobile,Web Site FROM [Customer$]"; OleDbConnection conn = new OleDbConnection(connString); string script = string.Empty; string script1 = string.Empty; int i = 1; try { if (conn.State == ConnectionState.Closed) { conn.Open(); } OleDbCommand cmd = new OleDbCommand(query, conn); OleDbDataReader odr = cmd.ExecuteReader(); var accounts = new Accounts(); while (odr.Read()) { i++; var code = odr["Code"].ToString().Trim(); if (string.IsNullOrEmpty(code)) { script1 += " - " + "Code is empty @ line No. : " + i.ToString(); } var name = odr["Name"].ToString().Trim(); if (string.IsNullOrEmpty(name)) { script1 += " - " + "Code is empty @ line No. : " + i.ToString(); } var loc = odr["Location"].ToString().Trim(); if (string.IsNullOrEmpty(loc)) { script1 += " - " + "Location is empty @ line No. : " + i.ToString(); } var country = odr["Country"].ToString().Trim(); if (string.IsNullOrEmpty(country)) { script1 += " - " + "Country is empty @ line No. : " + i.ToString(); } var state = odr["State"].ToString().Trim(); if (string.IsNullOrEmpty(state)) { script1 += " - " + "State is empty @ line No. : " + i.ToString(); } if (script == string.Empty && script1 == string.Empty) { Action = Constants.InsertAction; accounts.Add(new Account { SName = code, Name = name, Type = LType, Created = CreatedDate, Sub = Constants.LedgerSub, LMode = LMode, FGroup = FGroup, ContactPerson = odr["ContactPerson"].ToString().Trim(), Address = new Address { Street = odr["Address"].ToString().Trim(), City = loc, State = state, Country = country, ZipCode = odr["Zip"].ToString().Trim(), Mobile = odr["Mobile"].ToString().Trim(), Email = odr["Email"].ToString().Trim(), Phone = odr["Phone"].ToString().Trim(), WebSite = odr["WebSite"].ToString().Trim(), }, Parent = LType == Constants.Customers ? Constants.LabelCustomer : LType == Constants.Vendors ? Constants.LabelVendor : string.Empty, Action = Action, DataBaseInfo = UserContext.DataBaseInfo, }); } else { CustomMessageControl.MessageBodyText = script + script1; CustomMessageControl.MessageType = MessageTypes.Error; CustomMessageControl.ShowMessage(); } } if (script == string.Empty && script1 == string.Empty) { if (_controlPanel.SetAccounts(accounts)) { CustomMessageControl.MessageBodyText = GlobalCustomResource.PartyMasterSaved; CustomMessageControl.MessageType = MessageTypes.Success; CustomMessageControl.ShowMessage(); AuditLog.LogEvent(UserContext, SysEventType.INFO, "PARTYMASTER SAVED", GlobalCustomResource.PartyMasterSaved, true); clearForm(); DivAction = false; BindData(BindType.List); ScriptManager.RegisterStartupScript(Page, typeof(Page), "openTabFunctionCall", "openTab(1)", true); } else { CustomMessageControl.MessageBodyText = GlobalCustomResource.PartyMasterFailed; CustomMessageControl.MessageType = MessageTypes.Error; CustomMessageControl.ShowMessage(); AuditLog.LogEvent(UserContext, SysEventType.INFO, "PARTYMASTER UPDATE FAILED", GlobalCustomResource.PartyMasterFailed, true); } } } catch (Exception ex) { CustomMessageControl.MessageBodyText = ex.Message; CustomMessageControl.MessageType = MessageTypes.Error; CustomMessageControl.ShowMessage(); } finally { conn.Close(); conn.Dispose(); } uplView.Update(); }
protected void UploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { Session["ImageBytes"] = Convert.ToBase64String(afuImage1.FileBytes); }
protected void AsyncFileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { lblStatus.Text = e.statusMessage; lblStatus.Visible = true; }
private void Upload(AjaxControlToolkit.AsyncFileUploadEventArgs e) { if (string.IsNullOrEmpty(FileSaveDirectory)) { lblMessage.Visible = true; } if (!file_upload.HasFile) { return; } //if(FileAcquireMode== DbHelper.StaticValues.FileAcquireMode.Single) var fileName = Path.GetFileName(e.FileName); if (fileName == null) { return; } //ADDED later if (FileType != "All") { if (!file_upload.ContentType.ToLower().Contains(FileType.ToLower())) { lblMessage.Visible = true; lblMessage.Text = "Only " + FileType + " allowed"; _unwantedfileType = true; return; } } //added later if (FileExtension != "All") { var exts = FileExtension.ToLower().Split(new char[] { ',' }); var fileExt = Path.GetExtension(file_upload.FileName.ToLower()); if (exts.Length >= 1) { var foundMatch = false; foreach (var ext in exts) { var trimmed = ext.Trim(); if (fileExt == trimmed) { foundMatch = true; break; } } if (!foundMatch) { lblMessage.Visible = true; lblMessage.Text = "Only " + FileExtension + " files allowed"; _unwantedfileType = true; return; } } //if (Path.GetExtension(file_upload.FileName.ToLower()) != (FileExtension.ToLower())) //{ // lblMessage.Visible = true; // lblMessage.Text = "Only " + FileExtension.TrimStart('.') + " files allowed"; // _unwantedfileType = true; // return; //} } //var extension = Path.GetExtension(fileName); //using (var helper = new Academic.DbHelper.DbHelper.WorkingWithFiles()) { var extension = Path.GetExtension(fileName); var s = Guid.NewGuid().ToString() + extension; count = 0; string guidName = GetNewFileName(s); count = 0; if (guidName == "") { file_upload.BackColor = Color.Red; //throw ; return; } var fileUploadPath = Path.Combine(Server.MapPath(FileSaveDirectory), guidName); file_upload.SaveAs(fileUploadPath); //copied from another file so keep it. //var url = "~/Content/Images/CourseFileResource/" + fileName; //ScriptManager.RegisterStartupScript(this, this.GetType(), "fileName", // "top.$get(\"" + hdnFileFolder.ClientID + "\").value = '" + url + "';", true); var iconPath = GetIconForFile(guidName); var wrappedName = fileName; //if (fileName.Length > 7) //{ // wrappedName = fileName;//.Substring(0, 7) + "..."; //} //for (var i=0;i<fileName.Length;i++)// f in fileName) //{ // if (i%4 == 0 && i != 0) // { // wrappedName += "<wbr/>" + fileName[i]; // } // else wrappedName += fileName[i]; //} var valuetoSave = new FileResourceEventArgs() { FileDisplayName = wrappedName, FilePath = FileSaveDirectory + guidName, IconPath = iconPath , FileSizeInBytes = file_upload.PostedFile.ContentLength , FileType = file_upload.PostedFile.ContentType , Visible = true }; var files = Session["FilesList" + PageKey] as List <FileResourceEventArgs>; var localId = (files == null ? 0 : files.Count) + 1; LocalId = localId; valuetoSave.LocalId = localId.ToString(); //LocalId++; //if (FileAcquireMode == Enums.FileAcquireMode.Single) //{ // //here delete the previous uploaded file // DeletePreviousUploadedFile(); // Session["JustUploaded" + PageKey] = valuetoSave; //} Session["LatestFile" + PageKey] = valuetoSave; } }
protected void fileXlsx_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { var bytes = fileXlsx.FileBytes; Session["_XlsxCatalogoReceptores"] = bytes; }
protected void file_upload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { Upload(e); }
/// <summary> /// Handles the UploadedComplete event of the FileUpload1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="AjaxControlToolkit.AsyncFileUploadEventArgs" /> instance containing the event data.</param> protected void FileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { _postedAttachment = FileUpload1.PostedFile; }