Exemplo n.º 1
0
        public JsonResult UpdateInfo(string phone, string address, int marry, string ipphone, string noteContact)
        {
            try
            {
                NI10_Employee   employee     = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();
                PutDataResponse dataResponse = DataFunction.PutDataToService(serviceUrl, "Request/GetData", "",
                                                                             new List <string>()
                {
                    "@EmployeeCode", employee.EmployeeCode,
                    "@PhoneNumber", phone,
                    "@Address", address,
                    "@Marry", marry.ToString(),
                    "@IPphone", ipphone,
                    "@NoteContact", noteContact
                },
                                                                             "[dbo].[NI10_Employee_UpdateInfo]");

                if (dataResponse.StatusCode == "DONE")
                {
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("0", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json("0", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public JsonResult Follow(string TaskID, string IsFollow)
        {
            string          serviceUrl   = ConfigurationManager.AppSettings["ServiceUrl"];
            PutDataResponse updateStatus = DataFunction.PutDataToService(serviceUrl, "Request/GetData", "", new List <string>()
            {
                "@IsFollow", IsFollow, "@TaskID", TaskID
            }, "[dbo].[NI09_TaskList_Items_Update]");

            return(Json(updateStatus, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public string ChangeIsCheckCheckList(string TaskID, string CheckList)
        {
            string          serviceUrl    = ConfigurationManager.AppSettings["ServiceUrl"];
            PutDataResponse updateIsCheck = DataFunction.PutDataToService(serviceUrl, "Request/GetData", "", new List <string>()
            {
                "@TaskID", TaskID, "@StatusType", "", "@CheckList", CheckList, "@IsFollow", ""
            }, "[dbo].[NI09_TaskList_Items_Update]");

            return(JsonConvert.SerializeObject(updateIsCheck));
        }
Exemplo n.º 4
0
 public JsonResult UploadAvatar(HttpPostedFileBase fileImport = null)
 {
     try
     {
         NI10_Employee employee        = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();
         string        l_imageFileName = "";
         if (Request.Files != null)
         {
             foreach (string file in Request.Files)
             {
                 var uploadedFile = Request.Files[file];
                 if (uploadedFile.ContentLength > 0)
                 {
                     List <string> array = new List <string> {
                         "jpg", "JPG", "jpeg", "JPEG", "icon", "BMP", "bmp", "png", "PNG"
                     };
                     if (array.Contains(uploadedFile.ContentType.Split('/')[1].ToString()) == true)
                     {
                         Bitmap photoFile = StaticFunc.ResizeImage(uploadedFile.InputStream, 200, 200);
                         string img_duoi  = "." + uploadedFile.ContentType.Split('/')[1].ToString();
                         l_imageFileName = employee.EmployeeCode + DateTime.Now.ToString("yyyyMMddHHmmss") + img_duoi;
                         var         appData = Server.MapPath("/Files/Avatar/");
                         ImageFormat format  = StaticFunc.ConvertImageToByteArray(img_duoi);
                         photoFile.Save(Server.MapPath("/Files/Avatar/" + l_imageFileName), format);
                         if (l_imageFileName != "")
                         {
                             PutDataResponse dataResponse = DataFunction.PutDataToService(serviceUrl, "Request/GetData", "",
                                                                                          new List <string>()
                             {
                                 "@EmployeeCode", employee.EmployeeCode,
                                 "@Avatar", l_imageFileName
                             },
                                                                                          "[dbo].[NI10_Employee_UpdateAvatar]");
                             return(Json("/Files/Avatar/" + l_imageFileName, JsonRequestBehavior.AllowGet));
                         }
                     }
                     else
                     {
                         return(Json("0", JsonRequestBehavior.AllowGet)); // File không đúng định dạng ảnh. Vui lòng đổi ảnh khác
                     }
                 }
             }
         }
         return(Json("-1", JsonRequestBehavior.AllowGet)); // Xảy ra lỗi trong quá trình xử lý dữ liệu
     }
     catch (Exception ex)
     {
         return(Json("-1", JsonRequestBehavior.AllowGet)); // Xảy ra lỗi trong quá trình xử lý dữ liệu
     }
 }
Exemplo n.º 5
0
        public ActionResult AddUpdate(TasklistModel model, HttpPostedFileBase[] AttachFile)
        {
            WriteLogError(JsonConvert.SerializeObject(model));

            #region Upload File
            List <FileStringItem> fileStringItems = new List <FileStringItem>();
            if (model.FileString != null)
            {
                fileStringItems = JsonConvert.DeserializeObject <List <FileStringItem> >(model.FileString);
            }
            if (AttachFile != null && AttachFile.Count() > 0 && AttachFile[0] != null)
            {
                foreach (HttpPostedFileBase file in AttachFile)
                {
                    string         fileName = UploadFile(file, "/Files/TaskList");
                    FileStringItem fileItem = new FileStringItem()
                    {
                        FileID   = 0,
                        FileName = fileName,
                        FilePath = "/Files/TaskList/" + fileName
                    };
                    fileStringItems.Add(fileItem);
                }
            }
            #endregion

            List <CheckListItem>    checkListItems = JsonConvert.DeserializeObject <List <CheckListItem> >(model.CheckList);
            List <OptionStringItem> optionItems    = JsonConvert.DeserializeObject <List <OptionStringItem> >(model.OptionString);

            List <ObjectStringModel> ObjectString = new List <ObjectStringModel>();
            string            fileStr             = JsonConvert.SerializeObject(fileStringItems).ToString();
            ObjectStringModel abc = new ObjectStringModel
            {
                TaskID             = model.TaskID,
                ParentID           = model.ParentID,
                TaskTitle          = model.TaskTitle,
                ItemsDesc          = model.ItemsDesc,
                TaskType           = model.TaskType,
                StatusType         = model.StatusType,
                FileString         = fileStringItems,
                PriorityLevel      = model.PriorityLevel,
                CheckList          = checkListItems,
                OptionString       = optionItems,
                FromDateTime       = StaticFunc.ConvertFormDateTime(Request["FromDateTime"]).ToString("MM/dd/yyyy HH:mm"),
                ToDateTime         = StaticFunc.ConvertFormDateTime(Request["ToDateTime"]).ToString("MM/dd/yyyy HH:mm"),
                CompletedDatetime  = StaticFunc.ConvertFormDateTime(Request["CompletedDatetime"]).ToString("MM/dd/yyyy HH:mm"),
                FromDateRepeat     = StaticFunc.ConvertFormDate(Request["FromDateRepeat"]).ToString("MM/dd/yyyy HH:mm"),
                ToDateRepeat       = StaticFunc.ConvertFormDate(Request["ToDateRepeat"]).ToString("MM/dd/yyyy HH:mm"),
                IsRepeated         = model.IsRepeated,
                RepeatType         = model.RepeatType,
                InTimeString       = model.InTimeString,
                InWeekdayString    = model.InWeekdayString,
                InMonthdayString   = model.InMonthdayString,
                ObjectInChargeType = model.ObjectInChargeType,
                ObjectInCharge     = model.ObjectInCharge,
                IsActive           = "1",
                IsFollow           = Request["IsFollow"] == "1" ? "True" : "False",
                PersonsControl     = model.PersonsControl,
            };
            ObjectString.Add(abc);
            string test = JsonConvert.SerializeObject(ObjectString);
            WriteLogError(Request["FromDateTime"].ToString());
            WriteLogError(Request["ToDateTime"].ToString());
            WriteLogError(test);
            //return View();
            string          serviceUrl    = ConfigurationManager.AppSettings["ServiceUrl"];
            PutDataResponse AddUpdateTask = DataFunction.PutDataToService(serviceUrl, "Request/GetData", "", new List <string>()
            {
                "@SSID", "", "@ACTION", "SAVE", "@OBJECTID", "", "@USERID", SEmployee.EmployeeCode, "@TaskID", model.TaskID.ToString(), "@ObjectString", test
            }, "[dbo].[NI09_TaskList_Items_save]");
            if (AddUpdateTask.StatusCode == "DONE")
            {
                TempData["success"] = "Cập nhật dữ liệu thành công";
            }
            else
            {
                TempData["error"] = AddUpdateTask.StatusMess;
            }
            return(Redirect("/TaskList/Home/Detail?id=" + model.TaskID));
        }