protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         String[] array = new String[10];
         array = ItemDataProcess.getBookByItemId(4);
         GridViewDataBind();
         List <Category>  categories = ItemDataProcess.GetCategories();
         List <Publisher> publishers = ItemDataProcess.GetPublishers();
         Session["PublisherData"] = publishers;
         Session["CategoryData"]  = categories;
         if (Session["AuthenticatedAdminData"] != null)
         {
             FillCategories();
             FillPublishers();
             FillDate();
         }
     }
 }
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         if ((DropDownList)e.Row.FindControl("ddlDistinctItemCategory") != null)
         {
             DropDownList DropDownList1 = (DropDownList)e.Row.FindControl("ddlDistinctItemCategory");
             DropDownList1.DataSource     = ItemDataProcess.GetCategories();
             DropDownList1.DataTextField  = "name";
             DropDownList1.DataValueField = "categoryId";
             DropDownList1.DataBind();
         }
         if ((DropDownList)e.Row.FindControl("ddlDistinctItemPublisher") != null)
         {
             DropDownList DropDownList1 = (DropDownList)e.Row.FindControl("ddlDistinctItemPublisher");
             DropDownList1.DataSource     = ItemDataProcess.GetPublishers();
             DropDownList1.DataTextField  = "name";
             DropDownList1.DataValueField = "publisherId";
             DropDownList1.DataBind();
         }
     }
 }
Esempio n. 3
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "EditRow")
     {
         int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
         GridViewAdmin.EditIndex = rowIndex;
         GridViewDataBind();
     }
     else if (e.CommandName == "DeleteRow")
     {
         ItemDataProcess.DeleteCategoriesByID(Convert.ToInt32(e.CommandArgument));
         GridViewDataBind();
     }
     else if (e.CommandName == "CancelUpdate")
     {
         GridViewAdmin.EditIndex = -1;
         GridViewDataBind();
     }
     else if (e.CommandName == "UpdateRow")
     {
         int      rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
         Category category = new Category();
         category.CategoryId     = Convert.ToInt32(e.CommandArgument);
         category.Name           = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxCategoryName")).Text;
         category.ShelfNumber    = ((DropDownList)GridViewAdmin.Rows[rowIndex].FindControl("DropDownListCategoryShelfNumber")).SelectedItem.Text;
         GridViewAdmin.EditIndex = -1;
         ItemDataProcess.UpdateCategories(category);
         GridViewDataBind();
     }
     else if (e.CommandName == "InsertRow")
     {
         Category category = new Category();
         category.Name        = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtName")).Text;
         category.ShelfNumber = ((DropDownList)GridViewAdmin.FooterRow.FindControl("dllCategoryInsertShelfNumber")).SelectedItem.Text;
         ItemDataProcess.InsertCategories(category);
         GridViewDataBind();
     }
 }
 protected void GridViewAdmin_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "EditRow")
     {
         int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
         GridViewAdmin.EditIndex = rowIndex;
         GridViewDataBind();
     }
     else if (e.CommandName == "DeleteRow")
     {
         ItemDataProcess.DeletePublishersByID(Convert.ToInt32(e.CommandArgument));
         GridViewDataBind();
     }
     else if (e.CommandName == "CancelUpdate")
     {
         GridViewAdmin.EditIndex = -1;
         GridViewDataBind();
     }
     else if (e.CommandName == "UpdateRow")
     {
         int       rowIndex  = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
         Publisher publisher = new Publisher();
         publisher.PublisherId   = Convert.ToInt32(e.CommandArgument);
         publisher.Name          = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxPublisherName")).Text;
         publisher.Address       = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxPublisherAddress")).Text;
         GridViewAdmin.EditIndex = -1;
         ItemDataProcess.UpdatePublishers(publisher);
         GridViewDataBind();
     }
     else if (e.CommandName == "InsertRow")
     {
         Publisher publisher = new Publisher();
         publisher.Name    = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtName")).Text;
         publisher.Address = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtAddress")).Text;
         ItemDataProcess.InsertPublishers(publisher);
         GridViewDataBind();
     }
 }
Esempio n. 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ı
            }
        }
Esempio n. 6
0
        protected string returnItemName(int itemID)
        {
            Item item = ItemDataProcess.getItemByID(itemID);

            return(item.Name);
        }
Esempio n. 7
0
 private void GridViewDataBind()
 {
     GridViewAdmin.DataSource = ItemDataProcess.GetCategories(); //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();
         }
     }
 }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditRow")
            {
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                GridViewAdminDistinct.EditIndex = rowIndex;
                FillGridView();
            }
            else if (e.CommandName == "DeleteRow")
            {
                if (ItemDataProcess.type == bookType)
                {
                    ItemDataProcess.DeleteBookByID(Convert.ToInt32(e.CommandArgument));
                }
                else if (ItemDataProcess.type == journalType)
                {
                    ItemDataProcess.DeleteJournalByID(Convert.ToInt32(e.CommandArgument));
                }
                else if (ItemDataProcess.type == newspaperType)
                {
                    ItemDataProcess.DeleteNewspaperByID(Convert.ToInt32(e.CommandArgument));
                }
                else if (ItemDataProcess.type == videoType)
                {
                    ItemDataProcess.DeleteVideoByID(Convert.ToInt32(e.CommandArgument));
                }
                FillGridView();
            }
            else if (e.CommandName == "CancelUpdate")
            {
                GridViewAdminDistinct.EditIndex = -1;
                FillGridView();
            }
            else if (e.CommandName == "UpdateRow")
            {
                int  rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                Item item     = new Item();

                item.Name = ((TextBox)GridViewAdminDistinct.Rows[rowIndex].FindControl("TextBoxDistinctItemName")).Text;
                String state = ((DropDownList)GridViewAdminDistinct.Rows[rowIndex].FindControl("ddlDistinctItemState")).SelectedValue;
                if (state == "Available")
                {
                    item.State = 1;
                }
                else if (state == "Unavailable")
                {
                    item.State = 0;
                }

                item.ProductionDate = deConvertDate(((TextBox)GridViewAdminDistinct.Rows[rowIndex].FindControl("TextBoxDistinctItemProductionDate")).Text);//Date aldıktan sonra işlem yapppppp.....
                item.CategoryId     = ItemDataProcess.getCategoryIDByName(((DropDownList)GridViewAdminDistinct.Rows[rowIndex].FindControl("ddlDistinctItemCategory")).SelectedItem.Text);
                item.PublisherId    = ItemDataProcess.getPublisherIDByName(((DropDownList)GridViewAdminDistinct.Rows[rowIndex].FindControl("ddlDistinctItemPublisher")).SelectedItem.Text);
                item.Type           = ((Label)GridViewAdminDistinct.Rows[rowIndex].FindControl("LabelDistinctEditType")).Text;
                if (ItemDataProcess.type == bookType)
                {
                    Book book = new Book();
                    book.BookId = Convert.ToInt32(e.CommandArgument);
                    book.Author = ((TextBox)GridViewAdminDistinct.Rows[rowIndex].FindControl("TextBoxDistinctItemKolon")).Text;
                    item.ItemId = ItemDataProcess.getBookByBookId(book.BookId).ItemId;
                    ItemDataProcess.UpdateItems(item);
                    book.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.UpdateBook(book);
                }
                else if (ItemDataProcess.type == journalType)
                {
                    Journal journal = new Journal();
                    journal.JournalId = Convert.ToInt32(e.CommandArgument);
                    journal.TimeRange = ((TextBox)GridViewAdminDistinct.Rows[rowIndex].FindControl("TextBoxDistinctItemKolon")).Text;
                    item.ItemId       = ItemDataProcess.getJournalByJournalId(journal.JournalId).ItemId;
                    ItemDataProcess.UpdateItems(item);
                    journal.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.UpdateJournal(journal);
                }
                else if (ItemDataProcess.type == newspaperType)
                {
                    Newspaper news = new Newspaper();
                    news.NewspaperId = Convert.ToInt32(e.CommandArgument);
                    news.Period      = ((TextBox)GridViewAdminDistinct.Rows[rowIndex].FindControl("TextBoxDistinctItemKolon")).Text;
                    item.ItemId      = ItemDataProcess.getNewspaperByNewspaperId(news.NewspaperId).ItemId;
                    ItemDataProcess.UpdateItems(item);
                    news.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.UpdateNewspaper(news);
                }
                else if (ItemDataProcess.type == videoType)
                {
                    Video video = new Video();
                    video.VideoId = Convert.ToInt32(e.CommandArgument);
                    video.Format  = ((TextBox)GridViewAdminDistinct.Rows[rowIndex].FindControl("TextBoxDistinctItemKolon")).Text;
                    item.ItemId   = ItemDataProcess.getVideoByVideoId(video.VideoId).ItemId;
                    ItemDataProcess.UpdateItems(item);
                    video.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.UpdateVideo(video);
                }


                GridViewAdminDistinct.EditIndex = -1;

                FillGridView();
            }
            else if (e.CommandName == "InsertRow")
            {
                Item item = new Item();
                item.Name = ((TextBox)GridViewAdminDistinct.FooterRow.FindControl("txtDistinctName")).Text;
                String state = ((DropDownList)GridViewAdminDistinct.FooterRow.FindControl("ddlDistinctItemInsertState")).SelectedValue;
                if (state == "Available")
                {
                    item.State = 1;
                }
                else if (state == "Unavailable")
                {
                    item.State = 0;
                }
                string date = ((DropDownList)GridViewAdminDistinct.FooterRow.FindControl("ddlDistinctItemYear")).Text + ((DropDownList)GridViewAdminDistinct.FooterRow.FindControl("ddlDistinctItemMonth")).Text.PadLeft(2, '0') + ((DropDownList)GridViewAdminDistinct.FooterRow.FindControl("ddlDistinctItemDay")).Text.PadLeft(2, '0');
                item.ProductionDate = date;
                item.CategoryId     = ItemDataProcess.getCategoryIDByName(((DropDownList)GridViewAdminDistinct.FooterRow.FindControl("ddlDistinctFooterItemCategory")).SelectedItem.Text);
                item.PublisherId    = ItemDataProcess.getPublisherIDByName(((DropDownList)GridViewAdminDistinct.FooterRow.FindControl("ddlDistinctFooterItemPublisher")).SelectedItem.Text);
                string types = returnPrimaryKey();
                item.Type = types.Substring(0, types.Length - 2);

                if (ItemDataProcess.type == bookType)
                {
                    Book book = new Book();
                    book.Author = ((TextBox)GridViewAdminDistinct.FooterRow.FindControl("txtDistinctKolon")).Text;
                    ItemDataProcess.InsertItems(item);
                    book.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.InsertBook(book);
                }
                else if (ItemDataProcess.type == journalType)
                {
                    Journal jor = new Journal();
                    jor.TimeRange = ((TextBox)GridViewAdminDistinct.FooterRow.FindControl("txtDistinctKolon")).Text;
                    ItemDataProcess.InsertItems(item);
                    jor.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.InsertJournal(jor);
                }
                else if (ItemDataProcess.type == newspaperType)
                {
                    Newspaper news = new Newspaper();
                    news.Period = ((TextBox)GridViewAdminDistinct.FooterRow.FindControl("txtDistinctKolon")).Text;
                    ItemDataProcess.InsertItems(item);
                    news.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.InsertNewspaper(news);
                }
                else if (ItemDataProcess.type == videoType)
                {
                    Video video = new Video();
                    video.Format = ((TextBox)GridViewAdminDistinct.FooterRow.FindControl("txtDistinctKolon")).Text;
                    ItemDataProcess.InsertItems(item);
                    video.ItemId = ItemDataProcess.getItemIdByItemName(item.Name);
                    ItemDataProcess.InsertVideo(video);
                }
                FillGridView();
            }
            else if (e.CommandName == "Rent")/*Kiralama Kısmı*/
            {
                User user = (User)Session["AuthenticatedUserData"];
                Item item = new Item();
                int  id   = Convert.ToInt16(e.CommandArgument);//book ise bookId, video ise video id .....

                string[] tempItem = new string[10];
                if (ItemDataProcess.type == bookType)
                {
                    tempItem = ItemDataProcess.getBookByItemId(id);
                }
                else if (ItemDataProcess.type == journalType)
                {
                    tempItem = ItemDataProcess.getJournalByItemId(id);
                }
                else if (ItemDataProcess.type == newspaperType)
                {
                    tempItem = ItemDataProcess.getNewspaperByItemId(id);
                }
                else if (ItemDataProcess.type == videoType)
                {
                    tempItem = ItemDataProcess.getVideoByItemId(id);
                }
                item.ItemId         = Convert.ToInt32(tempItem[0]);
                item.Name           = tempItem[1];
                item.State          = Convert.ToInt32(tempItem[2]);
                item.ProductionDate = tempItem[3];
                item.CategoryId     = Convert.ToInt32(tempItem[4]);
                item.PublisherId    = Convert.ToInt32(tempItem[5]);
                item.Type           = tempItem[6];
                Borrow borrow = new Borrow();
                borrow.ItemId = item.ItemId;
                borrow.UserId = user.UserId;
                string   dateReceive = "";
                string   dateReturn  = "";
                string[] temp        = DateTime.Now.ToShortDateString().Split('-');
                dateReceive = temp[2] + temp[1].PadLeft(2, '0') + temp[0].PadLeft(2, '0');
                int day   = Convert.ToInt32(temp[0]) + 7;
                int month = Convert.ToInt32(temp[1]);
                int year  = Convert.ToInt32(temp[2]);
                if (day > 30)
                {
                    day = day % 30;
                    month++;
                }
                if (month > 12)
                {
                    month = month % 12;
                    year++;
                }
                dateReturn         = year + month.ToString().PadLeft(2, '0') + day.ToString().PadLeft(2, '0');
                borrow.ReceiveDate = dateReceive;
                borrow.ReturnDate  = dateReturn;
                BorrowDataProcess.InsertBorrow(borrow);
                Response.Redirect("BorrowList.aspx");
            }
        }
 protected string[] returnAllVideo(int id)
 {
     return(ItemDataProcess.getVideoByItemId(id));
 }
 protected string[] returnAllNewspaper(int id)
 {
     return(ItemDataProcess.getNewspaperByItemId(id));
 }
 protected string[] returnAllJournal(int id)
 {
     return(ItemDataProcess.getJournalByItemId(id));
 }
 protected string[] returnAllBook(int id)
 {
     return(ItemDataProcess.getBookByItemId(id));
 }
 protected Item returnItemById(int id)
 {
     return(ItemDataProcess.getItemByID(id));
 }
 protected string returnPublisherName(int value)
 {
     return(ItemDataProcess.getPublisherNameByPublisherID(value));;
 }
 protected string returnCategoryName(int value)
 {
     return(ItemDataProcess.getCategoryNameByCategoryID(value));
 }