示例#1
0
    private void GridViewAdminDataBind()
    {
        MyAspNetPager.PageSize = 18;
        Int32  recordcount;
        string sql = "SELECT * FROM T_WEBMANAGE WHERE STATUS=" + this.rblStatus.SelectedValue;

        if (!string.IsNullOrEmpty(txtUserName.Text))
        {
            sql += " AND USERNAME LIKE '%" + txtUserName.Text + "%'";
        }
        if (!string.IsNullOrEmpty(txtTrueName.Text))
        {
            sql += " AND TRUENAME LIKE '%" + txtTrueName.Text + "%'";
        }
        sql += " ORDER BY ID DESC";

        DataTable DT = Pages.GetPage(sql, MyAspNetPager.CurrentPageIndex, MyAspNetPager.PageSize, out recordcount);

        GridViewAdmin.DataSource = DT;
        GridViewAdmin.DataBind();
        this.MyAspNetPager.RecordCount   = recordcount;
        MyAspNetPager.TextBeforeInputBox = "共" + this.MyAspNetPager.RecordCount + "条  转到第";
        MyAspNetPager.TextAfterInputBox  = "页";
        this.lblRecordCount.Text         = recordcount.ToString();
        this.lblPageSize.Text            = MyAspNetPager.CurrentPageIndex.ToString();
    }
        protected void ButtonUsunAdmina_Click(object sender, EventArgs e)
        {
            int z = Convert.ToInt32(Session["IdAdmin"]);

            if (z == 0)
            {
                Response.Write("<script>alert ('NIE WYBRANO ŻADNEGO ADMINISTRATORA')</script>");
            }
            else
            {
                try
                {
                    con.Open();

                    string     cmdUsunAdmina = "DELETE FROM administratorzy WHERE id=" + (string)Session["IdAdmin"] + ";";
                    SqlCommand cmd           = new SqlCommand(cmdUsunAdmina, con);
                    cmd.ExecuteNonQuery();

                    con.Close();
                    GridViewAdmin.DataBind();
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
                Session["IdAdmin"] = "0";
            }
            Session["IdAdmin"] = "0";
        }
    private void getData()
    {
        string cs = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

        using (SqlConnection con = new SqlConnection(cs))
        {
            SqlCommand cmd = new SqlCommand("getAllUserAccounts", con);
            cmd.CommandType = CommandType.StoredProcedure;
            con.Open();
            GridViewAdmin.DataSource = cmd.ExecuteReader();
            GridViewAdmin.DataBind();
        }
    }
示例#4
0
        private void GridViewDataBind()
        {
            User user = (User)Session["AuthenticatedUserData"];

            if (user != null)
            {
                GridViewAdmin.DataSource = BorrowDataProcess.GetUserBorrows(user.UserId); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
                GridViewAdmin.DataBind();                                                 //this.DataBind() değil GridView’in DataBind()’i çağrıldı
            }
            else
            {
                GridViewAdmin.DataSource = BorrowDataProcess.GetBorrows(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
                GridViewAdmin.DataBind();                                  //this.DataBind() değil GridView’in DataBind()’i çağrıldı
            }
        }
示例#5
0
        protected void GridViewAdmin_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            User user = (User)Session["AuthenticatedUserData"];

            if (e.CommandName == "ExtendTime")
            {
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                GridViewAdmin.EditIndex  = rowIndex;
                GridViewAdmin.DataSource = BorrowDataProcess.GetUserBorrows(user.UserId); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
                GridViewAdmin.DataBind();                                                 //this.DataBind() değil GridView’in DataBind()’i çağrıldı
            }
            else if (e.CommandName == "Extend")
            {
                int    rowIndex    = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                String Returndate  = ((DropDownList)GridViewAdmin.Rows[rowIndex].FindControl("ddlReturnTime")).SelectedValue;
                String RecieveDate = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelRecieve")).Text;
                String name        = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelUserName")).Text;
                String itemName    = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelEditName")).Text;
                int    userId      = BorrowDataProcess.getUserIdByNickName(name).UserId;
                int    itemId      = ItemDataProcess.getItemIdByItemName(itemName);
                Borrow borrow      = new Borrow();

                string   oldDate  = (e.CommandArgument).ToString().Substring(0, 10);
                string[] tempDate = oldDate.Split('.');
                int      coeff    = Convert.ToInt32(Returndate.Split(' ')[0]);

                int day   = Convert.ToInt32(tempDate[0]) + (coeff * 7);
                int month = Convert.ToInt32(tempDate[1]);
                int year  = Convert.ToInt32(tempDate[2]);
                if (day > 30)
                {
                    day = day % 30;
                    month++;
                }
                if (month > 12)
                {
                    month = month % 12;
                    year++;
                }

                Returndate        = year.ToString() + month.ToString().PadLeft(2, '0') + day.ToString().PadLeft(2, '0');
                borrow.ReturnDate = Returndate.ToString();
                borrow.UserId     = userId;
                borrow.ItemId     = itemId;
                BorrowDataProcess.UpdateBorrow(borrow);
                GridViewAdmin.EditIndex  = -1;
                GridViewAdmin.DataSource = BorrowDataProcess.GetUserBorrows(user.UserId); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
                GridViewAdmin.DataBind();                                                 //this.DataBind() değil GridView’in DataBind()’i çağrıldı
            }
            else if (e.CommandName == "ReturnItem")
            {
                int    rowIndex    = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                String Returndate  = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelReturn")).Text;
                String name        = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelUserName")).Text;
                String itemName    = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelName")).Text;
                String RecieveDate = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelReceive")).Text;

                int userId   = BorrowDataProcess.getUserIdByNickName(name).UserId;
                int itemId   = ItemDataProcess.getItemIdByItemName(itemName);
                int memberId = MemberDataProcess.getMemberByUserId(userId).MemberId;
                //controlReturning(RecieveDate,Returndate);
                string[] cRetDate = Returndate.Split('/');
                string   tempRet  = cRetDate[2] + cRetDate[1] + cRetDate[0];
                string[] cRecDate = RecieveDate.Split('/');
                string   tempRec  = cRecDate[2] + cRecDate[1] + cRecDate[0];

                Bill     bill = new Bill();
                string[] temp = DateTime.Now.ToShortDateString().Split('/');
                bill.BillDate = temp[2] + temp[1] + temp[0];
                bill.ItemID   = itemId;
                bill.MemberID = memberId;

                bill.BillValue = calculateBillValue(tempRet).ToString();

                BorrowDataProcess.InsertBill(bill);
                Response.Redirect("HomeLibrary.aspx");
            }
            else if (e.CommandName == "CancelUpdate")
            {
                GridViewAdmin.EditIndex  = -1;
                GridViewAdmin.DataSource = BorrowDataProcess.GetUserBorrows(user.UserId); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
                GridViewAdmin.DataBind();                                                 //this.DataBind() değil GridView’in DataBind()’i çağrıldı
            }
        }
 private void GridViewDataBind()
 {
     GridViewAdmin.DataSource = MemberDataProcess.GetMembers(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
     GridViewAdmin.DataBind();                                  //this.DataBind() değil GridView’in DataBind()’i çağrıldı
 }
 private void GridViewDataBind()
 {
     if (ItemDataProcess.type == itemType)
     {
         if (Session["AuthenticatedAdminData"] != null)
         {
             GridViewAdmin.DataSource = ItemDataProcess.GetItems(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewAdmin.DataBind();                              //this.DataBind() değil GridView’in DataBind()’i çağrıldı
         }
         else
         {
             GridViewUser.DataSource = ItemDataProcess.GetItems(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewUser.DataBind();                              //this.DataBind() değil GridView’in DataBind()’i çağrıldı
         }
     }
     else if (ItemDataProcess.type == bookType)
     {
         if (Session["AuthenticatedAdminData"] != null)
         {
             GridViewAdminDistinct.DataSource = ItemDataProcess.GetBooks(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewAdminDistinct.DataBind();
         }
         else
         {
             GridViewUserDistinct.DataSource = ItemDataProcess.GetBooks(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewUserDistinct.DataBind();
         }
     }
     else if (ItemDataProcess.type == journalType)
     {
         if (Session["AuthenticatedAdminData"] != null)
         {
             GridViewAdminDistinct.DataSource = ItemDataProcess.GetJournals(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewAdminDistinct.DataBind();
         }
         else
         {
             GridViewUserDistinct.DataSource = ItemDataProcess.GetJournals(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewUserDistinct.DataBind();
         }
     }
     else if (ItemDataProcess.type == newspaperType)
     {
         if (Session["AuthenticatedAdminData"] != null)
         {
             GridViewAdminDistinct.DataSource = ItemDataProcess.GetNewspapers(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewAdminDistinct.DataBind();
         }
         else
         {
             GridViewUserDistinct.DataSource = ItemDataProcess.GetNewspapers(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewUserDistinct.DataBind();
         }
     }
     else if (ItemDataProcess.type == videoType)
     {
         if (Session["AuthenticatedAdminData"] != null)
         {
             GridViewAdminDistinct.DataSource = ItemDataProcess.GetVideos(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewAdminDistinct.DataBind();
         }
         else
         {
             GridViewUserDistinct.DataSource = ItemDataProcess.GetVideos(); //Görüldüğü gibi GridView’e DataSet nesnesi atanıyor.
             GridViewUserDistinct.DataBind();
         }
     }
 }