Ejemplo n.º 1
0
 Commonlogic objCl   = new Commonlogic(); //ObjCl is object of commonlogic
 #region Page_Load
 /// <summary>
 /// Name:Page_Load
 /// Description:"Add code to fetch data from the Employees table and show it on the page in a datagridview."
 /// Author:Monal Shah
 /// Created Date:2010/09/20
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     { if (!IsPostBack)
       {     //string strTableName = "Employees";
             // objDTable = objCl.SelectQuery(strTableName);
           objCl.GetSqlStmt = "SELECT EmployeeID," +
                              "TitleOfCourtesy+' '+FirstName+' '+LastName As Name," +
                              "Title,Convert(varchar,BirthDate,111)As BirthDate," +
                              "Convert(varchar,HireDate,111) As HireDate," +
                              "Address, City, Region, PostalCode, Country, HomePhone," +
                              "Extension, Photo, ReportsTo, Notes," +
                              "PhotoPath FROM Employees";
           objDTable = objCl.DataTables();
           this.GrdEmployee.DataSource = objDTable;
           this.GrdEmployee.DataBind();  //Binding grid
       }
     }
     catch (Exception exException)
     {
         Response.Redirect("Error.aspx");
         // Response.Write("ERROR:" + exException.Message);
     }
     finally
     {
         objDTable = null;
         objCl     = null;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Name:Bindgrid
        /// Description:Bind Grid with Customer details
        /// Author:monal shah
        /// Created Date:2010/09/23
        /// </summary>
        public void BindGrid()
        {
            try
            {
                objSelect = new StringBuilder();
                objSelect.Append("SELECT ");
                objSelect.Append("CustomerID");
                objSelect.Append(",");
                objSelect.Append("CompanyName");
                objSelect.Append(",");
                objSelect.Append("ContactName");
                objSelect.Append(",");
                objSelect.Append("ContactTitle");
                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("Phone");
                objSelect.Append(",");
                objSelect.Append("Fax ");
                objSelect.Append("From Customers");


                objCl.GetSqlStmt = objSelect.ToString();
                objDt            = objCl.DataTables();//here EmpDataSet method is called with the table name
                if (objDt.Rows.Count == 0)
                {
                    LblErrorMessage.Visible = true;
                    LblErrorMessage.Text    = objConstant.NoTableRecordFound;// "Datatable Does Not Contain Any Row";
                    LnkAddNewUser.Visible   = false;
                    //Response.Write(LblErrorMessage.Text);
                }
                else
                {
                    this.GrdCustomer.DataSource = objDt;
                    this.GrdCustomer.DataBind();//here binding data to gridview
                }
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx", false);
            }
            finally
            {
                objDt = null;
                objCl = null;
            }
        }
Ejemplo n.º 3
0
 Commonlogic objCl   = new Commonlogic(); //ObjCl is object of commonlogic
 #region Page_Load
 /// <summary>
 /// Name:Page_Load
 /// Description:"Add code to fetch data from the Territories table and show it on the page in a datagridview."
 /// 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)
 {
     if (!IsPostBack)
     {
         try
         {
             objCl.GetSqlStmt = "Select * From Territories";
             objDTable        = objCl.DataTables();//through the common logic object datatable function is call and assign vale to the datatable object
             //string strTableName = "Territories";
             //objDTable = objCl.DataTables();// SelectQuery(strTableName);//SelectQuery Method is called with tableName
             this.GrdTerritories.DataSource = objDTable;
             this.GrdTerritories.DataBind();//binding grid
         }
         catch (Exception)
         {
             Response.Redirect("Error.aspx", false);
         }
         finally
         {
             objDTable = null;
             objCl     = null;
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Name:Page_Load
        /// Description:Here in below code fetch data from employee territories table and disaplay in textbox.
        /// Author:Monal Shah
        /// Created Date:2010/10/4
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    int intIdValue = SessionMethod.CurrentSession.EmployeeID;    //fetch id value from session
                    //if id valueis '0'then btnSubmit.Text = "Insert" else  btnSubmit.Text = "Update";
                    //and setch data from table and display in textbox

                    if (intIdValue == 0)
                    {
                        btnSubmit.Text = "Insert";
                        BindListBox();
                    }
                    else
                    {
                        btnSubmit.Text = "Update";
                        objSelect      = new StringBuilder();
                        objSelect.Append("SELECT ");
                        objSelect.Append("EMP.EmployeeID");
                        objSelect.Append(",");
                        objSelect.Append("EMP.TitleOfCourtesy");
                        objSelect.Append(",");
                        objSelect.Append("EMP.FirstName");
                        objSelect.Append(",");
                        objSelect.Append("EMP.LastName");    // As Name");
                        objSelect.Append(",");
                        objSelect.Append("EMP.Title");
                        objSelect.Append(",");
                        objSelect.Append("Convert(varchar,EMP.BirthDate,111) As BirthDate");
                        objSelect.Append(",");
                        objSelect.Append("Convert(varchar,EMP.HireDate,111) As HireDate");
                        objSelect.Append(",");
                        objSelect.Append("EMP.Address");
                        objSelect.Append(",");
                        objSelect.Append("EMP.City");
                        objSelect.Append(",");
                        objSelect.Append("EMP.Region");
                        objSelect.Append(",");
                        objSelect.Append("EMP.PostalCode");
                        objSelect.Append(",");
                        objSelect.Append("EMP.Country");
                        objSelect.Append(",");
                        objSelect.Append("EMP.HomePhone");
                        objSelect.Append(",");
                        objSelect.Append("EMP.Extension");
                        objSelect.Append(",");
                        objSelect.Append("EMP.ReportsTo");
                        objSelect.Append(",");
                        objSelect.Append("EMP.Notes");
                        objSelect.Append(",");
                        objSelect.Append("EMP.PhotoPath ");
                        objSelect.Append("From Employees EMP");
                        objSelect.Append(" Where ");
                        objSelect.Append("EMP.EmployeeId");
                        objSelect.Append("=");
                        objSelect.Append("'");
                        objSelect.Append(intIdValue);
                        objSelect.Append("'");

                        objCl.GetSqlStmt = objSelect.ToString();
                        objDTable        = objCl.DataTables();

                        if (objDTable.Rows.Count > 0)
                        {
                            DdlSalutation.Enabled           = false;
                            TxtBdate.Enabled                = false;
                            BtnCal1.Enabled                 = false;
                            TxtLname.Text                   = Convert.ToString(objDTable.Rows[0]["LastName"]);
                            TxtFname.Text                   = Convert.ToString(objDTable.Rows[0]["FirstName"]);
                            TxtTitle.Text                   = Convert.ToString(objDTable.Rows[0]["Title"]);
                            DdlSalutation.SelectedItem.Text = Convert.ToString(objDTable.Rows[0]["TitleOfCourtesy"]);
                            TxtBdate.Text                   = Convert.ToString(objDTable.Rows[0]["BirthDate"]);
                            TxtHDate.Text                   = Convert.ToString(objDTable.Rows[0]["HireDate"]);
                            TxtAddress.Text                 = Convert.ToString(objDTable.Rows[0]["Address"]);
                            TxtCity.Text       = Convert.ToString(objDTable.Rows[0]["City"]);
                            TxtRegion.Text     = Convert.ToString(objDTable.Rows[0]["Region"]);
                            TxtPostalCode.Text = Convert.ToString(objDTable.Rows[0]["PostalCode"]);
                            TxtCountry.Text    = Convert.ToString(objDTable.Rows[0]["Country"]);
                            TxtHomePhone.Text  = Convert.ToString(objDTable.Rows[0]["HomePhone"]);
                            TxtExtension.Text  = Convert.ToString(objDTable.Rows[0]["Extension"]);
                            TxtNotes.Text      = Convert.ToString(objDTable.Rows[0]["Notes"]);
                            TxtReportsTo.Text  = Convert.ToString(objDTable.Rows[0]["ReportsTo"]);

                            BindListBox();
                        }
                        else
                        {
                            LblErrorMessage.Text = objConstant.NoTableRecordFound;    // "Datatable Does Not Contain Any Row";
                        }
                    }
                }
                catch (Exception)
                {
                    Response.Redirect("Error.aspx", false);
                }
                finally
                {
                    objCl     = null;
                    objDTable = null;
                    objSelect = null;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Name:BindGrid
        /// 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/10/01
        /// </summary>
        public void BindGrid()
        {
            try
            {
                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");

                objCl.GetSqlStmt = objSelect.ToString();// "SELECT EmployeeID, TitleOfCourtesy + ' ' + FirstName + ' ' + LastName AS Name, Title,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,Extension,Notes,ReportsTo,PhotoPath from Employees";   //Territories.TerritoryDescription FROM Employees INNER JOIN EmployeeTerritories ON Employees.EmployeeID = EmployeeTerritories.EmployeeID INNER JOIN Territories ON EmployeeTerritories.TerritoryID = Territories.TerritoryID where Employees.EmployeeID='1'";
                objDTable        = objCl.DataTables();
                if (objDTable.Rows.Count == 0)
                {
                    LblErrorMessage.Visible = true;
                    LblErrorMessage.Text    = objConstant.NoTableRecordFound;// "Datatable Does Not Contain Any Row";
                    LnkAddNewUser.Visible   = false;
                }
                else
                {
                    this.GrdEmpTerritories.DataSource = objDTable;
                    this.GrdEmpTerritories.DataBind();//here binding data to gridview
                }
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx");
            }
            finally
            {
                objSelect = null;
                objDTable = null;
                objCl     = null;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Name:Page_Load
 /// Description:Here in below code fetch data from Customers table and disaplay in textbox.
 /// Author:Monal Shah
 /// Created Date:2010/09/30
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         LblErrorMessage.Visible = false;
         try
         {
             string strIdValue = SessionMethod.CurrentSession.CustomerID;//fetch id value from session
             //if id valueis '0'then btnSubmit.Text = "Insert" else  btnSubmit.Text = "Update";
             //and setch data from table and display in textbox
             if (strIdValue == null)
             {
                 btnSubmit.Text = "Insert";
             }
             else
             {
                 btnSubmit.Text = "Update";
                 objSelect      = new StringBuilder();
                 objSelect.Append("SELECT ");
                 objSelect.Append("CustomerID");
                 objSelect.Append(",");
                 objSelect.Append("CompanyName");
                 objSelect.Append(",");
                 objSelect.Append("ContactName");
                 objSelect.Append(",");
                 objSelect.Append("ContactTitle");
                 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("Phone");
                 objSelect.Append(",");
                 objSelect.Append("Fax ");
                 objSelect.Append("From Customers ");
                 objSelect.Append("Where ");
                 objSelect.Append("CustomerID=");
                 objSelect.Append("'");
                 objSelect.Append(strIdValue);
                 objSelect.Append("'");
                 objCl.GetSqlStmt = objSelect.ToString();
                 objDTable        = objCl.DataTables();
                 if (objDTable.Rows.Count > 0)
                 {
                     TxtCompanyName.Text  = objDTable.Rows[0]["CompanyName"].ToString();
                     TxtContactName.Text  = objDTable.Rows[0]["ContactName"].ToString();
                     TxtContactTitle.Text = objDTable.Rows[0]["ContactTitle"].ToString();
                     TxtAddress.Text      = objDTable.Rows[0]["Address"].ToString();
                     TxtCity.Text         = objDTable.Rows[0]["City"].ToString();
                     TxtRegion.Text       = objDTable.Rows[0]["Region"].ToString();
                     TxtPostalCode.Text   = objDTable.Rows[0]["PostalCode"].ToString();
                     TxtCountry.Text      = objDTable.Rows[0]["Country"].ToString();
                     TxtPhone.Text        = objDTable.Rows[0]["Phone"].ToString();
                     TxtFax.Text          = objDTable.Rows[0]["Fax"].ToString();
                 }
                 else
                 {
                     LblErrorMessage.Visible = true;
                     LblErrorMessage.Text    = objConstant.NoTableRecordFound;// "Datatable Does Not Contain Any Row";
                     pnlPanelTable.Visible   = false;
                 }
             }
         }
         catch (Exception)
         {
             Response.Redirect("Error.aspx", false);
         }
     }
 }