Exemplo n.º 1
0
        protected void ButtonSignUp_Click(object sender, EventArgs e)
        {
            Member member = new Member();
            User   user   = new User();

            user.Name          = TextBoxName.Text;
            user.NickName      = TextBoxNick.Text;
            user.Mail          = TextBoxMail.Text;
            user.Address       = TextBoxAddress.Text;
            member.FacultyName = ddlFacultyName.SelectedItem.Text;
            member.MemberType  = ddlMemberType.SelectedItem.Text;
            user.Gender        = RadioButtonGender.Text;
            user.Password      = InputPassword.Value;
            if (user.Password == InputConfirmPassword.Value)
            {
                UserDataProcess.InsertUser(user);
                member.UserId = MemberDataProcess.getUserIdByNickName(user.NickName);
                MemberDataProcess.InsertMember(member);
                Response.Redirect("Default.aspx");
            }
            else
            {
                TextBoxAddress.Text          = "";
                InputPassword.Value          = "";
                TextBoxMail.Text             = "";
                TextBoxName.Text             = "";
                TextBoxNick.Text             = "";
                InputConfirmPassword.Value   = "";
                ddlFacultyName.SelectedIndex = -1;
                ddlMemberType.SelectedIndex  = -1;
            }
        }
Exemplo n.º 2
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ı
            }
        }
Exemplo n.º 3
0
 protected int convertUserIdToMemberId(int userId)
 {
     return(MemberDataProcess.getMemberByUserId(userId).MemberId);
 }
 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ı
 }
        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")
            {
                int memberID = Convert.ToInt32(e.CommandArgument);
                int userID   = MemberDataProcess.getUserIdByMemberId(memberID);
                MemberDataProcess.DeleteBillByMemberID(memberID);
                BorrowDataProcess.DeleteBorrowByUserID(userID);//Önce kiralamaları varsa onları siliyoruz.
                MemberDataProcess.DeleteMemberByID(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;
                Member member   = new Member();
                User   user     = new User();
                member.MemberId    = Convert.ToInt32(e.CommandArgument);
                member.FacultyName = ((DropDownList)GridViewAdmin.Rows[rowIndex].FindControl("ddlFacultyName")).SelectedItem.Text;
                member.MemberType  = ((DropDownList)GridViewAdmin.Rows[rowIndex].FindControl("ddlMemberType")).SelectedItem.Text;
                member.IsActive    = true;

                user.Name     = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxMemberName")).Text;
                user.Gender   = ((DropDownList)GridViewAdmin.Rows[rowIndex].FindControl("ddlGender")).SelectedItem.Text;
                user.Address  = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxMemberAddress")).Text;
                user.Password = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxMemberPassword")).Text;
                user.NickName = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxMemberNickName")).Text;
                user.IsOnline = false;
                user.Mail     = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxMemberMail")).Text;

                GridViewAdmin.EditIndex = -1;
                member.UserId           = MemberDataProcess.getUserIdByMemberId(member.MemberId);
                user.UserId             = MemberDataProcess.getUserIdByMemberId(member.MemberId);
                UserDataProcess.UpdateUsers(user);
                MemberDataProcess.UpdateMembers(member);


                GridViewDataBind();
            }
            else if (e.CommandName == "InsertRow")
            {
                Member member = new Member();
                User   user   = new User();

                member.FacultyName = ((DropDownList)GridViewAdmin.FooterRow.FindControl("ddlMemberInsertFacultyName")).SelectedItem.Text;
                member.MemberType  = ((DropDownList)GridViewAdmin.FooterRow.FindControl("ddlMemberInsertType")).SelectedItem.Text;
                member.IsActive    = true;


                user.Name     = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtName")).Text;
                user.Gender   = ((DropDownList)GridViewAdmin.FooterRow.FindControl("ddlMemberInsertGender")).SelectedItem.Text;
                user.Address  = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtAddress")).Text;
                user.Password = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtPassword")).Text;
                user.NickName = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtNickName")).Text;
                user.IsOnline = false;

                user.Mail = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtMail")).Text;

                UserDataProcess.InsertUser(user);
                member.UserId = MemberDataProcess.getUserIdByNickName(user.NickName);
                MemberDataProcess.InsertMember(member);
                GridViewDataBind();
            }
        }