Click here to Skip to main content
15,887,477 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
AnswerRe: I fix it!!!111 PinPopular
ZurdoDev12-Jan-15 4:10
professionalZurdoDev12-Jan-15 4:10 
GeneralRe: I fix it!!!111 Pin
CHill6012-Jan-15 4:26
mveCHill6012-Jan-15 4:26 
GeneralRe: I fix it!!!111 Pin
Ray Raymos18-Jan-15 13:36
Ray Raymos18-Jan-15 13:36 
GeneralRe: I fix it!!!111 Pin
BuggyTimes20-Jan-15 1:07
BuggyTimes20-Jan-15 1:07 
GeneralNew record... Pin
Kornfeld Eliyahu Peter21-Dec-14 11:14
professionalKornfeld Eliyahu Peter21-Dec-14 11:14 
GeneralRe: New record... Pin
Sander Rossel21-Dec-14 11:22
professionalSander Rossel21-Dec-14 11:22 
GeneralRe: New record... Pin
Kornfeld Eliyahu Peter21-Dec-14 11:27
professionalKornfeld Eliyahu Peter21-Dec-14 11:27 
GeneralRe: New record... Pin
Sander Rossel21-Dec-14 11:35
professionalSander Rossel21-Dec-14 11:35 
Kornfeld Eliyahu Peter wrote:
I'm only regret, that this gem will vanish soon...
That can be easily fixed Smile | :)
EDIT: Not that easily I guess... Copy/paste messes up the HTML a bit... Well, it's a pretty good impression anyway Smile | :)
Someone in QA wrote:
----Add.aspx-----


<%@ Page Title="" Language="C#" MasterPageFile="~/main.Master" AutoEventWireup="true" CodeBehind="Add.aspx.cs" Inherits="indianRailway.Add" %>
<asp:content id="Content1" contentplaceholderid="head" runat="server">

.auto-style1 {
text-align: left;
}
.auto-style3 {
font-size: xx-small;
}
.auto-style4 {
text-align: left;
}


<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="server">





EMPLOYEE DETAILS


Train No.

<asp:textbox skinid="abc" id="TextBoxTrainNo" runat="server" textmode="Number">
<asp:requiredfieldvalidator cssclass="popout" display="Dynamic" enableclientscript="false" id="RequiredFieldValidator1" runat="server" errormessage="Please specify" forecolor="Red" controltovalidate="TextBoxTrainNo">



Train Name

<asp:textbox skinid="abc" id="TextBoxTrainName" runat="server">
<asp:requiredfieldvalidator cssclass="validat" display="Dynamic" enableclientscript="false" id="RequiredFieldValidator2" runat="server" controltovalidate="TextBoxTrainName" errormessage="Please Specify" forecolor="Red">



Source Station

<asp:textbox skinid="abc" id="TextBoxSourceStation" runat="server">
<asp:requiredfieldvalidator cssclass="validat" display="Dynamic" enableclientscript="false" id="RequiredFieldValidator3" runat="server" controltovalidate="TextBoxSourceStation" errormessage="Please Specify" forecolor="Red">



Destination Station

<asp:textbox id="TextBoxDest" runat="server">
<asp:requiredfieldvalidator id="RequiredFieldValidator8" runat="server" controltovalidate="TextBoxDest" display="Dynamic" enableclientscript="False" errormessage="please specify" forecolor="Red">



Departure Time

<asp:textbox id="TextBoxDepart" skinid="abc" runat="server" textmode="Time">
<asp:requiredfieldvalidator cssclass="validat" display="Dynamic" enableclientscript="false" id="RequiredFieldValidator4" runat="server" controltovalidate="TextBoxDepart" errormessage="Please Specify" forecolor="Red">



Arrival Time

<asp:textbox skinid="abc" id="TextBoxArrival" runat="server" textmode="Time">
<asp:requiredfieldvalidator cssclass="validat" display="Dynamic" enableclientscript="false" id="RequiredFieldValidator5" runat="server" controltovalidate="TextBoxArrival" errormessage="Please Specify" forecolor="Red">



Available Days
(write days & use comma for seperation)

<asp:textbox id="TextBoxAvlbledays" runat="server">
<asp:requiredfieldvalidator cssclass="validat" display="Dynamic" enableclientscript="false" id="RequiredFieldValidator7" runat="server" controltovalidate="TextBoxAvlbledays" errormessage="Please Select" forecolor="Red" initialvalue="--Select--">




<asp:button text="Submit" id="Submit" runat="server" onclick="Submit_Click">











----Add.aspx.cs----



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using BllFactory;
using BO;
using BoFactory;
using Types;

namespace indianRailway
{
public partial class Add : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["MySession"] == null)
{
((Button)Master.FindControl("Button1")).Visible = false;
((Label)Master.FindControl("Label1")).Visible = false;
string message = "Oops! for this you have to login...";
ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('" + message + "'); window.location='" + Request.ApplicationPath + "MainLogin.aspx';", true);

}
else
{
((Button)Master.FindControl("Button1")).Visible = true;
((Label)Master.FindControl("Label1")).Visible = true;
((Label)Master.FindControl("Label1")).Text = "welcome : " + Convert.ToString(Session["MySession"]);

}
}

protected void Submit_Click(object sender, EventArgs e)
{
if (IsValid)
{
IboAdmin BoObj = BoFactory.BoFactoryAdmin.CreateInstanceOfBo();
BoObj.trainNo = Convert.ToInt64(TextBoxTrainNo.Text);
BoObj.trainName = TextBoxTrainName.Text;
BoObj.sourceStation = TextBoxSourceStation.Text;
BoObj.destinationStation = TextBoxDest.Text;


BoObj.departureTime = TextBoxDepart.Text;
BoObj.availableDyas = TextBoxAvlbledays.Text;
BoObj.arrivalTime = TextBoxArrival.Text;


IbllAdmin BllObj = BllFactory.BllFactoryAdmin.CreateInstanceOfBll();
long IdCatcher = BllObj.AddOfBll(BoObj);
if (IdCatcher == 0)
{

ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Details not saved... Please try again with Complete & correct details '); window.location='" + Request.ApplicationPath + "Add.aspx';", true);

}




else
{


ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Your details saved sucessfully, Please note your detail ID:" + IdCatcher + "'); window.location='" + Request.ApplicationPath + "Add.aspx';", true);


}
}

}
}
}






----main.Master----




<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="main.master.cs" Inherits="indianRailway.main" %>





<title>
<asp:contentplaceholder id="head" runat="server">


.auto-style1 {
font-size: xx-large;
}
.auto-style2 {
font-size: small;
}





        yourconvenience.com                                                                                                    
<asp:label id="Label1" runat="server" font-size="Small" text="Label" visible="False">
<asp:button id="Button1" runat="server" font-size="Small" onclick="Button1_Click" text="Sign Out" visible="False">

                                                                   Manage Everything Easily


<asp:menu id="Menu1" runat="server" backcolor="#333399" borderstyle="None" font-bold="True" font-italic="True" font-underline="False" forecolor="White" orientation="Horizontal" width="1350px">


<asp:menuitem text="Home" value="Home">
<asp:menuitem text="About Us" value="About Us">
<asp:menuitem text="Contact Us" value="Contact Us">
<asp:menuitem navigateurl="~/Add.aspx" text="Add New" value="Add New">
<asp:menuitem navigateurl="~/Manage.aspx" text="Manage Earlier " value="Manage Earlier ">




<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">


copyrights reserved








----main.Master.cs----

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace indianRailway
{
public partial class main : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Response.Redirect("MainLogin.aspx");
}
}
}



----MainLogin.aspx----


<%@ Page Title="" Language="C#" MasterPageFile="~/main.Master" AutoEventWireup="true" CodeBehind="MainLogin.aspx.cs" Inherits="indianRailway.MainLogin" %>
<asp:content id="Content1" contentplaceholderid="head" runat="server">

.table {
height:300px;
width:400px;
margin-top:20px;
}
td {
font-size:large;
background-color:wheat;
}
.button {
height:30px;
width:150px;
color:whitesmoke;
background-color:blue;
font-size:25px;

}
.button:hover {
color:whitesmoke;
background-color:green;
}
.textbox {
height:30px;
width:150px;
font-size:27px;
}
.auto-style18 {
width: 100%;
}
.auto-style19 {
font-size: x-large;
}
.auto-style20 {
height: 530px;
width: 667px;
}


<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="server">



 

Simply login to enjoy our services...

















Login


                               Username:

<asp:textbox id="TextBox1" runat="server">

<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" controltovalidate="TextBox1" enableclientscript="False" errormessage="please enter correct username" display="Dynamic" font-size="Small" forecolor="Red">



                               Password:

<asp:textbox id="TextBox2" runat="server" textmode="Password">

<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" controltovalidate="TextBox2" enableclientscript="False" errormessage="please enter correct password" display="Dynamic" font-size="Small" forecolor="Red">




<asp:button id="Button1" runat="server" text="login" width="85px" onclick="Button1_Click1">




 





-------MainLogin.aspx.cs---------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BO;
using BoFactory;
using BLL;
using BllFactory;
using Types;

namespace indianRailway
{
public partial class MainLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session.RemoveAll();
}

protected void Button1_Click1(object sender, EventArgs e)
{
if (IsValid)
{
IbllLogin BllObj = BllFactory.BllFactoryLogin.CreateInstanceOfBll();
IboLogin BoObj = BoFactory.BoFactoryLogin.CreateInstanceOfBo();
BoObj.name = TextBox1.Text.ToString();
BoObj.password = TextBox2.Text;
int i = BllObj.LoginCheckBll(BoObj);
if (i == 1)
{
Session["MySession"] = TextBox1.Text.ToString();
Response.Redirect("Add.aspx");
}
else
ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Incorrect username or password...Please try again'); window.location='" + Request.ApplicationPath + "MainLogin.aspx';", true);

}
else
{
TextBox1.Style.Add("border", "solid 1px red");
TextBox2.Style.Add("border", "solid 1px red");
}
}
}
}





----Manage.aspx----



<%@ Page Title="" Language="C#" MasterPageFile="~/main.Master" AutoEventWireup="true" CodeBehind="Manage.aspx.cs" Inherits="indianRailway.Manage" %>
<asp:content id="Content1" contentplaceholderid="head" runat="server">

<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="server">




<asp:panel height="490px" width="1200px" scrollbars="Horizontal" runat="server">
<asp:gridview id="GridView1" pagesize="15" horizontalalign="Center" verticalalign="Center" allowpaging="true" runat="server" autogeneratecolumns="False" cellpadding="4" forecolor="#333333" gridlines="None" onpageindexchanging="GridView1_PageIndexChanging" onrowcancelingedit="GridView1_RowCancelingEdit" onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating">



<asp:templatefield headertext="edit/delete">


<asp:linkbutton id="LinkButton3" commandname="Update" runat="server">Update
<asp:linkbutton id="LinkButton4" commandname="Cancel" runat="server">Cancel


<asp:linkbutton id="LinkButton1" commandname="Edit" runat="server">Edit
<asp:linkbutton id="LinkButton2" commandname="Delete" runat="server" onclientclick="return confirm('Are you sure you want to delete this?');">Delete



<asp:templatefield headertext="trainId" insertvisible="False" sortexpression="trainId">

<asp:label id="Label1" runat="server" text="<%# Eval("trainId") %>">


<asp:label id="Label11" runat="server" text="<%# Eval("trainId") %>">



<asp:templatefield headertext="trainNo" insertvisible="False" sortexpression="trainNo">

<asp:textbox id="TextBoxTrnO" runat="server" text="<%# Eval("trainNo") %>">


<asp:label id="Label111" runat="server" text="<%# Eval("trainNo") %>">


<asp:templatefield headertext="trainName" sortexpression="trainName">

<asp:textbox id="TextBoxTRnM" runat="server" text="<%# Eval("trainName") %>">


<asp:label id="Label2" runat="server" text="<%# Eval("trainName") %>">


<asp:templatefield headertext="sourceStation" sortexpression="sourceStation">

<asp:textbox id="TextBoxSorcStatn" runat="server" text="<%# Eval("sourceStation") %>">


<asp:label id="Label3" runat="server" text="<%# Eval("sourceStation") %>">


<asp:templatefield headertext="destinationStation" sortexpression="destinationStation">

<asp:textbox id="TextBoxDestStatn" runat="server" text="<%# Eval("destinationStation") %>">


<asp:label id="Label4" runat="server" text="<%# Eval("destinationStation") %>">


<asp:templatefield headertext="departureTime" sortexpression="departureTime">

<asp:textbox id="TextBoxDeprtTm" runat="server" text="<%# Eval("departureTime") %>">


<asp:label id="Label5" runat="server" text="<%# Eval("departureTime") %>">


<asp:templatefield headertext="availableDyas" sortexpression="availableDyas">

<asp:textbox id="TextBoxAvailbledays" runat="server" text="<%# Eval("availableDyas") %>">


<asp:label id="Label6" runat="server" text="<%# Eval("availableDyas") %>">


<asp:templatefield headertext="arrivalTime" sortexpression="arrivalTime">

<asp:textbox id="TextBoxArrvlTime" runat="server" text="<%# Eval("arrivalTime") %>">


<asp:label id="Label7" runat="server" text="<%# Eval("arrivalTime") %>">



<%--<asp:templatefield headertext="amount" sortexpression="amount">

<asp:textbox id="TextBoxAmt" runat="server" text="<%# Eval("amount") %>">


<asp:label id="Label8" runat="server" text="<%# Eval("amount") %>">


<asp:templatefield headertext="PreConditions" sortexpression="PreConditions">

<asp:textbox id="TextBoxPreconds" runat="server" text="<%# Eval("PreConditions") %>">


<asp:label id="Label9" runat="server" text="<%# Eval("PreConditions") %>">


<asp:templatefield headertext="PostConditions" sortexpression="PostConditions">

<asp:textbox id="TextBoxPostConds" runat="server" text="<%# Eval("PostConditions") %>">


<asp:label id="Label10" runat="server" text="<%# Eval("PostConditions") %>">



<asp:templatefield headertext="Remarks" sortexpression="Remarks">

<asp:textbox id="TextBoxRemarks" runat="server" text="<%# Eval("Remarks") %>">


<asp:label id="Label12" runat="server" text="<%# Eval("Remarks") %>">

--%>




<headerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">


<selectedrowstyle backcolor="#E2DED6" font-bold="True" forecolor="#333333">












----Manage.aspx.cs----





using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BO;
using BoFactory;
using BLL;
using BllFactory;
using Types;

namespace indianRailway
{
public partial class Manage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

if (Session["MySession"] == null)
{
((Button)Master.FindControl("Button1")).Visible = false;
((Label)Master.FindControl("Label1")).Visible = false;
string message = "Oops! for this you have to login...";
ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('" + message + "'); window.location='" + Request.ApplicationPath + "MainLogin.aspx';", true);

}
else
{
((Button)Master.FindControl("Button1")).Visible = true;
((Label)Master.FindControl("Label1")).Visible = true;
((Label)Master.FindControl("Label1")).Text = "welcome : " + Convert.ToString(Session["MySession"]);
}
if (!IsPostBack)
{
Bindgriddata();
}

}
public void Bindgriddata()
{
IbllAdmin BllObj = BllFactory.BllFactoryAdmin.CreateInstanceOfBll();
GridView1.DataSource = BllObj.ViewGridOfBll();
GridView1.DataBind();
}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{

}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Bindgriddata();
}

protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
Bindgriddata();

}

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow gvr = GridView1.Rows[e.RowIndex];
int id = Convert.ToInt32(((Label)gvr.FindControl("Label11")).Text);
IbllAdmin BllObj = BllFactory.BllFactoryAdmin.CreateInstanceOfBll();
int deleteCheck = BllObj.DeleteGridOfBll(id);
if (deleteCheck == 1)
{
Page.ClientScript.RegisterStartupScript(this.GetType(),
"alertkey", "alert('Record deleted sucessfully...');", false);
}

else
{
Page.ClientScript.RegisterStartupScript(this.GetType(),
"alertkey", "alert('Record not deleted');", false);
}
GridView1.EditIndex = -1;
Bindgriddata();
}

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
Bindgriddata();
}

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
IboAdmin BoObj = BoFactory.BoFactoryAdmin.CreateInstanceOfBo();
GridViewRow gvr = GridView1.Rows[e.RowIndex];

BoObj.trainId = Convert.ToInt64(((Label)gvr.FindControl("Label1")).Text);
BoObj.trainNo = Convert.ToInt64(((TextBox)gvr.FindControl("TextBoxTrnO")).Text);
BoObj.trainName = (((TextBox)gvr.FindControl("TextBoxTRnM")).Text);
BoObj.sourceStation = ((TextBox)gvr.FindControl("TextBoxSorcStatn")).Text;
BoObj.destinationStation = ((TextBox)gvr.FindControl("TextBoxDestStatn")).Text;
BoObj.departureTime = (((TextBox)gvr.FindControl("TextBoxDeprtTm")).Text);
BoObj.arrivalTime = (((TextBox)gvr.FindControl("TextBoxArrvlTime")).Text);
BoObj.availableDyas = (((TextBox)gvr.FindControl("TextBoxAvailbledays")).Text);

IbllAdmin objbll = BllFactory.BllFactoryAdmin.CreateInstanceOfBll();
int CheckUpdate = objbll.UpdateGridOfBll(BoObj);


if (CheckUpdate == 1)
Page.ClientScript.RegisterStartupScript(this.GetType(),
"alertkey", "alert('Details have been updated sucessfully');", false);

else
Page.ClientScript.RegisterStartupScript(this.GetType(),
"alertkey", "alert('Please try again with complete & correct details');", false);

GridView1.EditIndex = -1;
Bindgriddata();
}
}
}



----TypesAdmin.cs----

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Types
{
public interface IboAdmin
{

long trainNo { get; set; }
string trainName { get; set; }
string sourceStation { get; set; }
string destinationStation { get; set; }
string departureTime { get; set; }
string arrivalTime { get;set;}
string availableDyas { get; set; }
long trainId { get; set; }
}
public interface IbllAdmin
{
long AddOfBll(IboAdmin BoObj);
List ViewGridOfBll();
int UpdateGridOfBll(IboAdmin BoObj);
int DeleteGridOfBll(int x);
}
public interface IdalAdmin
{
long AddOfDal(IboAdmin BoObj);
List ViewGridOfDal();
bool UpdateGridOfDal(IboAdmin BoObj);
bool DeleteGridOfDal(int Id);
}
}


-----TypesLogin.cs----


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Types
{
public interface IboLogin
{
string name { get; set; }
string password { get; set; }
}
public interface IbllLogin
{
int LoginCheckBll(IboLogin BoObj);
}
public interface IdalLogin
{
bool LoginCheckDal(IboLogin BoObj);
}
}




----BoAdmin.cs----






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;

namespace BO
{
public class BoAdmin : IboAdmin
{


public long trainNo { get; set; }
public string trainName { get; set; }
public string sourceStation { get; set; }
public string destinationStation { get; set; }
public string departureTime { get; set; }
public string arrivalTime { get; set; }
public string availableDyas { get; set; }
public long trainId { get; set; }


}
}




----BoLogin.cs----



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;

namespace BO
{
public class BoLogin:IboLogin
{
public string name { get; set; }
public string password { get; set; }
}
}




----BoFactoryAdmin.cs----




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;
using BO;

namespace BoFactory
{
public static class BoFactoryAdmin
{
public static IboAdmin CreateInstanceOfBo()
{

IboAdmin BoObj = new BoAdmin();
return BoObj;
}
}
}





----BoFactoryLogin.cs----

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;
using BO;

namespace BoFactory
{
public static class BoFactoryLogin
{
public static IboLogin CreateInstanceOfBo()
{

IboLogin BoObj = new BoLogin();
return BoObj;
}
}
}






-----BllAdmin.cs-----


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;
using DAL;
using DalFactory;
using BO;

namespace BLL
{
public class BllAdmin: IbllAdmin
{
public long AddOfBll(IboAdmin BoObj)
{
long IdCatcher;
IdalAdmin DalObj = DalFactory.DalFactoryAdmin.CreateInstanceOfDal();

IdCatcher = DalObj.AddOfDal(BoObj);
if (IdCatcher != 0)
return IdCatcher;
else
return 0;
}
public List ViewGridOfBll()
{
IdalAdmin DalObj = DalFactory.DalFactoryAdmin.CreateInstanceOfDal();
List list = new List();
list = DalObj.ViewGridOfDal();
return list;
}
public int UpdateGridOfBll(IboAdmin BoObj)
{
bool value;
IdalAdmin DalObj = DalFactory.DalFactoryAdmin.CreateInstanceOfDal();
value = DalObj.UpdateGridOfDal(BoObj);
if (value)
return 1;
else
return 0;
}
public int DeleteGridOfBll(int x)
{
bool value;
IdalAdmin DalObj = DalFactory.DalFactoryAdmin.CreateInstanceOfDal();
value = DalObj.DeleteGridOfDal(x);
if (value)
return 1;
else
return 0;
}
}
}




-----BllLogin.cs-----





using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;


namespace BLL
{
public class BllLogin : IbllLogin
{
public int LoginCheckBll(IboLogin BoObj)
{
IdalLogin DalObj = DalFactory.DalFactroyLogin.CreateInstanceOfDal();
bool value;
value = DalObj.LoginCheckDal(BoObj);
if (value)
return 1;
else
return 0;
}
}
}


-----BllFactoryAdmin.cs-----


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BLL;
using Types;

namespace BllFactory
{
public static class BllFactoryAdmin
{
public static IbllAdmin CreateInstanceOfBll()
{
IbllAdmin BllObj = new BllAdmin();
return BllObj;
}
}
}






-------BllFactoryLogin.cs-----



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BLL;
using Types;

namespace BllFactory
{
public static class BllFactoryLogin
{
public static IbllLogin CreateInstanceOfBll()
{
IbllLogin BllObj = new BllLogin();
return BllObj;
}
}
}


----------DalAdmin.cs-------




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using BoFactory;

namespace DAL
{
public class DalAdmin :IdalAdmin
{
SqlConnection MyConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlconnection"].ConnectionString);
public long AddOfDal(IboAdmin BoObj)
{
SqlCommand MyCommand = new SqlCommand();
MyConnection.Open();
MyCommand.Connection = MyConnection;
MyCommand.CommandText = "USP_INSERT_id";
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.AddWithValue("@trainNo", BoObj.trainNo);
MyCommand.Parameters.AddWithValue("@trainName ", BoObj.trainName);
MyCommand.Parameters.AddWithValue("@sourceStation", BoObj.sourceStation);
MyCommand.Parameters.AddWithValue("@destinationStation", BoObj.destinationStation);
MyCommand.Parameters.AddWithValue("@departureTime", BoObj.departureTime);
MyCommand.Parameters.AddWithValue("@arrivalTime", BoObj.arrivalTime);
MyCommand.Parameters.AddWithValue("@availableDays", BoObj.availableDyas);


MyCommand.Parameters.Add("@trainId", SqlDbType.Int).Value = BoObj.trainId;
MyCommand.Parameters["@trainId"].Direction = ParameterDirection.Output;



long IdCatcher = 0;
try
{
MyCommand.ExecuteNonQuery();

IdCatcher = long.Parse(MyCommand.Parameters["@trainId"].Value.ToString());
BoObj.trainId = IdCatcher;

}
catch (Exception e)
{
throw e;
}

finally
{
MyConnection.Close();
}
if (IdCatcher > 0)
return IdCatcher;
else
return 0;

}
public List ViewGridOfDal()
{
SqlCommand MyCommand = new SqlCommand();
MyCommand.Connection = MyConnection;
MyConnection.Open();
MyCommand.CommandText = "USP_VIEW_id";
MyCommand.CommandType = CommandType.StoredProcedure;
List list1 = new List();
SqlDataReader reader = MyCommand.ExecuteReader();
while (reader.Read())
{

IboAdmin BoObj = BoFactory.BoFactoryAdmin.CreateInstanceOfBo();
BoObj.trainId = Convert.ToInt32(reader["trainId"]);
BoObj.trainName = reader["trainName"].ToString();
BoObj.sourceStation = reader["sourceStation"].ToString();
BoObj.destinationStation= reader["destinationStation"].ToString();


BoObj.departureTime = (reader["departureTime"]).ToString();
BoObj.arrivalTime = (reader["arrivalTime"]).ToString();


BoObj.availableDyas = reader["availableDays"].ToString();
BoObj.trainNo = Convert.ToInt32( reader["trainNo"]);
list1.Add(BoObj);



}
MyConnection.Close();
return list1;


}
public bool UpdateGridOfDal(IboAdmin BoObj)
{
SqlCommand MyCommand = new SqlCommand();
MyCommand.Connection = MyConnection;
MyConnection.Open();
MyCommand.CommandText = "USP_UPDATE_id";
MyCommand.CommandType = CommandType.StoredProcedure;



MyCommand.Parameters.AddWithValue("@trainNo", BoObj.trainNo);
MyCommand.Parameters.AddWithValue("@trainName ", BoObj.trainName);
MyCommand.Parameters.AddWithValue("@sourceStation", BoObj.sourceStation);
MyCommand.Parameters.AddWithValue("@destinationStation", BoObj.destinationStation);
MyCommand.Parameters.AddWithValue("@departureTime", BoObj.departureTime);
MyCommand.Parameters.AddWithValue("@arrivalTime", BoObj.arrivalTime);
MyCommand.Parameters.AddWithValue("@availableDays", BoObj.availableDyas);
MyCommand.Parameters.AddWithValue("@trainId", BoObj.trainId);


MyCommand.ExecuteNonQuery();
MyConnection.Close();
return true;
}
public bool DeleteGridOfDal(int Id)
{
SqlCommand MyCommand = new SqlCommand();
MyCommand.Connection = MyConnection;
MyConnection.Open();
MyCommand.CommandText = "USP_DELETE_id";
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.AddWithValue("@trainId", Id);
MyCommand.ExecuteNonQuery();
MyConnection.Close();
return true;
}
}
}





---------DalLogin.cs-------






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using BoFactory;

namespace DAL
{
public class DalLogin :IdalLogin
{
public bool LoginCheckDal(IboLogin BoObj)
{

SqlConnection MyConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlconnection"].ConnectionString);
SqlCommand MyCommand = new SqlCommand();
MyCommand.Connection = MyConnection;
MyConnection.Open();
MyCommand.CommandText = "USP_LOGIN_CHECK_id";
MyCommand.CommandType = CommandType.StoredProcedure;
SqlDataReader reader = MyCommand.ExecuteReader();
int flag = 0;
while (reader.Read())
{
if ((BoObj.name == Convert.ToString(reader["name"])) && (BoObj.password == Convert.ToString(reader["password"])))
{
flag = 1;
break;
}
else
{
flag = 0;
}
}
MyConnection.Close();
if (flag == 1)
return true;
else
return false;

}
}
}



---------DalFactoryAdmin.cs-----

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;
using DAL;

namespace DalFactory
{
public static class DalFactoryAdmin
{
public static IdalAdmin CreateInstanceOfDal()
{
IdalAdmin DalObj = new DalAdmin();
return DalObj;
}

}
}




------DalFactoryLogin.cs------




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Types;
using DAL;

namespace DalFactory
{
public static class DalFactroyLogin
{
public static IdalLogin CreateInstanceOfDal()
{
IdalLogin objdal = new DalLogin();
return objdal;
}
}
}




------Sqls----------



use anythingsaa
drop table trainDetails_id
create table trainDetails_id
(
trainId int identity(10000,1),
trainNo bigint,
trainName varchar(30),
sourceStation varchar(40),
destinationStation varchar(40),
departureTime varchar(28) ,
arrivalTime varchar(28) ,
availableDays varchar(200)
)

select * from

create procedure USP_INSERT_id
(
@trainId int out,
@trainNo bigint,
@trainName varchar(30),
@sourceStation varchar(40),
@destinationStation varchar(40),
@departureTime varchar(28) ,
@arrivalTime varchar(28) ,
@availableDays varchar(200)
)
as
begin
insert into trainDetails_id values (@trainNo,@trainName,@sourceStation,@destinationStation,@departureTime,@arrivalTime,@availableDays)
set @trainId=@@IDENTITY
end




create procedure USP_VIEW_id
as
begin
select * from trainDetails_id
end

execute USP_VIEW_id

create procedure USP_UPDATE_id
(
@trainId int,
@trainNo bigint,
@trainName varchar(30),
@sourceStation varchar(40),
@destinationStation varchar(40),
@departureTime varchar(28) ,
@arrivalTime varchar(28),
@availableDays varchar(200)
)
as
begin
update trainDetails_id set

trainNo=@trainNo,
trainName=@trainName,
sourceStation=@sourceStation,
destinationStation =@destinationStation,
departureTime=@departureTime,
arrivalTime=@arrivalTime,
availableDays=@availableDays
where trainId=@trainId
end



Create procedure USP_DELETE_id
(
@trainId int
)
as
begin
delete from trainDetails_id
where trainId=@trainId
end

--Admin--

create table Admin_id
(
name varchar(40),
password varchar(50)
)


select * from Admin_id

insert into Admin_id values ('ggf','hfgh')
insert into Admin_id values ('dssdd','dffd')

--create procedure usp_check
--@name varchar(40) ,
--@password int
--as
--begin
--select name,password
--from Admin1
--where name=@name and password=@password
--end


create procedure USP_LOGIN_CHECK_id
as
begin
select * from Admin_id
end

insert into Admin_id values ('df','dfdfd')

My blog[^]
C#
public class SanderRossel : Lazy<Person>
{
   public void DoWork()
   {
      throw new NotSupportedException();
   }
}

GeneralRe: New record... Pin
Deflinek22-Dec-14 2:35
Deflinek22-Dec-14 2:35 
GeneralRe: New record... Pin
PIEBALDconsult21-Dec-14 12:17
mvePIEBALDconsult21-Dec-14 12:17 
GeneralRe: New record... Pin
_Maxxx_21-Dec-14 14:32
professional_Maxxx_21-Dec-14 14:32 
GeneralRe: New record... Pin
OriginalGriff22-Dec-14 4:34
mveOriginalGriff22-Dec-14 4:34 
GeneralRe: New record... Pin
Thanks787224-Dec-14 3:02
professionalThanks787224-Dec-14 3:02 
GeneralWeb/Java Application Developer Cover Letter PinPopular
Member 1132376319-Dec-14 10:19
Member 1132376319-Dec-14 10:19 
GeneralRe: Web/Java Application Developer Cover Letter Pin
dexterama19-Dec-14 10:26
professionaldexterama19-Dec-14 10:26 
GeneralRe: Web/Java Application Developer Cover Letter Pin
Jörgen Andersson19-Dec-14 10:41
professionalJörgen Andersson19-Dec-14 10:41 
GeneralRe: Web/Java Application Developer Cover Letter Pin
newton.saber19-Dec-14 11:07
newton.saber19-Dec-14 11:07 
GeneralRe: Web/Java Application Developer Cover Letter Pin
Brisingr Aerowing19-Dec-14 13:54
professionalBrisingr Aerowing19-Dec-14 13:54 
JokeRe: Web/Java Application Developer Cover Letter Pin
Sander Rossel19-Dec-14 23:39
professionalSander Rossel19-Dec-14 23:39 
GeneralRe: Web/Java Application Developer Cover Letter Pin
BillWoodruff20-Dec-14 18:53
professionalBillWoodruff20-Dec-14 18:53 
GeneralRe: Web/Java Application Developer Cover Letter Pin
Dominic Burford30-Dec-14 22:29
professionalDominic Burford30-Dec-14 22:29 
GeneralRe: Web/Java Application Developer Cover Letter Pin
GuyThiebaut6-Jan-15 2:00
professionalGuyThiebaut6-Jan-15 2:00 
GeneralRe: Web/Java Application Developer Cover Letter Pin
loctrice4-Feb-15 2:53
professionalloctrice4-Feb-15 2:53 
General10600 lines PinPopular
CDP180210-Dec-14 10:33
CDP180210-Dec-14 10:33 
GeneralRe: 10600 lines PinPopular
DaveX8610-Dec-14 10:52
DaveX8610-Dec-14 10:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.