protected void btnAddChange_Click(object sender, EventArgs e) { List <int> membersList = new List <int>(); foreach (GridViewRow row in gvMembersOfCommittee.Rows) { int member = Convert.ToInt32(row.Cells[1].Text); membersList.Add(member); } string apiUrl2 = Utilities.BASE_URL + "/api/CommitteesMembers"; int memberId = WebApiConsume.GetUserId(Utilities.BASE_URL + "/api/Users", ddlMemberChange.SelectedItem.Text); if (!membersList.Contains(memberId)) { int?meetingId = WebApiConsume.GetMeetingId(Utilities.BASE_URL + "/api/Committees", Convert.ToInt32(ViewState["CommitteeId"]), ViewState["CreatedAt"].ToString()); CommitteesMember input = new CommitteesMember { CommitteeId = Convert.ToInt32(ViewState["CommitteeId"]), MemberId = memberId, CommitteeRole = 6, UpdatedAt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), CreatedAt = ViewState["CreatedAt"].ToString(), MeetingId = meetingId }; try { string apiUrlUser = Utilities.BASE_URL + "/api/Users"; string inputJson3 = (new JavaScriptSerializer()).Serialize(input); WebApiConsume.PostCommitteeMembersUpdate(Utilities.BASE_URL + "/api/CommitteesMembers", inputJson3); gvMembersOfCommittee.DataSource = WebApiConsume.ShowCommitteeMembers(Convert.ToInt32(ViewState["CommitteeId"])); gvMembersOfCommittee.DataBind(); User userFcm = WebApiConsume.GetUserById(Utilities.BASE_URL + "/api/Users", memberId); string apiUrlFcm = Utilities.BASE_URL + "/api/Fcm"; WebApiConsume.SendUserNotification(apiUrlFcm, Convert.ToInt32(ViewState["CommitteeId"]), txtCommitteeName.Text, userFcm.FCMToken); SMS.SendSms("انت عضو فى لجنة " + "\n" + txtCommitteeName.Text + " المشكلة بتاريخ " + "\n" + txtCommitteeDate.Text, userFcm.Phone); foreach (GridViewRow row in gvMembersOfCommittee.Rows) { string mobile = row.Cells[3].Text; SMS.SendSms("تم اضافة عضو للجنة " + "\n" + txtCommitteeName.Text + " المشكلة بتاريخ " + "\n" + txtCommitteeDate.Text, mobile); } // Utilities.SendMailToOnePerson(userFcm.UserEmailId, "انضمام للجنة", "تم اضافتك للجنة بنجاح"); ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "تم", "alert('تم اضافة العضو لللجنة بنجاح');", true); } catch (Exception ex) { string filePath = @Utilities.LogError_Path + "Error.txt"; using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("-----------------------------------------------------------------------------"); writer.WriteLine("Date : " + DateTime.Now.ToString()); writer.WriteLine(); while (ex != null) { writer.WriteLine(ex.GetType().FullName); writer.WriteLine("Message : " + ex.Message); writer.WriteLine("StackTrace : " + ex.StackTrace); ex = ex.InnerException; } } } //Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.success('تم ارسال الاشعارات بنجاح', 'تم')", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.error('هذا العضو موجود بالفعل داخل اللجنه', 'تحذير')", true); //ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "تحذير", "alert('هذا العضو موجود بالفعل داخل اللجنه');", true); } }
protected void btnAdd_Click(object sender, EventArgs e) { if ((ddlCommitteepresident.SelectedValue != "NULL" && ddlCommitteeSecrtary.SelectedValue != "NULL")) { selectedUsers.Add(Convert.ToInt32(ddlCommitteeSecrtary.SelectedItem.Value)); selectedUsers.Add(Convert.ToInt32(ddlCommitteepresident.SelectedItem.Value)); } else { // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('من فضلك قم باختيار رئيس لجنه وسكرتير لجنه ')", true); } if (selectedUsers.Count != 0) { if (ddlMemberSelect?.SelectedItem?.Value != "NULL") { if (selectedUsers.Contains(Convert.ToInt32(ddlMemberSelect?.SelectedItem?.Value))) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('هذا العضو موجود بالفعل ')", true); //Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.error('هذا العضو موجود بالفعل ', 'تحذير')", true); } else { List <int> membersList = new List <int>(); string apiUrl2 = Utilities.BASE_URL + "/api/CommitteesMembers"; int memberId = WebApiConsume.GetUserId(Utilities.BASE_URL + "/api/Users", ddlMemberSelect.SelectedItem.Text); membersList.Add(memberId); if (gvAddMember.Rows.Count != 0) { foreach (GridViewRow row in gvAddMember.Rows) { //membersList.Add(memberId); if (!userGrids.Any(x => x.رقم_العضو == memberId)) { userGrids.Add(WebApiConsume.ShowCommitteeMembersForNew(memberId)[0]); gvAddMember.Visible = true; gvAddMember.DataSource = userGrids.Distinct().ToList(); gvAddMember.DataBind(); selectedUsers.Add(Convert.ToInt32(ddlMemberSelect.SelectedItem.Value)); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('تم ادخال العضو للجنة بنجاح')", true); } } } else { userGrids.Add(WebApiConsume.ShowCommitteeMembersForNew(memberId)[0]); gvAddMember.Visible = true; gvAddMember.DataSource = userGrids; gvAddMember.DataBind(); selectedUsers.Add(Convert.ToInt32(ddlMemberSelect.SelectedItem.Value)); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('تم ادخال العضو للجنة بنجاح')", true); } if (!membersList.Contains(memberId)) { //CommitteesMember input = new CommitteesMember //{ // CommitteeId = Convert.ToInt32(ViewState["CommitteeId"]), // MemberId = memberId //}; //string apiUrlUser = Utilities.BASE_URL + "/api/Users"; //string inputJson3 = (new JavaScriptSerializer()).Serialize(input); //WebApiConsume.PostCommitteeMembersUpdate(Utilities.BASE_URL + "/api/CommitteesMembers", inputJson3); //Page.ClientScript.RegisterStartupScript(this.GetType(), "toastr_message", "toastr.success('تم ادخال هذا العضو بنجاح', 'تم')", true); } } } } }