Example #1
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();
     }
 }
Example #2
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();
         }
     }
 }