예제 #1
0
 public void xoaCauHinhEmail(string id, string userId)
 {
     try
     {
         if (string.IsNullOrEmpty(id))
         {
             Clients.Caller.DeletedResult(false);
         }
         else
         {
             var dv = xlDonVi.Doc(id);
             dv.CauHinhEmail   = new CauHinhEmail();
             dv.IdNguoiCapNhat = userId;
             Clients.Caller.DeletedResult(xlDonVi.CapNhat(dv));
         }
     }
     catch (Exception)
     {
         Clients.Caller.DeletedResult(false);
     }
 }
예제 #2
0
 public ActionResult Them(FormCollection collection)
 {
     if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser))
     {
         NotifyModel thongBao = new NotifyModel();
         try
         {
             if (!string.IsNullOrEmpty(collection["save"].ToString()))
             {
                 var   user  = (NguoiDung)SessionManager.ReturnSessionObject(ConstantValues.SessionKeyCurrentUser);
                 DonVi donVi = new DonVi();
                 donVi.Ten       = collection["ten"].ToString();
                 donVi.DiaChi    = collection["diaChi"].ToString();
                 donVi.DienThoai = collection["dienThoai"].ToString();
                 donVi.Email     = collection["email"].ToString();
                 donVi.Fax       = collection["fax"].ToString();
                 //donVi.HoTenLanhDao = collection["hoTenLanhDao"].ToString();
                 //donVi.DienThoaiLanhDao = collection["dienThoaiLanhDao"].ToString();
                 //donVi.EmailLanhDao = collection["emailLanhDao"].ToString();
                 if (collection["donViTrucThuoc"].ToString() == "0")
                 {
                     donVi.IdDonViTrucThuoc = "0";
                     donVi.Cap = 1;
                 }
                 else
                 {
                     var dvTrucThuoc = xlDonVi.Doc(collection["donViTrucThuoc"].ToString());
                     donVi.IdDonViTrucThuoc = dvTrucThuoc.Id.ToString();
                     donVi.Cap = dvTrucThuoc.Cap + 1;
                 }
                 donVi.IdNguoiTao     = user.Id.ToString();
                 donVi.IdNguoiCapNhat = user.Id.ToString();
                 HttpPostedFileBase file = Request.Files["logoDonVi"];
                 if (file.FileName != null && file.FileName != "")
                 {
                     if (file.ContentLength > 0)
                     {
                         string savedFileName = "";
                         string savedFilePath = UploadFile.getFullFilePath(UploadFile.DonViDirectory, file.FileName, out savedFileName);
                         file.SaveAs(savedFilePath);
                         donVi.Logo = "/" + UploadFile.DonViDirectory + savedFileName;
                     }
                 }
                 if (xlDonVi.Ghi(donVi))
                 {
                     thongBao.TypeNotify = "alert-success";
                     thongBao.Message    = "Thêm thành công";
                 }
                 else
                 {
                     thongBao.TypeNotify = "alert-danger";
                     thongBao.Message    = "Thêm thất bại!";
                 }
             }
         }
         catch (Exception)
         {
             thongBao.TypeNotify = "alert-danger";
             thongBao.Message    = "Thêm thất bại!";
         }
         ViewBag.ThongBao = thongBao;
         var model = xlDonVi.DocDanhSachTuDonViCha(currentUser.IdDonVi, (bool)Session[ConstantValues.SessionKeyVaiTro]);
         return(View("Them", model));
     }
     if (Request.Url != null)
     {
         SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath);
     }
     return(RedirectToAction("Index", "Login"));
 }