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[] returnAllJournal(int id)
 {
     return(ItemDataProcess.getJournalByItemId(id));
 }