Sajid Hussain

Sajid Hussain

  • 1.2k
  • 514
  • 101.5k

How Do I Display Error Or Successful Message After Data Inse

Oct 2 2014 1:30 PM
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();               }         }     } }
 
 
 
<%@ Page Title="" Language="C#" MasterPageFile="Site.Master" AutoEventWireup="true"     CodeBehind="EmployeeAbsentForm.aspx.cs" Inherits="CTP.HRMS.WebApp.Forms.EmployeeAbsentForm" %>   <asp:Content ContentPlaceHolderID="PageHeader" runat="server">     <div class="breadcrumb">         <h3 style="padding: 0; margin: 0"><%=Page.Header.Title%></h3>       </div>   </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">     <asp:UpdatePanel runat="server">         <ContentTemplate>             <div class="form-horizontal">                 <div class="form-group">                     <label class="col-sm-2 control-label">                         Roll No <span class="symbol required"></span>                     </label>                     <div class="col-sm-3">                        <asp:DropDownList CssClass="form-control search-select" runat="server" MaxLength="7" ID="ddlRollNo"  />                        <asp:RequiredFieldValidator ValidationGroup="vgEmployee" runat="server" ID="rfvrOLL" ControlToValidate="ddlRollNo" Required="required"></asp:RequiredFieldValidator>                      </div>                     <label class="col-sm-2 control-label">                         Rank <span class="symbol required"></span>                     </label>                     <div class="col-sm-3">                         <asp:DropDownList CssClass="form-control" ID="ddlRank" runat="server" />                         <asp:RequiredFieldValidator ValidationGroup="vgEmployee" runat="server" Required="required" ID="rfvRank" ControlToValidate="ddlRank"  ForeColor="#CC0000"></asp:RequiredFieldValidator>                     </div>                     <div class="col-sm-1">  </div>                 </div>                 <div class="form-group">                     <label class="col-sm-2 control-label">                         Start Date:                     </label>                     <div class="col-sm-3">                         <asp:TextBox ID="txtStartDate" runat="server" MaxLength="10" Required="required" data-date-viewmode="years"                             CssClass="form-control date-picker" data-date-format="dd-mm-yyyy"></asp:TextBox>                      </div>                     <label class="col-sm-2 control-label">                         Start Time:                     </label>                     <div class="input-group input-append bootstrap-timepicker col-sm-3"> 						<input id="txtstartTime" runat="server" type="text" class="form-control time-picker" /> 						<span class="input-group-addon add-on"></span> 					</div>                     </div>                 <div class="form-group">                     <label class="col-sm-2 control-label">                         End Date:                     </label>                     <div class="col-sm-3">                         <asp:TextBox ID="txtEndDate" runat="server"                              CssClass="form-control date-picker" data-date-viewmode="years" Required="required" MaxLength="10" data-date-format="dd-mm-yyyy"></asp:TextBox>                        </div>                     <label class="col-sm-2 control-label">                         End Time:                     </label>                     <div class="input-group input-append bootstrap-timepicker col-sm-3"> 						<input id="txtEndTime" runat="server" type="text" class="form-control time-picker"  /> 						<span class="input-group-addon add-on"></span> 					</div>                     <div class="col-sm-1">  </div>                 </div>                 <div class="form-group">                     <label class="col-sm-2 control-label">                         Durtion: <span class="symbol required"></span>                     </label>                     <div class="col-sm-3">                         <asp:TextBox CssClass="form-control"  runat="server" ID="txtDurtion" Required="required" />                         <asp:RegularExpressionValidator runat="server" ID="revDurtion" ControlToValidate="txtDurtion" Required="required"></asp:RegularExpressionValidator><br />                     </div                     <div class="col-sm-1 ">                          <asp:LinkButton runat="server" CausesValidation="false" OnClick="txtStartDate_TextChanged" CssClass="btn btn-block" Text="Calculate" Width="120" />                     </div>                     <div class="col-sm-3"></div>                 </div>                 <div class="form-group" style="background-color: whitesmoke;">                     <div class="col-md-5"> </div>                     <div class="col-md-2">                         <asp:Button ID="btnSubmit" runat="server" Text="Save" CausesValidation="true"                             CssClass="btn btn-success btn-block"                             ValidationGroup="vgEmployee" OnClick="btnSubmit_Click" />                     </div>                     <div class="col-md-2">                         <asp:LinkButton ID="btnCancel2" runat="server" Text="Cancel" CssClass="btn btn-danger btn-block" OnClick="btnCancel_Click" />                     </div>                 </div>             </div>         </ContentTemplate>     </asp:UpdatePanel>   </asp:Content>
i have tried bootstrap but it is not function properly  

Answers (1)