protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserName"] == null) { //Response.Write("<script LANGUAGE='JavaScript' >alert('You are not logged in, Please login to see your side!);href='~/'</script>",true ); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('You are not logged in, Please login to see your side.');window.location ='Login.aspx'", true); return; } DataTable dt = new DataTable(); dt.Columns.Add("File", typeof(string)); dt.Columns.Add("Size", typeof(string)); dt.Columns.Add("Type", typeof(string)); foreach (string strFile in Directory.GetFiles(Server.MapPath("~/Document/"))) { FileInfo fi = new FileInfo(strFile); dt.Rows.Add(fi.Name, fi.Length, GetFileTypeByExtenstion(fi.Extension)); GridView_Info.DataSource = dt; GridView_Info.DataBind(); } } }
private void showData() { TBInfoService infoService = new TBInfoService(); int typeId = Convert.ToInt32(DropDownList_Type.SelectedValue); string key = TextBox_Keys.Text.Trim(); ArrayList list = infoService.GetInfoList(typeId, key, 0, -1, searchtype); GridView_Info.DataSource = list; GridView_Info.DataBind(); }
protected void Button_Upload_Click(object sender, EventArgs e) { if (Fileupload.HasFile) { string fileExtenstion = System.IO.Path.GetExtension(Fileupload.FileName); if (fileExtenstion.ToLower() != ".doc" && fileExtenstion.ToLower() != ".docx" && fileExtenstion.ToLower() != ".xlsx" && fileExtenstion.ToLower() != ".xls" && fileExtenstion.ToLower() != ".jpg" && fileExtenstion.ToLower() != ".png" && fileExtenstion.ToLower() != ".txt" && fileExtenstion.ToLower() != ".pdf") { Response.Write("<script LANGUAGE='JavaScript' >alert('File extension are not matched!')</script>"); } else { int uplodedfileSize = Fileupload.PostedFile.ContentLength; if (uplodedfileSize > 2097152) { Response.Write("<script LANGUAGE='JavaScript' >alert('Maximum File size (2MB) exceeded!')</script>"); } else { Fileupload.PostedFile.SaveAs(Server.MapPath("~/Document/") + Fileupload.FileName); } } } DataTable dt = new DataTable(); dt.Columns.Add("File", typeof(string)); dt.Columns.Add("Size", typeof(string)); dt.Columns.Add("Type", typeof(string)); foreach (string strFile in Directory.GetFiles(Server.MapPath("~/Document/"))) { FileInfo fi = new FileInfo(strFile); dt.Rows.Add(fi.Name, fi.Length, GetFileTypeByExtenstion(fi.Extension)); GridView_Info.DataSource = dt; GridView_Info.DataBind(); } }
protected void GridView_Info_RowEditing(object sender, GridViewEditEventArgs e) { GridView_Info.EditIndex = e.NewEditIndex; GridView_Info.DataBind();// your gridview binding function //Response.Redirect("~/Account/MemberEdit.aspx"); }
protected void GridView_Info_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView_Info.PageIndex = e.NewPageIndex; GridView_Info.DataBind(); }
protected bool Search_RedovisningBySearchItem(string Searchdate1, string Searchdate2) //protected void TextBox_MemberID_TextChanged(object sender, EventArgs e) { try { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot"); System.Configuration.ConnectionStringSettings connStringSQL; connStringSQL = rootWebConfig.ConnectionStrings.ConnectionStrings["DefaultConnection"]; string MyconnStr = null; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { if (connStringSQL != null) { if (connStringSQL.ProviderName == "System.Data.SqlClient") { MyconnStr = connStringSQL.ConnectionString; SqlConnection conn = new SqlConnection(@"" + MyconnStr + ""); conn.Open(); //Image_MemberPicture.ImageUrl = ImageConverter(strBase64); //PreviousBalnace SqlCommand MyCommand_PreVal; string MySqlString_PreVal = null; SqlDataReader dataReader_PreVal; MySqlString_PreVal = "select KONTO,SHORT_DESC,'" + "2018-01-01" + "'+' till '+'" + Searchdate1 + "' as TRANSDATE," + "RED_TYP_DESC,t1.ACC_ID,t1.RED_TYP,isnull((CASE WHEN t1.TRANTYPE='D' THEN REDOVISNING_AMT END),0.00) as 'Debit'," + " isnull((CASE WHEN t1.TRANTYPE='C' THEN REDOVISNING_AMT END),0.00) as 'Kredit'" + " from " + " ((select ACC_ID,RED_TYP,TRANTYPE,SUM(TR_AMOUNT) as REDOVISNING_AMT from [NRB_MMS].[dbo].[Redovisning] where datum <'" + Searchdate1 + "'" + " group by ACC_ID,RED_TYP,TRANTYPE) as t1" + " inner join" + " (select * from [NRB_MMS].[dbo].[Red_typ]) as t2 " + " on t1.ACC_ID=t2.ACC_ID and t1.RED_TYP=t2.RED_TYP) order by ACC_ID,RED_TYP,TRANTYPE desc "; MyCommand_PreVal = new SqlCommand(MySqlString_PreVal, conn); dataReader_PreVal = MyCommand_PreVal.ExecuteReader(); GridView_PreviousBalance.DataSource = null; GridView_PreviousBalance.DataBind(); if (dataReader_PreVal.HasRows) { GridView_PreviousBalance.Visible = true; GridView_PreviousBalance.DataSource = dataReader_PreVal; GridView_PreviousBalance.DataBind(); } else { GridView_PreviousBalance.DataSource = null; GridView_PreviousBalance.DataBind(); GridView_PreviousBalance.Visible = false; } dataReader_PreVal.Close(); MyCommand_PreVal.Dispose(); //Present Balance according to date SqlCommand MyCommand; string MySqlString = null; SqlDataReader dataReader; //MySqlString = "Select * FROM [NRB_MMS].[dbo].[Member] where MemberID= " + MemberID + ""; MySqlString = "select KONTO,SHORT_DESC,'" + Searchdate1 + "'+' till '+'" + Searchdate2 + "' as TRANSDATE,RED_TYP_DESC,t1.ACC_ID,t1.RED_TYP,isnull((CASE WHEN t1.TRANTYPE='D' THEN REDOVISNING_AMT END),0.00) as 'Debit'," + " isnull((CASE WHEN t1.TRANTYPE='C' THEN REDOVISNING_AMT END),0.00) as 'Kredit'" + " from " + " ((select ACC_ID,RED_TYP,TRANTYPE,SUM(TR_AMOUNT) as REDOVISNING_AMT from [NRB_MMS].[dbo].[Redovisning] where datum>='" + Searchdate1 + "'" + " and datum<='" + Searchdate2 + "' group by ACC_ID,RED_TYP,TRANTYPE) as t1" + " inner join" + " (select * from [NRB_MMS].[dbo].[Red_typ]) as t2 " + " on t1.ACC_ID=t2.ACC_ID and t1.RED_TYP=t2.RED_TYP) order by ACC_ID,RED_TYP,TRANTYPE desc "; //MySqlString = "Select * FROM [NRB_MMS].[dbo].[Member] where MemberID like '%" + SearchItem + "%'" + // " or FAMILYID like '%" + SearchItem + "%' or pers_nr like '%" + SearchItem + "%' or FAMILYNAME like '%" + SearchItem + "%'" + // " or MemberFNAME like '%" + SearchItem + "%' or MemberLNAME like '%" + SearchItem + "%' or EMAIL_USERNAME like '%" + SearchItem + "%'" + // " or phone_nr like '%" + SearchItem + "%'"; MyCommand = new SqlCommand(MySqlString, conn); dataReader = MyCommand.ExecuteReader(); GridView_Info.DataSource = null; GridView_Info.DataBind(); if (dataReader.HasRows) { GridView_Info.Visible = true; GridView_Info.DataSource = dataReader; GridView_Info.DataBind(); } else { GridView_Info.DataSource = null; GridView_Info.DataBind(); GridView_Info.Visible = false; dataReader.Close(); MyCommand.Dispose(); return(false); } } } } } catch (Exception ex) { throw new ApplicationException(ex.Message.ToString()); } return(false); //IsSearch_MemberID = 1; }
private void BindGridViewData_forallMember() { try { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot"); System.Configuration.ConnectionStringSettings connStringSQL; connStringSQL = rootWebConfig.ConnectionStrings.ConnectionStrings["DefaultConnection"]; string MyconnStr = null; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { if (connStringSQL != null) { if (connStringSQL.ProviderName == "System.Data.SqlClient") { MyconnStr = connStringSQL.ConnectionString; SqlConnection conn = new SqlConnection(@"" + MyconnStr + ""); conn.Open(); //Image_MemberPicture.ImageUrl = ImageConverter(strBase64); SqlCommand MyCommand; string MySqlString = null; SqlDataReader dataReader; //MySqlString = "Select * FROM [NRB_MMS].[dbo].[Member] order by FAMILYID,MemberID ASC"; MySqlString = "SELECT ROW_NUMBER() OVER(ORDER BY MemberID ASC) AS ROWNR, * FROM [NRB_MMS].[dbo].[Member] order by FAMILYID,MemberID ASC"; MyCommand = new SqlCommand(MySqlString, conn); //MyCommand.Parameters.AddWithValue("@user", TextBox_UserName.Text); dataReader = MyCommand.ExecuteReader(); GridView_Info.DataSource = null; GridView_Info.DataBind(); if (dataReader.HasRows) { GridView_Info.Visible = true; GridView_Info.DataSource = dataReader; GridView_Info.DataBind(); } dataReader.Close(); dataReader.Dispose(); } else { Response.Write("<script LANGUAGE='JavaScript' >alert('Ingen information hittades!')</script>"); //dataReader.Close(); //MyCommand.Dispose(); } } } } catch (Exception ex) { throw new ApplicationException(ex.Message.ToString()); } //IsSearch_MemberID = 1; }