Ejemplo n.º 1
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int        updated;
        int        rowupdate = e.RowIndex;
        clsbooking obj       = new clsbooking();

        try
        {
            obj.BookingID = int.Parse((String)GridView1.Rows[rowupdate].Cells[1].Text);
            obj.Delete();
            obj.CarNo = (String)GridView1.Rows[rowupdate].Cells[5].Text;

            String query = "update tblcar set Booked='" + "NO" + "' where CarNo='" + obj.CarNo + "'";
            updated = dbobj.InsertUpdateDelete(query);


            GridView1.EditIndex = -1;

            //refresh the grid view
            populateGridview();
        }
        catch (Exception err)
        {
            lblmsg.Text = err.Message;
        }
    }
Ejemplo n.º 2
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int        updated, result;
        int        rowupdate = e.RowIndex;
        clsbooking obj       = new clsbooking();

        try
        {
            obj.BookingID = int.Parse((String)GridView1.Rows[rowupdate].Cells[1].Text);
            DateTime cdt       = DateTime.Now.AddHours(1);
            String[] splitdate = GridView1.Rows[rowupdate].Cells[4].Text.Split('-');
            String[] splittime = GridView1.Rows[rowupdate].Cells[5].Text.Split(':');

            DateTime pdt = new DateTime(int.Parse(splitdate[2]), int.Parse(splitdate[1]), int.Parse(splitdate[0]), int.Parse(splittime[0]), int.Parse(splittime[1]), 00);
            result = DateTime.Compare(pdt, cdt);

            if (result > 0)
            {
                obj.Delete();

                obj.CarNo = (String)GridView1.Rows[rowupdate].Cells[2].Text;

                String query = "update tblcar set Booked='" + "NO" + "' where CarNo='" + obj.CarNo + "'";
                updated = dbobj.InsertUpdateDelete(query);

                //remove the edit mode
                GridView1.EditIndex = -1;

                //refresh the grid view
                populateGridview();
            }
            else
            {
                lblmsg.Text = "Previous Bookings Cannot Be Cancelled";
            }
        }
        catch (Exception err)
        {
            lblmsg.Text = err.Message;
        }
    }