示例#1
0
 /// <summary>
 /// Name:Page_Load
 /// Description:when user clicks on grid header text value then grid's
 /// column values are sorted in ascending and descending order.
 /// Author:Monal Shah
 /// created Date:2010/10/21
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void EmployeeGrid_Sorting(object sender, System.Web.UI.WebControls.GridViewSortEventArgs e)
 {
     try
     {
         GridViewSortExpression      = e.SortExpression;
         ViewState["SortExpression"] = e.SortExpression;
         objDt1      = new DataTable();
         objSbSelect = new StringBuilder();
         objSbSelect.Append("Select ");
         objSbSelect.Append("* ");
         objSbSelect.Append("From ");
         objSbSelect.Append("TblEmployee");
         objcl.GetSqlStmt = objSbSelect.ToString();
         objDt1           = objcl.DataTables();
         objDv            = new DataView(objDt1);
         string direction = GetSortDirection();
         objDv.Sort = GridViewSortExpression + " " + direction;
         this.EmployeeGrid.DataSource = objDv;
         this.EmployeeGrid.DataBind();
     }
     catch (Exception)
     {
         Response.Redirect("Error.aspx", false);
     }
 }
示例#2
0
 /// <summary>
 /// Name:UserExists
 /// Description:Check for valid and authenticatte user.
 /// Author:Monal Shah
 /// Created Date:2010/11/16
 /// </summary>
 /// <param name="UserName"></param>
 /// <param name="Passwordvalue"></param>
 /// <returns>bool</returns>
 private bool UserExists(string UserName, string Passwordvalue)
 {
     dtUsers = new DataTable();
     objSb   = new StringBuilder();
     try
     {
         objSb.Append("Select ");
         objSb.Append("* ");
         objSb.Append("From ");
         objSb.Append("TblLogin ");
         objSb.Append("Where ");
         objSb.Append("UserId");
         objSb.Append("=");
         objSb.Append("'");
         objSb.Append(TxtName.Text);
         objSb.Append("'");
         objSb.Append(" AND ");
         objSb.Append("PasswordValue ");
         objSb.Append("=");
         objSb.Append("'");
         objSb.Append(TxtPwd.Text);
         objSb.Append("'");
         objcl.GetSqlStmt = objSb.ToString();
         dtUsers          = objcl.DataTables();
         if (dtUsers.Rows.Count > 0)
         {
             if (dtUsers.Rows[0]["UserId"].ToString() == UserName && dtUsers.Rows[0]["PasswordValue"].ToString() == Passwordvalue)
             {
                 return(true);
             }
         }
     }
     catch (Exception)
     { Response.Redirect("Error.aspx", false); }
     finally
     {
         objSb = null;
         dtUsers.Dispose();
     }
     return(false);
 }
示例#3
0
        /// <summary>
        /// Name:Bindgrid
        /// Description:Bind the repeater and datalist if datatable is blank then it displays message in label
        /// Author:Monal Shah
        /// created Date:2010/10/22
        /// </summary>
        public void BindGrid()
        {
            try
            {
                objSbSelect = new StringBuilder();
                objSbSelect.Append("Select ");
                objSbSelect.Append("* ");
                objSbSelect.Append("From ");
                objSbSelect.Append("TblEmployee");
                objcl.GetSqlStmt         = objSbSelect.ToString();
                objDt                    = objcl.DataTables();
                objDv                    = new DataView(objDt);
                objDv.Sort               = DdlSort.SelectedItem.Value.ToString() + " " + ASCENDING;
                pgitems                  = new PagedDataSource();
                pgitems.DataSource       = objDv;
                pgitems.AllowPaging      = true;
                pgitems.PageSize         = 5;
                pgitems.CurrentPageIndex = PageNumber;
                _pgCount                 = pgitems.PageCount;
                if (objDt.Rows.Count > 0)
                {
                    if (pgitems.PageCount > 1)
                    {
                        pages = new ArrayList();
                        for (int i = 0; i < pgitems.PageCount; i++)
                        {
                            pages.Add((i + 1).ToString());
                        }
                        LblPageNo.Text = string.Format(ConstantMessage.ViewingMsg, pgitems.CurrentPageIndex + 1, pgitems.PageCount);

                        BtnPrevious.Enabled = !pgitems.IsFirstPage;
                        BtnNext.Enabled     = !pgitems.IsLastPage;

                        this.EmployeeRepeater.DataSource = pgitems;
                        this.EmployeeRepeater.DataBind();
                        this.EmployeeDataList.DataSource = pgitems;
                        this.EmployeeDataList.DataBind();
                    }
                }
                else
                {
                    LblMsg.Visible           = true;
                    EmployeeRepeater.Visible = false;
                    EmployeeDataList.Visible = false;
                    TblRepeater.Visible      = false;
                    LblMsg.Text         = ConstantMessage.NoRecord;
                    BtnPrevious.Visible = false;
                    BtnNext.Visible     = false;
                    BtnFirst.Visible    = false;
                    BtnLast.Visible     = false;
                }
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx", false);
            }
            finally
            {
                objSbSelect = null;
                objcl       = null;
                objDt.Dispose();
            }
        }