public void Binddata() { string from = txtFrom.Text; string to = txtTo.Text; string username, catid, operator_id; if (Session["username"] != null || Session["operator_id"] != null) { username = Session["username"].ToString(); catid = Convert.ToString(Session["category"]); operator_id = Convert.ToString(Session["operator_id"]); } else { Session.Abandon(); Response.Redirect("~/Login.aspx"); return; } Hashtable htAddPlanParams = getParamsData(); Hashtable htResponse = new Hashtable(); Cls_Business_UserAccountMap objTran = new Cls_Business_UserAccountMap(); htResponse = objTran.UserAccApp_Details(htAddPlanParams, username, Session["UserUpdate"].ToString()); DataTable dt = null; //check for exception if (htResponse["htResponse"] != null) { dt = (DataTable)htResponse["htResponse"]; } if (dt == null) { Response.Redirect("~/ErrorPage.aspx"); return; } lblSearchParams.Text = Server.HtmlDecode("<b style='color:#094791;'></b><b>Transaction From : </b>" + from + "<b>Transaction To : </b>" + to); if (dt.Rows.Count == 0) { btngrnExel.Visible = false; grdUserAccMap.Visible = false; lblSearchMsg.Text = "No data found"; } else { btngrnExel.Visible = true; grdUserAccMap.Visible = true; lblSearchMsg.Text = ""; ViewState["searched_trans"] = dt; grdUserAccMap.DataSource = dt; grdUserAccMap.DataBind(); ScriptManager.RegisterStartupScript(Page, this.GetType(), "Key", "<script>MakeStaticHeader('" + grdUserAccMap.ClientID + "', 400, 1200 , 46 ,false); </script>", false); div1.Visible = false; DivMainContent.Visible = true; } }
private void callprocedureTemp() { String IPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (IPAddress == null) { IPAddress = Request.ServerVariables["REMOTE_ADDR"]; } string IPAdd = Convert.ToString(IPAddress); Cls_Business_UserAccountMap obj = new Cls_Business_UserAccountMap(); string pro_output = obj.UserAccountMap(Session["username"].ToString().Trim(), IPAdd, "", "", "", "B"); if (pro_output.Split('#')[0] == "9999") { lblStatusHeading.Text = "File Upload : Successful"; lblStatus.Text = ""; } else { lblStatusHeading.Text = pro_output.Split('#')[1].ToString();// "File Upload : Failed"; } }
protected void btnUpload_Click(object sender, EventArgs e) { if (rblMode.SelectedValue == "0") { if (txtAccountNo.Text.Length > 0) { string valid = SecurityValidation.chkData("N", txtAccountNo.Text); if (valid == "") { String IPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (IPAddress == null) { IPAddress = Request.ServerVariables["REMOTE_ADDR"]; } string IPAdd = Convert.ToString(IPAddress); Cls_Business_UserAccountMap obj = new Cls_Business_UserAccountMap(); string pro_output = obj.UserAccountMap(Session["username"].ToString().Trim(), IPAdd, ddlLco.SelectedValue, txtAccountNo.Text, rblAction.SelectedValue.ToString(), "S"); if (pro_output.Split('#')[0] == "9999") { lblStatusHeading.Text = "Successful"; lblStatus.Text = ""; } else { lblStatusHeading.Text = pro_output.Split('#')[1].ToString();// "File Upload : Failed"; } txtAccountNo.Text = ""; ddlLco.SelectedIndex = 0; rblAction.SelectedValue = "Y"; } else { lblStatusHeading.Text = valid.ToString(); return; } } } else { lblStatusHeading.Text = ""; lblStatus.Text = ""; DataTable temp = new DataTable(); temp.Dispose(); string file_name = ""; if (!fupData.HasFile) { lblStatusHeading.Text = "File Upload : Failed"; lblStatus.Text = "Select non-empty tab deliminated file first and try again"; return; } //check - file extension if (fupData.PostedFile.ContentType != "text/plain") { lblStatusHeading.Text = "File Upload : Failed"; lblStatus.Text = "Only tab deliminated text(.txt) files are allowed"; return; } else { if (!SecurityValidation.SizeUploadValidation(fupData)) { lblStatusHeading.Text = "File Upload : Failed"; lblStatus.Text = "Please upload file less than 5MB"; return; } } if (fupData.PostedFile.ContentLength == 0) { lblStatusHeading.Text = "File Upload : Failed"; lblStatus.Text = "File does not have contents"; return; } //check - directory and save file in diectory string directoryPath = string.Format(@"D:/DataUpload/HathwayBulk/{0}", Session["username"].ToString().Trim()); string filePath = directoryPath + "/" + fupData.PostedFile.FileName; try { if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } fupData.SaveAs(filePath); } catch (Exception ex) { lblStatusHeading.Text = "File Upload : Failed"; lblStatus.Text = ex.Message.ToString(); return; } Cls_Presentation_Helper helper = new Cls_Presentation_Helper(); DateTime date = DateTime.Now; string cur_timestamp = DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss"); string cur_time = DateTime.Now.ToString("dd-MMM-yyyy_hh:mm:ss"); file_name = fupData.PostedFile.FileName; Random random = new Random(); upload_id = username + "_" + cur_time + "_" + random.Next(1000, 9999); ViewState["upload_id"] = upload_id; string table_columns = "( var_user_acc_username, var_user_acc_accountno, Var_user_acc_activeflag)"; string uploadResult = helper.cDataUpload("D:\\DataUpload\\HathwayBulk\\" + Session["username"].ToString().Trim() + "\\" + fupData.PostedFile.FileName, "D:\\DataUpload\\HathwayBulk\\" + Session["username"].ToString().Trim() + "\\HathwayUserAccMappingCTL.txt", "D:\\DataUpload\\HathwayBulk\\" + Session["username"].ToString().Trim() + "\\HathwayUserAccMappingLOG.log", table_columns, "Upassdb", "UPASS", "cba", "AOUP_LCOPRE_USER_ACC_MAP_raw", "" ); if (uploadResult == "0") { callprocedureTemp(); } else { if (uploadResult == "") { lblStatus.Text = "Error While Uploading..."; lblStatus.Visible = true; } else { lblStatus.Text = uploadResult.ToString(); lblStatus.Visible = true; } } } }