Hey guys,
I'm new here and I have a question.
I have this code and I need to remove the part where it adds the information to the DB.
I tried many things (without knowing html), but none worked.
I think, this line " DB.Instance.InsInfo(info);" is the one who enters the data to the DB but i couldn't make it work without it.
Please HELP!
Thanks!!
Jason.
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Security.Policy;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
public partial class Main : BasePage
{
public class ShowResult
{
public string Type { get; set;}
public string Value { get; set;}
public string Action { get; set; }
public ShowResult(string type, string value, string action)
{
Type = type;
Value = value;
Action = action;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (CurrentUser == null)
{
Response.Redirect("Login.aspx");
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
List<ShowResult> showResult = new List<ShowResult>();
string allInfo = txtInfo.Text;
var separator = new[] {"\r\n"};
var inputArray = allInfo.Split(separator,StringSplitOptions.None);
foreach (var s in inputArray)
{
Info info = new Info();
info.UserId = CurrentUser.Id;
info.Type = s.Contains("@") ? "Email" : "Domain";
if (info.Type.Equals("Domain"))
{
if (s.Contains("http://www."))
{
info.Value = s.Substring(11, s.Length - 11);
}
else if (s.Contains("http://"))
{
info.Value = s.Substring(7, s.Length - 7);
}
else if (s.Contains("www."))
{
info.Value = s.Substring(4, s.Length - 4);
}
else
{
info.Value = s;
}
}
else
{
info.Value = s;
}
var new_s = info.Value.Split('/');
info.Value = new_s[0];
var res = DB.Instance.InsInfo(info);
if (res =="1")
{
showResult.Add(new ShowResult(info.Type,info.Value,"Approved"));
}
else if (res == CurrentUser.Username)
{
showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + CurrentUser.Username));
}
else
{
showResult.Add(new ShowResult(info.Type, info.Value, "Exist by: " + res));
}
}
grdResults.DataSource = showResult;
grdResults.DataBind();
}
protected void grdResults_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label action = (Label)e.Row.FindControl("lblAction");
if (action.Text.Contains("Approved"))
{
action.Style["background-color"] = "green";
//action.Style["color"] = "white";
}
else if (action.Text.Contains(CurrentUser.Username))
{
action.Style["background-color"] = "yellow";
//action.Style["color"] = "white";
}
else
{
action.Style["background-color"] = "red";
}
}
}
}