using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Text;
public partial class InsertEmployee : System.Web.UI.Page
{
public string
Message,EmployeeName,DepartmentName,Logo;
public bool
Active;
public int
Salary;
Class1 c1 = new
Class1();
protected
override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
if
(HttpContext.Current.Request.Url.AbsoluteUri.Contains("InsertEmployee.aspx"))
{
base.MasterPageFile
= "MasterPage.master";
}
//if
(Request.Url.Host.Contains("InsertEmployee.aspx"))
//{
// base.MasterPageFile =
Server.MapPath("MasterPage1.master");
//}
else
{
base.MasterPageFile = "MasterPage1.master";
}
}
protected void
Page_Load(object sender, EventArgs e)
{
//string id
= Request.QueryString["id"].ToString();
//if (id !=
"")
//{
//}
string
UserName =
Session["UserName"]!=null?Session["UserName"].ToString():"";
if
(UserName == "")
{
Response.Redirect("Login.aspx");
}
}
protected void
LoadData()
{
EmployeeName = txtEmpName.Text.ToString();
DepartmentName = txtDeptName.Text.ToString();
Salary =
int.Parse(txtSalary.Text.ToString());
Logo =
Path.GetFileName(FileUpload1.FileName);
Active =
chkActive.Checked;
string filename =
Server.MapPath("Images\\" + Logo);
FileUpload1.SaveAs(filename);
c1.InsertEmployee(EmployeeName, DepartmentName, Salary, Logo,Active);
Message =
"Record Inserted Successfully";
}
protected void
btnSave_Click(object sender, EventArgs e)
{
LoadData();
Clear();
}
protected void
Clear()
{
txtEmpName.Text = "";
txtDeptName.Text = "";
txtSalary.Text = "";
}
}
No comments:
Post a Comment