Esempio n. 1
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ı
            }
        }
Esempio n. 2
0
 protected int convertUserIdToMemberId(int userId)
 {
     return(MemberDataProcess.getMemberByUserId(userId).MemberId);
 }