Esempio n. 1
0
 protected void btnSaveAttachment_Click(object sender, EventArgs e)
 {
     using (CultureDataContext db = new CultureDataContext())
     {
         if (fuAttach.HasFile)
         {
             string path = Server.MapPath("CommitteeAttachments/");
             while (File.Exists(path + fuAttach.FileName))
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('يوجد مرفق بنفس الاسم');</script>", false);
                 return;
             }
             fuAttach.SaveAs(path + fuAttach.FileName);
             CommitteeAttachment q = new CommitteeAttachment();
             q.Attachment_File        = "CommitteeAttachments/" + fuAttach.FileName;
             q.Attachment_Name        = txtFileName.Text;
             q.Attachment_CommitteeID = int.Parse(ViewState["ID"].ToString());
             db.CommitteeAttachments.InsertOnSubmit(q);
             db.SubmitChanges();
             txtFileName.Text = string.Empty;
             BindAttachments();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحفظ بنجاح');$('#attachmentsModal').modal('show');</script>", false);
         }
     }
 }
Esempio n. 2
0
 protected void lnkDeleteAttachment_Command(object sender, CommandEventArgs e)
 {
     using (CultureDataContext db = new CultureDataContext())
     {
         CommitteeAttachment c = db.CommitteeAttachments.Where(x => x.Attachment_ID == int.Parse(e.CommandArgument.ToString())).FirstOrDefault();
         try
         {
             db.CommitteeAttachments.DeleteOnSubmit(c);
             db.SubmitChanges();
             BindAttachments();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('تم الحفظ بنجاح');$('#attachmentsModal').modal('show');</script>", false);
         }
         catch (Exception exception)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", "<script language='javascript'> alert('حدث خطأ اثناء الحذف'); </script>", false);
         }
     }
 }