예제 #1
0
 protected void btnPostponed_Click(object sender, EventArgs e)
 {
     using (CultureDataContext db = new CultureDataContext())
     {
         Meeting c = db.Meetings.Where(x => x.Meeting_ID == int.Parse(ViewState["ID"].ToString())).FirstOrDefault();
         try
         {
             c.Meeting_StatusID = 4;
             db.SubmitChanges();
             FillControls();
             BindData();
             divDatePostponedUntil.Visible = true;
         }
         catch (Exception exception)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('حدث خطأ اثناء الحذف'); </script>", false);
         }
     }
 }
예제 #2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     using (CultureDataContext db = new CultureDataContext())
     {
         User u = db.Users.FirstOrDefault(x => x.User_ID == ClientDetails.DeSerializeClientDetails(Session["User"].ToString()).ID);
         if (u != null)
         {
             if (u.User_Password == EncryptString.Encrypt(txtOldPassword.Text))
             {
                 u.User_Password = EncryptString.Encrypt(txtNewPassword.Text);
                 db.SubmitChanges();
                 ScriptManager.RegisterStartupScript(this, GetType(), "alertUser", "$('body').removeClass('modal-open');alert('تم الحفظ بنجاح');", true);
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "alertUser", "alert('عفوا، كلمة السر القديمة غير صحيحة');$('#changePasswordModal').modal('show');", true);
             }
         }
     }
 }
예제 #3
0
 protected void lnkDeleteAttachment_Command(object sender, CommandEventArgs e)
 {
     using (CultureDataContext db = new CultureDataContext())
     {
         MemberAttachment c = db.MemberAttachments.Where(x => x.Attachment_ID == int.Parse(e.CommandArgument.ToString())).FirstOrDefault();
         db.MemberAttachments.DeleteOnSubmit(c);
         db.SubmitChanges();
         try
         {
             if (File.Exists(Server.MapPath(c.Attachment_File)))
             {
                 File.Delete(Server.MapPath(c.Attachment_File));
             }
         }
         catch (Exception exception)
         {
         }
         ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحذف بنجاح');$('#attachmentsModal').modal('show');$('#rewards').removeClass('active show');$('#rewardsPIll').removeClass('active show');$('#attachment').addClass('active show');$('#attachmentPIll').addClass('active show');</script>", false);
         BindAttachments();
     }
 }
예제 #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         using (CultureDataContext db = new CultureDataContext())
         {
             try
             {
                 if (ViewState["ID"] == null)
                 {
                     MeetingAgenda q = new MeetingAgenda()
                     {
                         Agenda_Item                 = txtName.Text,
                         Agenda_StatusID             = (int)StatusEnum.UnderApprove,
                         Agenda_MeetingID            = int.Parse(Request.QueryString["id"]),
                         Agenda_DiscussionPriorityID = int.Parse(ddlDiscussionPriority.SelectedValue),
                         Agenda_Notes                = txtNotes.Text
                     };
                     db.MeetingAgendas.InsertOnSubmit(q);
                 }
                 else
                 {
                     MeetingAgenda q = db.MeetingAgendas.FirstOrDefault(x => x.Agenda_ID.Equals(int.Parse(ViewState["ID"].ToString())));
                     q.Agenda_Item  = txtName.Text;
                     q.Agenda_Notes = txtNotes.Text;
                     q.Agenda_DiscussionPriorityID = int.Parse(ddlDiscussionPriority.SelectedValue);
                 }
                 db.SubmitChanges();
                 ClearControls();
                 BindData();
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحفظ بنجاح');$('#AgendaModal').modal('hide');$('.modal-backdrop').remove();</script>", false);
             }
             catch (Exception exception)
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('حدث خطا اثناء الحفظ');</script>", false);
                 //Logger.ErrorLog(exception);
             }
         }
     }
 }
예제 #5
0
 protected void btnSaveAttachment_Click(object sender, EventArgs e)
 {
     using (CultureDataContext db = new CultureDataContext())
     {
         if (fuAttach.HasFile)
         {
             string path = Server.MapPath("MembersAttachments/");
             while (File.Exists(path + fuAttach.FileName))
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('يوجد مرفق بنفس الاسم');</script>", false);
                 return;
             }
             fuAttach.SaveAs(path + fuAttach.FileName);
             MemberAttachment q = new MemberAttachment();
             q.Attachment_File     = "MembersAttachments/" + fuAttach.FileName;
             q.Attachment_Name     = txtFileName.Text;;
             q.Attachment_MemberID = int.Parse(Request.QueryString["id"]);
             db.MemberAttachments.InsertOnSubmit(q);
             db.SubmitChanges();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحفظ بنجاح');$('#rewards').removeClass('active show');$('#rewardsPIll').removeClass('active show');$('#attachment').addClass('active show');$('#attachmentPIll').addClass('active show');</script>", false);
             BindAttachments();
         }
     }
 }
예제 #6
0
 protected void btnSaveGoal_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         using (CultureDataContext db = new CultureDataContext())
         {
             try
             {
                 if (ViewState["GoalID"] == null)
                 {
                     CommitteeGoal q = new CommitteeGoal()
                     {
                         Goal_Text        = txtGoal.Text,
                         Goal_CommitteeID = int.Parse(ViewState["ID"].ToString())
                     };
                     db.CommitteeGoals.InsertOnSubmit(q);
                 }
                 else
                 {
                     CommitteeGoal q = db.CommitteeGoals.FirstOrDefault(x => x.Goal_ID.Equals(int.Parse(ViewState["GoalID"].ToString())));
                     q.Goal_Text = txtGoal.Text;
                 }
                 db.SubmitChanges();
                 txtGoal.Text        = string.Empty;
                 ViewState["GoalID"] = null;
                 BindGoals();
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحفظ بنجاح');$('#goalsModal').modal('show');</script>", false);
             }
             catch (Exception exception)
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('حدث خطا اثناء الحفظ');</script>", false);
                 //Logger.ErrorLog(exception);
             }
         }
     }
 }
예제 #7
0
    public void PrintNodesRecursive(TreeViewNode oParentNode, int group)
    {
        var x = oParentNode.Text;

        foreach (TreeViewNode SubNode in oParentNode.Nodes)
        {
            using (CultureDataContext db = new CultureDataContext())
            {
                foreach (TreeViewNode item in SubNode.Nodes)
                {
                    if (item.Checked)
                    {
                        if (item.Text == "عرض")
                        {
                            var            optionsByPage = db.SystemPageFunctions.FirstOrDefault(p => p.SystemPageFunction_PageID.Equals(Convert.ToInt32(SubNode.Name.Replace('p', ' ').Trim())) && p.SystemPageFunction_FunctionID == (int)FunctionsEnum.Show);
                            GroupPrivilege a             = new GroupPrivilege
                            {
                                GroupPrivilege_PageFunctionID = optionsByPage.SystemPageFunction_ID,
                                GroupPrivilege_GroupID        = group
                            };
                            db.GroupPrivileges.InsertOnSubmit(a);
                        }
                        else if (item.Text == "اضافة")
                        {
                            var            optionsByPage = db.SystemPageFunctions.FirstOrDefault(p => p.SystemPageFunction_PageID.Equals(Convert.ToInt32(SubNode.Name.Replace('p', ' ').Trim())) && p.SystemPageFunction_FunctionID == (int)FunctionsEnum.Add);
                            GroupPrivilege a             = new GroupPrivilege
                            {
                                GroupPrivilege_PageFunctionID = optionsByPage.SystemPageFunction_ID,
                                GroupPrivilege_GroupID        = group
                            };
                            db.GroupPrivileges.InsertOnSubmit(a);
                        }
                        else if (item.Text == "تعديل")
                        {
                            var            optionsByPage = db.SystemPageFunctions.FirstOrDefault(p => p.SystemPageFunction_PageID.Equals(Convert.ToInt32(SubNode.Name.Replace('p', ' ').Trim())) && p.SystemPageFunction_FunctionID == (int)FunctionsEnum.Edit);
                            GroupPrivilege a             = new GroupPrivilege
                            {
                                GroupPrivilege_PageFunctionID = optionsByPage.SystemPageFunction_ID,
                                GroupPrivilege_GroupID        = group
                            };
                            db.GroupPrivileges.InsertOnSubmit(a);
                        }
                        else if (item.Text == "حذف")
                        {
                            var            optionsByPage = db.SystemPageFunctions.FirstOrDefault(p => p.SystemPageFunction_PageID.Equals(Convert.ToInt32(SubNode.Name.Replace('p', ' ').Trim())) && p.SystemPageFunction_FunctionID == (int)FunctionsEnum.Delete);
                            GroupPrivilege a             = new GroupPrivilege
                            {
                                GroupPrivilege_PageFunctionID = optionsByPage.SystemPageFunction_ID,
                                GroupPrivilege_GroupID        = group
                            };
                            db.GroupPrivileges.InsertOnSubmit(a);
                        }
                        else if (item.Text == "فهرسة")
                        {
                            var            optionsByPage = db.SystemPageFunctions.FirstOrDefault(p => p.SystemPageFunction_PageID.Equals(Convert.ToInt32(SubNode.Name.Replace('p', ' ').Trim())) && p.SystemPageFunction_FunctionID == (int)FunctionsEnum.Index);
                            GroupPrivilege a             = new GroupPrivilege
                            {
                                GroupPrivilege_PageFunctionID = optionsByPage.SystemPageFunction_ID,
                                GroupPrivilege_GroupID        = group
                            };
                            db.GroupPrivileges.InsertOnSubmit(a);
                        }
                    }
                }

                db.SubmitChanges();
            }
        }
        ++z;
        if (z < tvPermissions.Nodes.Count)
        {
            TreeViewNode MainNode = tvPermissions.Nodes[z];
            PrintNodesRecursive(MainNode, group);
        }
    }
예제 #8
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         using (CultureDataContext db = new CultureDataContext())
         {
             try
             {
                 string avatar = string.Empty;
                 if (fuAvatar.HasFile)
                 {
                     string path = Server.MapPath("MembersAttachments/");
                     while (File.Exists(path + fuAvatar.FileName))
                     {
                         ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('يوجد مرفق بنفس الاسم');</script>", false);
                         return;
                     }
                     fuAvatar.SaveAs(path + fuAvatar.FileName);
                     avatar = "MembersAttachments/" + fuAvatar.FileName;
                 }
                 Member q = db.Members.FirstOrDefault(x => x.Member_ID.Equals(int.Parse(Request.QueryString["id"])));
                 q.Member_Name               = txtName.Text;
                 q.Member_Address            = txtAddress.Text;
                 q.Member_As                 = txtAs.Text;
                 q.Member_Email              = txtEmail.Text;
                 q.Member_MembershipStatusID = rdStatus1.Checked ? 1 : 2;
                 q.Member_Notes              = txtNotes.Text;
                 q.Member_RoleID             = rdRole1.Checked ? 1 : 2;
                 q.Member_TypeID             = rdMale.Checked ? int.Parse(rdMale.Value) : (rdFemale.Checked ? int.Parse(rdFemale.Value) : int.Parse(rdUnit.Value));
                 if (q.Users.Any())
                 {
                     User u = q.Users.FirstOrDefault();
                     u.User_FullName = txtName.Text;
                     u.User_Email    = txtEmail.Text;
                 }
                 var phone = q.MemberPhones;
                 db.MemberPhones.DeleteAllOnSubmit(phone);
                 SavePhone(db, q);
                 if (fuAvatar.HasFile)
                 {
                     q.Member_Avatar = avatar;
                 }
                 db.SubmitChanges();
                 var query = db.MemberNotifications.Where(x => x.MemberNotification_MemberID == int.Parse(Request.QueryString["id"]));
                 db.MemberNotifications.DeleteAllOnSubmit(query);
                 if (chkEmail.Checked)
                 {
                     AddNotification(1, int.Parse(Request.QueryString["id"]), db);
                 }
                 if (chkSMS.Checked)
                 {
                     AddNotification(2, int.Parse(Request.QueryString["id"]), db);
                 }
                 if (chkWhatsAppNotification.Checked)
                 {
                     AddNotification(3, int.Parse(Request.QueryString["id"]), db);
                 }
                 ClearControls();
                 BindData();
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحفظ بنجاح');$('#memberModal').modal('hide');$('.modal-backdrop').remove();</script>", false);
             }
             catch (Exception ex)
             {
                 string             sPath    = HttpContext.Current.Request.Url.AbsolutePath;
                 System.IO.FileInfo oInfo    = new System.IO.FileInfo(sPath);
                 string             PageName = oInfo.Name;
                 StackTrace         st       = new StackTrace(ex, true);
                 StackFrame         sf       = new StackFrame(0);
                 Common.InsertException(PageName, ex.Message, ex.StackTrace, int.Parse(sf.GetFileLineNumber().ToString()));
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('حدث خطا اثناء الحفظ');</script>", false);
                 //Logger.ErrorLog(exception);
             }
         }
     }
 }
예제 #9
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         using (CultureDataContext db = new CultureDataContext())
         {
             try
             {
                 string avatar = string.Empty;
                 if (fuAvatar.HasFile)
                 {
                     string path = Server.MapPath("MembersAttachments/");
                     while (File.Exists(path + fuAvatar.FileName))
                     {
                         ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('يوجد مرفق بنفس الاسم');</script>", false);
                         return;
                     }
                     fuAvatar.SaveAs(path + fuAvatar.FileName);
                     avatar = "MembersAttachments/" + fuAvatar.FileName;
                 }
                 if (ViewState["ID"] == null)
                 {
                     //int code = 1;
                     //Member c = db.Members.Where(x=>x.Member_CommitteeID== int.Parse(Request.QueryString["id"])).OrderByDescending(x => x.Member_ID).FirstOrDefault();
                     //if (c != null)
                     //    code = int.Parse(c.Member_Code.Split('-')[2]) + 1;
                     //Committee o = db.Committees.FirstOrDefault(x => x.Committee_ID == int.Parse(Request.QueryString["id"]));
                     int    code = 100;
                     Member c    = db.Members.Where(x => x.Member_CommitteeID == int.Parse(Request.QueryString["id"])).OrderByDescending(x => x.Member_ID).FirstOrDefault();
                     if (c != null)
                     {
                         code = int.Parse(c.Member_Code.Split('-')[1]) + 10;
                     }
                     Committee o = db.Committees.FirstOrDefault(x => x.Committee_ID == int.Parse(Request.QueryString["id"]));
                     Member    q = new Member()
                     {
                         Member_Name               = txtName.Text,
                         Member_Code               = o.Committee_Code + "-" + code.ToString().PadLeft(3, '0'),
                         Member_Address            = txtAddress.Text,
                         Member_As                 = txtAs.Text,
                         Member_CommitteeID        = int.Parse(Request.QueryString["id"]),
                         Member_Email              = txtEmail.Text,
                         Member_MembershipStatusID = rdStatus1.Checked ? 1 : 2,
                         Member_Notes              = txtNotes.Text,
                         Member_RoleID             = rdRole1.Checked ? 1 : 2,
                         Member_StatusID           = (int)StatusEnum.UnderApprove,
                         Member_Avatar             = fuAvatar.HasFile ? avatar : null,
                         Member_TypeID             = rdMale.Checked ? int.Parse(rdMale.Value) : (rdFemale.Checked ? int.Parse(rdFemale.Value) : int.Parse(rdUnit.Value))
                     };
                     db.Members.InsertOnSubmit(q);
                     SavePhone(db, q);
                     if (chkEmail.Checked)
                     {
                         AddNotification(1, q, db);
                     }
                     if (chkSMS.Checked)
                     {
                         AddNotification(2, q, db);
                     }
                     if (chkWhatsAppNotification.Checked)
                     {
                         AddNotification(3, q, db);
                     }
                 }
                 else
                 {
                     Member q = db.Members.FirstOrDefault(x => x.Member_ID.Equals(int.Parse(ViewState["ID"].ToString())));
                     q.Member_Name               = txtName.Text;
                     q.Member_Address            = txtAddress.Text;
                     q.Member_As                 = txtAs.Text;
                     q.Member_CommitteeID        = int.Parse(Request.QueryString["id"]);
                     q.Member_Email              = txtEmail.Text;
                     q.Member_MembershipStatusID = rdStatus1.Checked ? 1 : 2;
                     q.Member_Notes              = txtNotes.Text;
                     q.Member_RoleID             = rdRole1.Checked ? 1 : 2;
                     q.Member_StatusID           = (int)StatusEnum.UnderApprove;
                     q.Member_TypeID             = rdMale.Checked ? int.Parse(rdMale.Value) : (rdFemale.Checked ? int.Parse(rdFemale.Value) : int.Parse(rdUnit.Value));
                     if (fuAvatar.HasFile)
                     {
                         q.Member_Avatar = avatar;
                     }
                     var query = db.MemberNotifications.Where(x => x.MemberNotification_MemberID == int.Parse(ViewState["ID"].ToString()));
                     db.MemberNotifications.DeleteAllOnSubmit(query);
                     if (chkEmail.Checked)
                     {
                         AddNotification(1, q, db);
                     }
                     if (chkSMS.Checked)
                     {
                         AddNotification(2, q, db);
                     }
                     if (chkWhatsAppNotification.Checked)
                     {
                         AddNotification(3, q, db);
                     }
                     if (q.Users.Any())
                     {
                         User u = q.Users.FirstOrDefault();
                         u.User_FullName = txtName.Text;
                         u.User_Email    = txtEmail.Text;
                     }
                     var phone = q.MemberPhones;
                     db.MemberPhones.DeleteAllOnSubmit(phone);
                     SavePhone(db, q);
                 }
                 db.SubmitChanges();
                 ClearControls();
                 BindData();
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحفظ بنجاح');$('#memberModal').modal('hide');$('.modal-backdrop').remove();</script>", false);
             }
             catch (Exception exception)
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('حدث خطا اثناء الحفظ');</script>", false);
                 //Logger.ErrorLog(exception);
             }
         }
     }
 }
예제 #10
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         using (CultureDataContext db = new CultureDataContext())
         {
             try
             {
                 if (ViewState["ID"] == null)
                 {
                     int     code = 1;
                     Meeting c    = db.Meetings.Where(x => x.Meeting_CommitteeID == int.Parse(Request.QueryString["id"])).OrderByDescending(x => x.Meeting_ID).FirstOrDefault();
                     if (c != null)
                     {
                         code = int.Parse(c.Meeting_Code.Split('-')[2]) + 1;
                     }
                     Committee o = db.Committees.FirstOrDefault(x => x.Committee_ID == int.Parse(Request.QueryString["id"]));
                     Meeting   q = new Meeting()
                     {
                         Meeting_Date            = Convert.ToDateTime(txtDate.Value),
                         Meeting_Code            = o.Committee_Code.Split('-')[0] + code.ToString().PadLeft(3, '0'),
                         Meeting_Place           = txtPlace.Text,
                         Meeting_TimeFrom        = DateTime.Parse(txtTimeFrom.Value.Trim()).TimeOfDay,
                         Meeting_CommitteeID     = int.Parse(Request.QueryString["id"]),
                         Meeting_TimeTo          = DateTime.Parse(txtTimeTo.Value.Trim()).TimeOfDay,
                         Meeting_StatusID        = (int)StatusEnum.UnderApprove,
                         Meeting_Notes           = txtNotes.Text,
                         Meeting_TypeID          = rdType1.Checked ? 1 : 2,
                         Meeting_RewardNotMember = decimal.Parse(txtReward.Text),
                         Meeting_RewardMember    = decimal.Parse(txtRewardMember.Text)
                     };
                     db.Meetings.InsertOnSubmit(q);
                 }
                 else
                 {
                     Meeting q = db.Meetings.FirstOrDefault(x => x.Meeting_ID.Equals(int.Parse(ViewState["ID"].ToString())));
                     q.Meeting_Date            = Convert.ToDateTime(txtDate.Value);
                     q.Meeting_Place           = txtPlace.Text;
                     q.Meeting_TimeFrom        = DateTime.Parse(txtTimeFrom.Value.Trim()).TimeOfDay;
                     q.Meeting_CommitteeID     = int.Parse(Request.QueryString["id"]);
                     q.Meeting_TimeTo          = DateTime.Parse(txtTimeTo.Value.Trim()).TimeOfDay;
                     q.Meeting_Notes           = txtNotes.Text;
                     q.Meeting_TypeID          = rdType1.Checked ? 1 : 2;
                     q.Meeting_RewardNotMember = decimal.Parse(txtReward.Text);
                     q.Meeting_RewardMember    = decimal.Parse(txtRewardMember.Text);
                     q.Meeting_PostponedUntil  = Convert.ToDateTime(txtDatePostponedUntil.Text);
                 }
                 db.SubmitChanges();
                 ClearControls();
                 BindData();
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> $('body').removeClass('modal-open');alert('تم الحفظ بنجاح');$('#meetingModal').modal('hide');$('.modal-backdrop').remove();</script>", false);
             }
             catch (Exception ex)
             {
                 string             sPath    = HttpContext.Current.Request.Url.AbsolutePath;
                 System.IO.FileInfo oInfo    = new System.IO.FileInfo(sPath);
                 string             PageName = oInfo.Name;
                 StackTrace         st       = new StackTrace(ex, true);
                 StackFrame         sf       = new StackFrame(0);
                 Common.InsertException(PageName, ex.Message, ex.StackTrace, int.Parse(sf.GetFileLineNumber().ToString()));
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('حدث خطا اثناء الحفظ');</script>", false);
             }
         }
     }
 }
예제 #11
0
 protected void lnkSubmitEditUser_Click(object sender, EventArgs e)
 {
     Page.Validate("vgRegister");
     if (Page.IsValid)
     {
         using (CultureDataContext db = new CultureDataContext())
         {
             try
             {
                 int?member = ddlMember.SelectedValue != "-1" ? (int?)int.Parse(ddlMember.SelectedValue) : null;
                 if (ViewState["ID"] != null)
                 {
                     if (!db.Users.Any(x => x.User_ID != int.Parse(ViewState["ID"].ToString()) && x.User_MemberID == (member ?? 0)))
                     {
                         User u =
                             db.Users.FirstOrDefault(x => x.User_ID.Equals(int.Parse(ViewState["ID"].ToString())));
                         if (u != null)
                         {
                             u.User_MemberID    = member;
                             u.User_CommitteeID = ddlCommittee.SelectedValue != "-1" ? (int?)int.Parse(ddlCommittee.SelectedValue) : null;
                             u.User_FullName    = txtFullName.Text;
                             u.User_Email       = txtRegUsername.Text;
                             u.User_Mobile1     = txtMobile.Text;
                             if (member != null)
                             {
                                 Member m = db.Members.FirstOrDefault(x => x.Member_ID == member);;
                                 m.Member_Name  = txtFullName.Text;
                                 m.Member_Email = txtRegUsername.Text;
                             }
                             GroupUser gu = u.GroupUsers.FirstOrDefault();
                             if (gu != null && ddlGroup.SelectedValue != "-1")
                             {
                                 gu.GroupUser_GroupID = int.Parse(ddlGroup.SelectedValue);
                             }
                             else if (gu != null && ddlGroup.SelectedValue == "-1")
                             {
                                 db.GroupUsers.DeleteOnSubmit(gu);
                             }
                             else if (gu == null && ddlGroup.SelectedValue != "-1")
                             {
                                 GroupUser t = new GroupUser();
                                 t.GroupUser_UserID  = u.User_ID;
                                 t.GroupUser_GroupID = int.Parse(ddlGroup.SelectedValue);
                                 db.GroupUsers.InsertOnSubmit(t);
                             }
                         }
                     }
                     else
                     {
                         ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'>$('#groupAddModal').modal('show');alert('تم انشاء مستخدم لهذا العضو من قبل');</script>", false);
                         return;
                     }
                 }
                 else
                 {
                     if (!db.Users.Any(x => x.User_MemberID == (member ?? 0)))
                     {
                         User u = new User();
                         u.User_MemberID    = member;
                         u.User_CommitteeID = ddlCommittee.SelectedValue != "-1" ? (int?)int.Parse(ddlCommittee.SelectedValue) : null;
                         u.User_FullName    = txtFullName.Text.Trim();
                         u.User_Email       = txtRegUsername.Text.Trim();
                         u.User_Mobile1     = txtMobile.Text.Trim();
                         u.User_Password    = EncryptString.Encrypt("123456");
                         u.User_StatusID    = (int)StatusEnum.Approved;
                         db.Users.InsertOnSubmit(u);
                         if (member != null)
                         {
                             Member m = db.Members.FirstOrDefault(x => x.Member_ID == member);;
                             m.Member_Name  = txtFullName.Text;
                             m.Member_Email = txtRegUsername.Text;
                         }
                         if (ddlGroup.SelectedValue != "-1")
                         {
                             var g = db.Groups.FirstOrDefault(x => x.Group_ID.Equals(int.Parse(ddlGroup.SelectedValue)));
                             if (g != null)
                             {
                                 GroupUser t = new GroupUser();
                                 t.GroupUser_GroupID = g.Group_ID;
                                 t.User = u;
                                 db.GroupUsers.InsertOnSubmit(t);
                             }
                         }
                     }
                     else
                     {
                         ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'>$('#groupAddModal').modal('show');$('body').removeClass('modal-open');alert('تم انشاء مستخدم لهذا العضو من قبل');</script>", false);
                         return;
                     }
                 }
                 db.SubmitChanges();
                 ScriptManager.RegisterStartupScript(this, GetType(), "alertUserm", "$('#groupAddModal').modal('hide');$('.modal-backdrop').remove();$('body').removeClass('modal-open');alert('تم الحفظ بنجاح .');", true);
                 ClearUserControls();
                 BindDDL(true);
                 BindUsers();
             }
             catch (Exception ex)
             {
                 string             sPath    = HttpContext.Current.Request.Url.AbsolutePath;
                 System.IO.FileInfo oInfo    = new System.IO.FileInfo(sPath);
                 string             PageName = oInfo.Name;
                 StackTrace         st       = new StackTrace(ex, true);
                 StackFrame         sf       = new StackFrame(0);
                 Common.InsertException(PageName, ex.Message, ex.StackTrace, int.Parse(sf.GetFileLineNumber().ToString()));
                 ScriptManager.RegisterStartupScript(this, GetType(), "alertUser",
                                                     "alert('حدث خطأ اثناء التنفيذ');", true);
             }
         }
     }
     else
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'>$('#groupAddModal').modal('show');</script>", false);
     }
 }