Exemple #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;
            }
        }
        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();
            }
        }
        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")
            {
                AdminDataProcess.DeleteAdminByID(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;
                Admin admin    = new Admin();
                User  user     = new User();
                admin.AdminId  = Convert.ToInt32(e.CommandArgument);
                admin.WorkHour = Convert.ToInt32(((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxEditWorkHour")).Text);

                user.Name     = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxAdminName")).Text;
                user.Gender   = ((DropDownList)GridViewAdmin.Rows[rowIndex].FindControl("ddlGender")).SelectedItem.Text;
                user.Address  = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxAdminAddress")).Text;
                user.Password = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxAdminPassword")).Text;
                user.NickName = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxAdminNickName")).Text;
                string online = ((Label)GridViewAdmin.Rows[rowIndex].FindControl("LabelAdminOnline")).Text;
                if (online == "Offline")
                {
                    user.IsOnline = false;
                }
                else if (online == "Online")
                {
                    user.IsOnline = true;
                }
                user.Mail = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxAdminMail")).Text;

                GridViewAdmin.EditIndex = -1;
                admin.UserId            = AdminDataProcess.getUserIdByAdminId(admin.AdminId);
                user.UserId             = AdminDataProcess.getUserIdByAdminId(admin.AdminId);
                UserDataProcess.UpdateUsers(user);
                AdminDataProcess.UpdateAdmins(admin);


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

                admin.WorkHour = Convert.ToInt32(((TextBox)GridViewAdmin.FooterRow.FindControl("TextBoxInsertWorkHour")).Text);

                user.Name     = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtName")).Text;
                user.Gender   = ((DropDownList)GridViewAdmin.FooterRow.FindControl("ddlAdminInsertGender")).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);
                admin.UserId = AdminDataProcess.getUserIdByNickName(user.NickName);//select gender kısmı problem//ekran paass insert nokta//delete için tirgger olmalı //active ve online düzeltilmeli/7store u at //ay hafta doldur
                AdminDataProcess.InsertAdmin(admin);
                GridViewDataBind();
            }
        }