Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] == null || Session["SystemRole"] == null)
            {
                Response.Redirect("login.aspx");
            }
            txtCommitteeDate.Text = txtCommitteeDateHidden.Value;
            if (!IsPostBack)
            {
                txtCommitteeDate.Text = "";
                divAddMember.Visible  = false;
                selectedUsers         = new List <int>();
                userGrids             = new List <UserGrid>();
                List <User> Members = WebApiConsume.GetUsers(Utilities.BASE_URL + "/api/Users/GetUsers");


                ddlMemberSelect.DataSource     = Members;
                ddlMemberSelect.DataTextField  = "Name";
                ddlMemberSelect.DataValueField = "ID";
                ddlMemberSelect.DataBind();
                ddlMemberSelect.Items.Insert(0, new ListItem("أختر من القائمه", "NULL"));
                ddlCommitteeSecrtary.DataSource     = Members;
                ddlCommitteeSecrtary.DataTextField  = "Name";
                ddlCommitteeSecrtary.DataValueField = "ID";
                ddlCommitteeSecrtary.DataBind();
                ddlCommitteeSecrtary.Items.Insert(0, new ListItem("أختر من القائمه", "NULL"));

                ddlCommitteepresident.DataSource     = Members;
                ddlCommitteepresident.DataTextField  = "Name";
                ddlCommitteepresident.DataValueField = "ID";
                ddlCommitteepresident.DataBind();
                ddlCommitteepresident.Items.Insert(0, new ListItem("أختر من القائمه", "NULL"));


                List <Committee.Models.Department> departments = WebApiConsume.GetDepartments(Utilities.BASE_URL + "/api/Deapartments/GetDepartments");


                ddlCommitteeDept.DataSource     = departments;
                ddlCommitteeDept.DataTextField  = "DeptName";
                ddlCommitteeDept.DataValueField = "DeptId";
                ddlCommitteeDept.DataBind();
                ddlCommitteeDept.SelectedValue = Session["DeptId"].ToString();
                ddlCommitteeDept.Enabled       = false;
                ddlCommitteeDept.Items.Insert(0, new ListItem("أختر من القائمه", "NULL"));
                int committeeId = Convert.ToInt32(Request.QueryString["cId"]);

                List <UserGrid> data = WebApiConsume.ShowCommitteeMembers(committeeId);
                if (Request.QueryString["status"] == "selected")
                {
                    gvMeeting.DataSource = ShowMeetings(Convert.ToInt32(Request.QueryString["cId"]));
                    gvMeeting.DataBind();



                    if (data.Count != 0)
                    {
                        lblmembersOfCommittee.Visible = true;
                        lblmembersOfCommittee.Text    = "الاعضاء المشتركون فى اللجنة";
                    }
                    else
                    {
                        lblmembersOfCommittee.Visible = true;
                        lblmembersOfCommittee.Text    = "لا يوجد اعضاء مشتركون فى  هذه اللجنة";
                    }
                    gvMembersOfCommittee.DataSource = data.Where(x => x != null).ToList();

                    gvMembersOfCommittee.DataBind();
                    ddlMemberChange.Visible        = true;
                    ddlMemberChange.DataSource     = Members;
                    ddlMemberChange.DataTextField  = "Name";
                    ddlMemberChange.DataValueField = "ID";
                    ddlMemberChange.DataBind();
                    ddlMemberChange.Items.Insert(0, new ListItem("أختر من القائمه", "NULL"));
                    gvMembersOfCommittee.Visible = true;
                    divAddMember.Visible         = true;
                }

                gvMembersOfCommittee.DataSource = data.Where(x => x != null).ToList();

                gvMembersOfCommittee.DataBind();
                LabelddlCommitteepresident.Visible = true;
                LabeddlCommitteeSecrtary.Visible   = true;
                ddlCommitteeSecrtary.Visible       = true;
                ddlCommitteepresident.Visible      = true;
                divAddMembers.Visible          = true;
                ddlMemberSelect.Visible        = true;
                ddlMemberSelect.DataSource     = Members;
                ddlMemberSelect.DataTextField  = "Name";
                ddlMemberSelect.DataValueField = "ID";
                ddlMemberSelect.DataBind();
                ddlMemberSelect.Items.Insert(0, new ListItem("أختر من القائمه", "NULL"));

                if (Request.QueryString["status"] == "selected")
                {
                    gvMeeting.DataSource = ShowMeetings(Convert.ToInt32(Request.QueryString["cId"]));
                    gvMeeting.DataBind();


                    committeeId = Convert.ToInt32(Request.QueryString["cId"]);

                    data = WebApiConsume.ShowCommitteeMembers(committeeId);
                    if (data.Count != 0)
                    {
                        lblmembersOfCommittee.Visible   = true;
                        lblmembersOfCommittee.Text      = "الاعضاء المشتركون فى اللجنة";
                        gvMembersOfCommittee.DataSource = data.Where(x => x != null).ToList();
                        gvMembersOfCommittee.DataBind();
                    }
                    else
                    {
                        lblmembersOfCommittee.Visible = true;
                        lblmembersOfCommittee.Text    = "لا يوجد اعضاء مشتركون فى  هذه اللجنة";
                    }
                }

                if (Request.QueryString["status"] == "update" || Request.QueryString["status"] == "selected")

                {
                    gvMeeting.Visible = true;
                    List <MeetingSearch> ms = ShowMeetings(Convert.ToInt32(Request.QueryString["cId"]));
                    if (ms.Count != 0)
                    {
                        lblgvMeeting.Visible = true;
                        lblgvMeeting.Text    = "اجتماعات اللجنة";
                        gvMeeting.DataSource = ms;
                        gvMeeting.DataBind();
                    }
                    else
                    {
                        lblgvMeeting.Visible = true;
                        lblgvMeeting.Text    = " لا يوجد اجتماعات لهذه اللجنة";
                    }

                    data = WebApiConsume.ShowCommitteeMembers(Convert.ToInt32(Request.QueryString["cId"]));
                    if (data.Count != 0)
                    {
                        lblmembersOfCommittee.Visible   = true;
                        lblmembersOfCommittee.Text      = "الاعضاء المشتركون فى اللجنة";
                        gvMembersOfCommittee.DataSource = data.Where(x => x != null).ToList();
                        gvMembersOfCommittee.DataBind();
                        lblmembersOfCommittee.Visible = true;
                    }
                    else
                    {
                        lblmembersOfCommittee.Visible = true;
                        lblmembersOfCommittee.Text    = "لا يوجد اعضاء مشتركون فى  هذه اللجنة";
                    }


                    lblAddCommitteetitle.Text = "تعديل اللجنة";
                    lblAddCommitteeh2.Text    = "تعديل اللجنة";
                    List <CommitteeSearchUpdate> committeesUpdate = new List <CommitteeSearchUpdate>();
                    string apiUrl3 = Utilities.BASE_URL + "/api/Committees";

                    WebClient client = new WebClient();
                    client.Headers["Content-type"] = "application/json";
                    client.Encoding = Encoding.UTF8;
                    int cId = Convert.ToInt32(Request.QueryString["cId"]);
                    ViewState["CommitteeId"] = cId;
                    Committee.Models.CommitteeRetrieveUpdate Committee = (new JavaScriptSerializer()).Deserialize <Committee.Models.CommitteeRetrieveUpdate>(client.DownloadString(apiUrl3 + "/GetCommitteeByIdForWeb?committeeId=" + cId.ToString()));
                    txtCommitteeDate.Text = Committee.CommitteeDate;
                    ddlCommitteeClassification.SelectedValue = Committee.Type.Id.ToString();
                    ddlCommitteeImportancy.SelectedValue     = Committee.Importance.Id.ToString();
                    ddlcommitteeStatus.SelectedValue         = Committee.Activity.Id.ToString();
                    txtCommitteeTopic.Text              = Committee.CommitteeTopic;
                    txtCommitteeBasedON.Text            = Committee.CommitteeBasedOn;
                    txtEnrollmentNumber.Text            = Committee.CommitteeEnrollmentNumber;
                    txtEnrollmentDate.Text              = Committee.CommitteeEnrollmentDate;
                    txtInboxSide.Text                   = Committee.CommitteeInbox1;
                    ddlCommitteeDept.SelectedValue      = Committee?.Department?.DeptId.ToString();
                    txtCommitteeName.Text               = Committee.CommitteeName;
                    ddlCommitteepresident.SelectedValue = Committee.CommitteeManager;
                    ddlCommitteeSecrtary.SelectedValue  = Committee.CommitteeSecretary;
                    ViewState["CreatedAt"]              = Committee.CreatedAt;
                    //gvCommittee.DataSource = ShowCommittees();
                    //gvCommittee.DataBind();
                }
                else
                {
                    lblAddCommitteetitle.Text = "اضافة لجنة جديدة";
                    lblAddCommitteeh2.Text    = "اضافة لجنة جديدة";
                }
                if (Request.QueryString["status"] == "selected")
                {
                    lblAddCommitteetitle.Text = "عرض اللجنة";
                    lblAddCommitteeh2.Text    = "عرض اللجنة";
                    List <CommitteeSearchUpdate> committeesUpdate = new List <CommitteeSearchUpdate>();
                    string apiUrl3 = Utilities.BASE_URL + "/api/Committees";

                    WebClient client = new WebClient();
                    client.Headers["Content-type"] = "application/json";
                    client.Encoding = Encoding.UTF8;
                    int cId = Convert.ToInt32(Request.QueryString["cId"]);
                    ViewState["CommitteeId"] = cId;
                    Committee.Models.CommitteeRetrieveUpdate Committee = (new JavaScriptSerializer()).Deserialize <Committee.Models.CommitteeRetrieveUpdate>(client.DownloadString(apiUrl3 + "/GetCommitteeByIdForWeb?committeeId=" + cId.ToString()));
                    txtCommitteeDate.Text    = Committee.CommitteeDate;
                    txtCommitteeDate.Enabled = false;
                    ddlCommitteeClassification.SelectedValue = Committee.Type.Id.ToString();
                    ddlCommitteeClassification.Enabled       = false;
                    ddlCommitteeImportancy.SelectedValue     = Committee.Importance.Id.ToString();
                    ddlCommitteeImportancy.Enabled           = false;
                    ddlcommitteeStatus.SelectedValue         = Committee.Activity.Id.ToString();
                    ddlcommitteeStatus.Enabled          = false;
                    txtCommitteeTopic.Text              = Committee.CommitteeTopic;
                    txtCommitteeTopic.Enabled           = false;
                    txtCommitteeBasedON.Text            = Committee.CommitteeBasedOn;
                    txtCommitteeBasedON.Enabled         = false;
                    txtEnrollmentNumber.Text            = Committee.CommitteeEnrollmentNumber;
                    txtEnrollmentNumber.Enabled         = false;
                    txtEnrollmentDate.Text              = Committee.CommitteeEnrollmentDate;
                    txtEnrollmentDate.Enabled           = false;
                    txtInboxSide.Text                   = Committee.CommitteeInbox1;
                    txtInboxSide.Enabled                = false;
                    ddlCommitteeDept.SelectedValue      = Committee?.Department?.DeptId.ToString();
                    ddlCommitteeDept.Enabled            = false;
                    txtCommitteeName.Text               = Committee.CommitteeName;
                    txtCommitteeName.Enabled            = false;
                    ddlCommitteepresident.SelectedValue = Committee.CommitteeManager;
                    ddlCommitteepresident.Enabled       = false;
                    ddlCommitteeSecrtary.SelectedValue  = Committee.CommitteeSecretary;
                    ddlCommitteeSecrtary.Enabled        = false;
                    btnSave.Visible      = false;
                    divAddMember.Visible = false;
                }
                if (Request.QueryString["status"] == "update")
                {
                    divAddMember.Visible           = true;
                    divAddMembers.Visible          = false;
                    ddlMemberChange.Visible        = true;
                    ddlMemberChange.DataSource     = Members;
                    ddlMemberChange.DataTextField  = "Name";
                    ddlMemberChange.DataValueField = "ID";
                    ddlMemberChange.DataBind();
                    ddlMemberChange.Items.Insert(0, new ListItem("أختر من القائمه", "NULL"));
                }
                if (Session["SystemRole"].ToString() == "1" && Request.QueryString["status"] == "update")
                {
                    divAddMember.Visible  = false;
                    divAddMembers.Visible = false;
                }
            }
        }