コード例 #1
0
ファイル: Edit.aspx.cs プロジェクト: MarwaAlhazmi/Alrashaqa
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            switch (rbAdd.SelectedIndex)
            {
            case 0:
                pnlEmp.Visible     = true;
                pnlDep.Visible     = false;
                pnlService.Visible = false;
                pnlWith.Visible    = false;
                using (ClubDBEntities club = new ClubDBEntities())
                {
                    gvEmp.DataSource = club.getEmployees();
                    gvEmp.DataBind();
                }
                break;

            case 1:
                pnlEmp.Visible     = false;
                pnlDep.Visible     = false;
                pnlService.Visible = true;
                pnlWith.Visible    = false;
                using (ClubDBEntities club = new ClubDBEntities())
                {
                    var r = club.getServices();
                    gvSer.DataSource = r;
                    gvSer.DataBind();
                }

                break;

            case 2:
                pnlEmp.Visible     = false;
                pnlDep.Visible     = true;
                pnlService.Visible = false;
                pnlWith.Visible    = false;
                using (ClubDBEntities club = new ClubDBEntities())
                {
                    var r = from i in club.Departments
                            orderby i.DepID
                            select i
                    ;
                    gvDep.DataSource = r;
                    gvDep.DataBind();
                }
                break;

            case 3:
                pnlEmp.Visible     = false;
                pnlDep.Visible     = false;
                pnlService.Visible = false;
                pnlWith.Visible    = true;
                using (ClubDBEntities club = new ClubDBEntities())
                {
                    var result = club.getWithTypes();
                    gvWith.DataSource = result;
                    gvWith.DataBind();
                }
                break;
            }
        }
コード例 #2
0
ファイル: Edit.aspx.cs プロジェクト: MarwaAlhazmi/Alrashaqa
        protected void btnWSave_Click(object sender, EventArgs e)
        {
            string name = tbWName.Text;
            int    dep  = Convert.ToInt32(ddlWDep.SelectedValue);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                var u = (from i in club.WithTypes
                         where i.ID == EditWith
                         select i).First();
                u.Name       = name;
                u.Department = dep;

                club.SaveChanges();
                tbWName.Text          = "";
                ddlWDep.SelectedIndex = 0;
                withTable.Visible     = false;
                gvWith.DataSource     = club.getWithTypes();
                gvWith.DataBind();
            }
        }
コード例 #3
0
ファイル: Edit.aspx.cs プロジェクト: MarwaAlhazmi/Alrashaqa
        protected void gvWith_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(gvWith.Rows[e.RowIndex].Cells[4].Text);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                try
                {
                    var re = club.WithTypes.Where(a => a.ID == id).First();
                    club.WithTypes.DeleteObject(re);
                    club.SaveChanges();
                    gvWith.DataSource = club.getWithTypes();
                    gvWith.DataBind();
                    string Message = " تم الحذف  ";
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
                }
                catch
                {
                    lblError.Text    = "لايمكن الحذف";
                    lblError.Visible = true;
                }
            }
        }