Пример #1
0
 /// <summary>
 /// Name:Page_Load
 /// Description:"Add code to fetch data from the Employees table and show it on the page in a datagridview.and store the typed dataset into session."
 /// Author:Monal Shah
 /// Created Date:2010/09/21
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             string strTable = "Employees";
             objSelect = new StringBuilder();
             objSelect.Append("SELECT ");
             objSelect.Append("EmployeeID");
             objSelect.Append(",");
             objSelect.Append("TitleOfCourtesy+' '+FirstName+' '+LastName As Name");
             objSelect.Append(",");
             objSelect.Append("Title");
             objSelect.Append(",");
             objSelect.Append("Convert(varchar,BirthDate,111) As BirthDate");
             objSelect.Append(",");
             objSelect.Append("Convert(varchar,HireDate,111) As HireDate");
             objSelect.Append(",");
             objSelect.Append("Address");
             objSelect.Append(",");
             objSelect.Append("City");
             objSelect.Append(",");
             objSelect.Append("Region");
             objSelect.Append(",");
             objSelect.Append("PostalCode");
             objSelect.Append(",");
             objSelect.Append("Country");
             objSelect.Append(",");
             objSelect.Append("HomePhone");
             objSelect.Append(",");
             objSelect.Append("Extension");
             objSelect.Append(",");
             objSelect.Append("ReportsTo");
             objSelect.Append(",");
             objSelect.Append("Notes");
             objSelect.Append(",");
             objSelect.Append("PhotoPath ");
             objSelect.Append("From Employees");
             string strQuery = objSelect.ToString();
             objEmpDataSet = objCl.EmpDataSet(strQuery, strTable);//here EmpDataSet method is called with the table name
             SessionMethod.CurrentSession.StoreTypedDataSet = objEmpDataSet;
             // Session["DataSetSession"] = objEmpDataSet;//stores the dataset into session
             this.GrdEmployee.DataSource = objEmpDataSet;
             this.GrdEmployee.DataBind();//here binding data to gridview
         }
     }
     catch (Exception)
     {
         Response.Redirect("Error.aspx", false);
         //  Response.Write("ERROR:" + exException.Message);
     }
     finally
     {
         objEmpDataSet = null;
         objCl         = null;
     }
 }
Пример #2
0
 /// <summary>
 /// Name:Page_Load
 /// Description:Bind the grid with emplyee table using typed dataset and perform DML operatio(Insert,Update,Delete)
 /// Author:monal shah
 /// Created Date:2010/09/23
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             //objCl.GetSqlStmt = str;
             //objDTable = objCl.DataTables();
             string strTable = "Employees";
             objSelect = new StringBuilder();
             objSelect.Append("SELECT ");
             objSelect.Append("EmployeeID");
             objSelect.Append(",");
             objSelect.Append("TitleOfCourtesy+' '+FirstName+' '+LastName As Name");
             objSelect.Append(",");
             objSelect.Append("Title");
             objSelect.Append(",");
             objSelect.Append("Convert(varchar,BirthDate,111) As BirthDate");
             objSelect.Append(",");
             objSelect.Append("Convert(varchar,HireDate,111) As HireDate");
             objSelect.Append(",");
             objSelect.Append("Address");
             objSelect.Append(",");
             objSelect.Append("City");
             objSelect.Append(",");
             objSelect.Append("Region");
             objSelect.Append(",");
             objSelect.Append("PostalCode");
             objSelect.Append(",");
             objSelect.Append("Country");
             objSelect.Append(",");
             objSelect.Append("HomePhone");
             objSelect.Append(",");
             objSelect.Append("Extension");
             objSelect.Append(",");
             objSelect.Append("ReportsTo");
             objSelect.Append(",");
             objSelect.Append("Notes");
             objSelect.Append(",");
             objSelect.Append("PhotoPath ");
             objSelect.Append("From Employees");
             string strQuery = objSelect.ToString();
             objEmpDataSet = objCl.EmpDataSet(strQuery, strTable);
             this.GrdEmployee.DataSource = objEmpDataSet.Employees;
             this.GrdEmployee.DataBind();//here binding data to gridview
         }
     }
     catch (SqlException)
     {
         Response.Redirect("Error.aspx", false);
         // Response.Write("ERROR:" + exException.Message);
     }
     finally
     {
         objEmpDataSet = null;
         objCl         = null;
     }
 }
Пример #3
0
        /// <summary>
        /// Name:Bindgrid
        /// Description:Bind Grid with employee details
        /// Author:monal shah
        /// Created Date:2010/09/23
        /// </summary>
        public void BindGrid()
        {
            try
            {
                string strTable = "Employees";
                objSelect = new StringBuilder();
                objSelect.Append("SELECT ");
                objSelect.Append("EmployeeID");
                objSelect.Append(",");
                objSelect.Append("TitleOfCourtesy+' '+FirstName+' '+LastName As Name");
                objSelect.Append(",");
                objSelect.Append("Title");
                objSelect.Append(",");
                objSelect.Append("Convert(varchar,BirthDate,111) As BirthDate");
                objSelect.Append(",");
                objSelect.Append("Convert(varchar,HireDate,111) As HireDate");
                objSelect.Append(",");
                objSelect.Append("Address");
                objSelect.Append(",");
                objSelect.Append("City");
                objSelect.Append(",");
                objSelect.Append("Region");
                objSelect.Append(",");
                objSelect.Append("PostalCode");
                objSelect.Append(",");
                objSelect.Append("Country");
                objSelect.Append(",");
                objSelect.Append("HomePhone");
                objSelect.Append(",");
                objSelect.Append("Extension");
                objSelect.Append(",");
                objSelect.Append("ReportsTo");
                objSelect.Append(",");
                objSelect.Append("Notes");
                objSelect.Append(",");
                objSelect.Append("PhotoPath ");
                objSelect.Append("From Employees");

                string strQuery = objSelect.ToString();
                ////"Title,Convert(varchar,BirthDate,111) As BirthDate," +
                ////"Convert(varchar,HireDate,111) As HireDate," +
                ////"Address, City, Region, PostalCode, Country," +
                ////"HomePhone, Extension, ReportsTo, Notes," +
                ////"PhotoPath FROM Employees";
                objEmpDataSet = objCl.EmpDataSet(strQuery, strTable); //here EmpDataSet method is called with the table name
                this.GrdEmployee.DataSource = objEmpDataSet;
                this.GrdEmployee.DataBind();                          //here binding data to gridview
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx", false);
            }
            finally
            {
                objEmpDataSet = null;
                objCl         = null;
            }
        }
Пример #4
0
        /// <summary>
        /// Name:Page_Load
        /// Description:"Add a gridview control to the page and bind it to the EmployeeTerritories table of the typed dataset"
        /// Author:Monal Shah
        /// Created Date:2010/09/21
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    int intIdValue = SessionMethod.CurrentSession.EmployeeID;
                    //if session is not '0' then clicked linkbutton's record will be displayed
                    //else all the employeeterritories record will be displayed.
                    if (intIdValue != 0)
                    {
                        objDTable = objCl.SelectNWhereQuery("EmployeeTerritories", "EmployeeID", intIdValue);
                        this.GrdEmpTerritories.DataSource = objDTable;
                        this.GrdEmpTerritories.DataBind();//here binding data to gridview
                    }
                    else
                    {
                        string strTable = "EmployeeTerritories";
                        objEmpTerroristDataSet            = objCl.EmpDataSet(strTable); //here EmpDataSet method is called with the table name
                        this.GrdEmpTerritories.DataSource = objEmpTerroristDataSet.EmployeeTerritories;
                        this.GrdEmpTerritories.DataBind();                              //here binding data to gridview
                    }
                }
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx", false);
                // Response.Write("ERROR:" + exException.Message);
            }
            finally
            {
                objEmpTerroristDataSet = null;
                objCl     = null;
                objDTable = null;
            }
        }
Пример #5
0
        /// <summary>
        /// Name:Bindgrid
        /// Description:Bind Grid with employee details
        /// Author:monal shah
        /// Created Date:2010/09/23
        /// </summary>
        public void BindGrid()
        {
            try
            {
                string strTable = "Employees";
                objSelect = new StringBuilder();
                objSelect.Append("SELECT ");
                objSelect.Append("EmployeeID");
                objSelect.Append(",");
                objSelect.Append("TitleOfCourtesy+' '+FirstName+' '+LastName As Name");
                objSelect.Append(",");
                objSelect.Append("Title");
                objSelect.Append(",");
                objSelect.Append("Convert(varchar,BirthDate,111) As BirthDate");
                objSelect.Append(",");
                objSelect.Append("Convert(varchar,HireDate,111) As HireDate");
                objSelect.Append(",");
                objSelect.Append("Address");
                objSelect.Append(",");
                objSelect.Append("City");
                objSelect.Append(",");
                objSelect.Append("Region");
                objSelect.Append(",");
                objSelect.Append("PostalCode");
                objSelect.Append(",");
                objSelect.Append("Country");
                objSelect.Append(",");
                objSelect.Append("HomePhone");
                objSelect.Append(",");
                objSelect.Append("Extension");
                objSelect.Append(",");
                objSelect.Append("ReportsTo");
                objSelect.Append(",");
                objSelect.Append("Notes");
                objSelect.Append(",");
                objSelect.Append("PhotoPath ");
                objSelect.Append("From Employees");

                string strQuery = objSelect.ToString();
                objEmpDataSet = objCl.EmpDataSet(strQuery, strTable);//here EmpDataSet method is called with the table name
                if (objEmpDataSet.Tables[0].Rows.Count > 0)
                {
                    this.GrdEmployee.DataSource = objEmpDataSet;
                    this.GrdEmployee.DataBind();//here binding data to gridview
                }
                else
                {
                    LblErrorMessage.Visible = true;
                    LblErrorMessage.Text    = objConstant.NoTableRecordFound;// "Datatable Does Not Contain Any Row";
                    LnkAddNewUser.Visible   = false;
                }
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx", false);
            }
            finally
            {
                objEmpDataSet = null;
                objCl         = null;
            }
        }
Пример #6
0
 /// <summary>
 ///Name:Page_Load
 ///Description:Fetch data from table and display in form and after that update the value of table's row.
 ///Author:monal shah
 ///Created Date:2010/09/23
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string strTable   = "Employees";
         int    intIdValue = SessionMethod.CurrentSession.EmployeeID;
         try
         {
             if (intIdValue != 0)
             {
                 btnSubmit.Text = "Update";
                 objSelect      = new StringBuilder();
                 objSelect.Append("SELECT ");
                 objSelect.Append("EmployeeID");
                 objSelect.Append(",");
                 objSelect.Append("TitleOfCourtesy");
                 objSelect.Append(",");
                 objSelect.Append("FirstName");
                 objSelect.Append(",");
                 objSelect.Append("LastName");
                 objSelect.Append(",");
                 objSelect.Append("Title");
                 objSelect.Append(",");
                 objSelect.Append("Convert(varchar,BirthDate,111) As BirthDate");
                 objSelect.Append(",");
                 objSelect.Append("Convert(varchar,HireDate,111) As HireDate");
                 objSelect.Append(",");
                 objSelect.Append("Address");
                 objSelect.Append(",");
                 objSelect.Append("City");
                 objSelect.Append(",");
                 objSelect.Append("Region");
                 objSelect.Append(",");
                 objSelect.Append("PostalCode");
                 objSelect.Append(",");
                 objSelect.Append("Country");
                 objSelect.Append(",");
                 objSelect.Append("HomePhone");
                 objSelect.Append(",");
                 objSelect.Append("Extension");
                 objSelect.Append(",");
                 objSelect.Append("ReportsTo");
                 objSelect.Append(",");
                 objSelect.Append("Notes");
                 objSelect.Append(",");
                 objSelect.Append("PhotoPath ");
                 objSelect.Append("From Employees ");
                 objSelect.Append("Where EmployeeID=");
                 objSelect.Append("'");
                 objSelect.Append(intIdValue);
                 objSelect.Append("'");
                 string strQuery = objSelect.ToString();
                 //string strQuery = "Select EmployeeID,LastName,FirstName," +
                 //                    "TitleOfCourtesy, Title,BirthDate," +
                 //                    "HireDate,Address, City, Region," +
                 //                    "PostalCode, Country, HomePhone," +
                 //                    "Extension, Photo, ReportsTo, Notes," +
                 //                    "PhotoPath FROM Employees where " +
                 //                    "EmployeeID='" + intIdValue + "'";
                 objEmpDataSet = objCl.EmpDataSet(strQuery, strTable);
                 //if datatable contains more than 0 value then the data
                 //will be fetch frm the table and display in form
                 if (objEmpDataSet.Tables[0].Rows.Count > 0)
                 {
                     DdlSalutation.Enabled           = false;
                     TxtBdate.Enabled                = false;
                     BtnCal1.Enabled                 = false;
                     TxtLname.Text                   = objEmpDataSet.Tables[0].Rows[0]["LastName"].ToString();
                     TxtFname.Text                   = objEmpDataSet.Tables[0].Rows[0]["FirstName"].ToString();
                     TxtTitle.Text                   = objEmpDataSet.Tables[0].Rows[0]["Title"].ToString();
                     DdlSalutation.SelectedItem.Text = objEmpDataSet.Tables[0].Rows[0]["TitleOfCourtesy"].ToString();
                     TxtBdate.Text                   = objEmpDataSet.Tables[0].Rows[0]["BirthDate"].ToString();
                     TxtHDate.Text                   = objEmpDataSet.Tables[0].Rows[0]["HireDate"].ToString();
                     TxtAddress.Text                 = objEmpDataSet.Tables[0].Rows[0]["Address"].ToString();
                     TxtCity.Text       = objEmpDataSet.Tables[0].Rows[0]["City"].ToString();
                     TxtRegion.Text     = objEmpDataSet.Tables[0].Rows[0]["Region"].ToString();
                     TxtPostalCode.Text = objEmpDataSet.Tables[0].Rows[0]["PostalCode"].ToString();
                     TxtCountry.Text    = objEmpDataSet.Tables[0].Rows[0]["Country"].ToString();
                     TxtHomePhone.Text  = objEmpDataSet.Tables[0].Rows[0]["HomePhone"].ToString();
                     TxtExtension.Text  = objEmpDataSet.Tables[0].Rows[0]["Extension"].ToString();
                     TxtNotes.Text      = objEmpDataSet.Tables[0].Rows[0]["Notes"].ToString();
                     TxtReportsTo.Text  = objEmpDataSet.Tables[0].Rows[0]["ReportsTo"].ToString();
                 }
             }
         }
         catch (Exception)
         {
             Response.Redirect("Error.aspx", false);
         }
     }
 }