C#
namespace CTP.HRMS.WebApp.Forms { public partial class EmployeeAbsentForm : PageBase { protected override string ModuleName { get { return "EmployeeAbsentForm"; } } private Employee _employee; private Employee Employee { get { if (_employee == null) { if (Request.QueryString["id"] != null) { _employee = _service.GetEmployee(Request.QueryString["id"].ToString()); } if (_employee == null) _employee = new Employee(); } return _employee; } } protected void Page_Load(object sender, EventArgs e) { if (!MyUser.CanAccess.AbsentRecord) { Redirect("/Forms/Redirected.aspx", "You do not have access to this page"); } if (!Page.IsPostBack) { Page.Header.Title = "Please Enter New Absent Record:"; BindData(); // PopulateData(); } } protected void BindData() { // Fill all Dropdowns ddlRollNo.Bind(_service.GetAllEmployee(), "IdName", "Id"); ddlRank.Bind(_service.GetAllRank()); } //protected void PopulateData() //{ // if ( Employee.Id != null) // { // // txtName.Text = Employee.Name; // EmployeeAbsent empAbsent = new EmployeeAbsent(); // txtRollNo.Text = Employee.Id; // ddlRank.SelectedValue = // txtStartDate.Text = empAbsent.StartDate.ToString(); // txtEndDate.Text = empAbsent.EndDate.ToString(); // txtDurtion.Text = empAbsent.Durtion; // txtReason.Text = empAbsent.Reason; // } //} protected void btnSubmit_Click(object sender, EventArgs e) { try { string[] temp = txtstartTime.Value.Split(new char[] { ' ', ':' }); DateTime startDate = SafeConvert.ToDateTime(txtStartDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0])) .AddMinutes(SafeConvert.ToInt32(temp[1])); temp = txtEndTime.Value.Split(new char[] { ' ', ':' }); DateTime endDate = SafeConvert.ToDateTime(txtEndDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0])) .AddMinutes(SafeConvert.ToInt32(temp[1])); EmployeeAbsent empAbsent = new EmployeeAbsent(); empAbsent.UserName = MyUser.UserName; empAbsent.EntryDate = DateTime.Now; empAbsent.Emlopyee_Id = ddlRollNo.Text; empAbsent.Rank_Id = SafeConvert.ToByte(ddlRank.SelectedValue); empAbsent.StartDate = startDate; empAbsent.EndDate = endDate; empAbsent.Durtion = txtDurtion.Text; _service.InsertEmployeeAbsent(empAbsent); _queryStatus = empAbsent.Id > 0; } catch (Exception ex) { HandException(ex); } Redirect("EmployeeAbsentForm.aspx"); } protected void btnCancel_Click(object sender, EventArgs e) { Response.Redirect("EmployeeAbsentForm.aspx"); } protected void txtStartDate_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtStartDate.Text) && !string.IsNullOrEmpty(txtstartTime.Value) && !string.IsNullOrEmpty(txtEndDate.Text) && !string.IsNullOrEmpty(txtEndTime.Value)) { string[] temp = txtstartTime.Value.Split(new char[] { ' ', ':' }); DateTime startDate = SafeConvert.ToDateTime(txtStartDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0])) .AddMinutes(SafeConvert.ToInt32(temp[1])); temp = txtEndTime.Value.Split(new char[] { ' ', ':' }); DateTime endDate = SafeConvert.ToDateTime(txtEndDate.Text).AddHours(temp[2] == "PM" ? SafeConvert.ToInt32(temp[0]) + 12 : SafeConvert.ToInt32(temp[0])) .AddMinutes(SafeConvert.ToInt32(temp[1])); txtDurtion.Text = (endDate - startDate).ToString(); } } } }SQL
Roll No
Rank
Start Date:
Start Time:
End Date:
End Time:
Durtion:

Saineshwar BageriRank #115 · 19.6K reputationPosted Oct 2, 2014, 10:26 PM EDT
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Data Inserted Successfully')", true);