Esempio n. 1
0
        protected void grdContact_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            ContactTableAdapter contact = new ContactTableAdapter();
            //bool flag = false;
            int         index = GridView1.EditIndex;
            GridViewRow row   = GridView1.Rows[index];

            TextBox id       = row.FindControl("TextBox1") as TextBox;
            TextBox roomno   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2");
            TextBox floorno  = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3");
            TextBox timefrom = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox4");
            TextBox timeto   = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox5");

            //TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
            //CheckBox chkActive =
            //  (CheckBox)GridView1.Rows[e.RowIndex].FindControl("chkActive");
            //DropDownList cmbType =
            //  (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType");
            //DropDownList ddlSex =
            //  (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlSex");
            //if (chkActive.Checked) flag = true; else flag = false;
            contact.Update(Convert.ToInt32(id.Text), Convert.ToInt32(roomno.Text), Convert.ToInt32(floorno.Text),
                           Convert.ToInt32(timefrom.Text), Convert.ToInt32(timeto.Text));
            GridView1.EditIndex = -1;
            FillGrid();
        }
Esempio n. 2
0
        /*
         * protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
         * {
         *  if (e.Row.RowType == DataControlRowType.DataRow)
         *  {
         *      //Find the DropDownList in the Row
         *      DropDownList ddlCountries = (e.Row.FindControl("ddlCountries") as DropDownList);
         *      ddlCountries.DataSource = GetData("SELECT * from numbers");
         *      ddlCountries.DataTextField = "timefromddl";
         *      ddlCountries.DataValueField = "timefromddl";
         *      ddlCountries.DataBind();
         *
         *      //Add Default Item in the DropDownList
         *      ddlCountries.Items.Insert(0, new ListItem("Please select"));
         *
         *      //Select the Country of Customer in DropDownList
         *      string country = (e.Row.FindControl("lbltimefrom") as Label).Text;
         *      ddlCountries.Items.FindByValue(country).Selected = true;
         *  }
         * }
         */
        protected void grdContact_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ContactTableAdapter contact = new ContactTableAdapter();

            //bool flag = false;
            if (e.CommandName.Equals("Insert"))
            {
                //TextBox txtNewName =
                //  (TextBox)GridView1.FooterRow.FindControl("txtNewName");
                //CheckBox chkNewActive =
                //  (CheckBox)GridView1.FooterRow.FindControl("chkNewActive");
                //DropDownList cmbNewType =
                //  (DropDownList)GridView1.FooterRow.FindControl("cmbNewType");
                //DropDownList ddlNewSex =
                //  (DropDownList)GridView1.FooterRow.FindControl("ddlNewSex");
                //if (chkNewActive.Checked) flag = true; else flag = false;

                TextBox id = (TextBox)GridView1.FooterRow.FindControl("insertid");
                //TextBox roomno = (TextBox)GridView1.FooterRow.FindControl("insertroomno");
                DropDownList roomno = (DropDownList)GridView1.FooterRow.FindControl("insertroomno");
                // TextBox floorno = (TextBox)GridView1.FooterRow.FindControl("insertfloorno");
                DropDownList floorno  = (DropDownList)GridView1.FooterRow.FindControl("insertfloorno");
                TextBox      timefrom = (TextBox)GridView1.FooterRow.FindControl("inserttimefrom");
                TextBox      timeto   = (TextBox)GridView1.FooterRow.FindControl("inserttimeto");
                //TextBox txtName = (TextBox)GridView1.HeaderRow.FindControl("txtName");
                //contact.Insert(txtNewName.Text, ddlNewSex.SelectedValue,
                //               cmbNewType.SelectedValue, flag);
                contact.Insert(Convert.ToInt32(id.Text), Convert.ToInt32(roomno.SelectedValue.ToString()), Convert.ToInt32(floorno.SelectedValue.ToString()),
                               Convert.ToInt32(timefrom.Text), Convert.ToInt32(timeto.Text));
                FillGrid();
            }
        }
Esempio n. 3
0
        protected void grdContact_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string bookingid            = GridView1.DataKeys[e.RowIndex].Values["bookingid"].ToString();
            ContactTableAdapter contact = new ContactTableAdapter();
            int id = Convert.ToInt32(bookingid);

            contact.Delete(id);
            FillGrid();
        }
Esempio n. 4
0
        public void FillGrid()
        {
            ContactTableAdapter contact  = new ContactTableAdapter();
            DataSet             contacts = contact.GetData("select id,roomno,floorno,timefrom,timeto,bookingid from booking");

            if (contacts.Tables[0].Rows.Count > 0)
            {
                GridView1.DataSource = contacts;
                GridView1.DataBind();
            }
            else
            {
                contacts.Tables[0].Rows.Add(contacts.Tables[0].NewRow());
                GridView1.DataSource = contacts;
                GridView1.DataBind();

                int TotalColumns = GridView1.Rows[0].Cells.Count;
                GridView1.Rows[0].Cells.Clear();
                GridView1.Rows[0].Cells.Add(new TableCell());
                GridView1.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                GridView1.Rows[0].Cells[0].Text       = "No Record Found";
            }
        }
Esempio n. 5
0
        protected void grdContact_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //ContactTypeTableAdapter contactType = new ContactTypeTableAdapter();
            //DataTable contactTypes = contactType.GetData();
            //if (e.Row.RowType == DataControlRowType.DataRow)
            //{
            //    Label lblType = (Label)e.Row.FindControl("lblType");
            //    if (lblType != null)
            //    {
            //        int typeId = Convert.ToInt32(lblType.Text);
            //        lblType.Text = (string)contactType.GetTypeById(typeId);
            //    }
            //    DropDownList cmbType = (DropDownList)e.Row.FindControl("cmbType");
            //    if (cmbType != null)
            //    {
            //        cmbType.DataSource = contactTypes;
            //        cmbType.DataTextField = "TypeName";
            //        cmbType.DataValueField = "Id";
            //        cmbType.DataBind();
            //        cmbType.SelectedValue =
            //          grdContact.DataKeys[e.Row.RowIndex].Values[1].ToString();
            //    }
            //}
            //if (e.Row.RowType == DataControlRowType.Footer)
            //{
            //    DropDownList cmbNewType = (DropDownList)e.Row.FindControl("cmbNewType");
            //    cmbNewType.DataSource = contactTypes;
            //    cmbNewType.DataBind();
            //}
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string bookingid    = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "bookingid"));
                Button lnkbtnresult = (Button)e.Row.FindControl("ButtonDelete");
                if (lnkbtnresult != null)
                {
                    lnkbtnresult.Attributes.Add("onclick", "javascript:return deleteConfirm('" + bookingid + "')");
                }
            }
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                DropDownList        ddList  = (DropDownList)e.Row.FindControl("insertfloorno");
                ContactTableAdapter contact = new ContactTableAdapter();
                //return DataTable havinf department data
                DataTable dt = contact.GetFloors();
                ddList.DataSource     = dt;
                ddList.DataTextField  = "floorno";
                ddList.DataValueField = "floorno";
                ddList.DataBind();

                //DataRowView dr = e.Row.DataItem as DataRowView;
                //ddList.SelectedValue = dr["insertroomno"].ToString();
            }

            //ContactTableAdapter contact = new ContactTableAdapter();
            //if (e.Row.RowType == DataControlRowType.DataRow)
            //{
            //GridView1.DataBind();
            //Find the DropDownList in the Row
            //if (Convert.ToInt32(e.Row.Cells[0].Text) < 10000)
            //{
            //    e.Row.BackColor = System.Drawing.Color.AliceBlue;
            //}
            //}
        }