public JsonResult SaveEvent(SelectListModelUploadSubmit model)
        {
            var result = _tblAccessUploadProcessService.SaveProcess(model.objE, model);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public MessageReport SaveProcess(Employee emp, SelectListModelUploadSubmit obj)
        {
            //
            var user = GetCurrentUser.GetUser();

            //
            var cardgroupid     = "";
            var userId          = user != null ? user.Id : "";
            var customerid      = "";
            var customergroupid = "";
            var controllerid    = obj.controllerid;
            var controllerids   = emp.ControllerIDs;
            var expiredate      = "2099/12/31";
            var desc            = obj.desc;

            //Lấy nhóm thẻ
            if (emp.CardNumber != "0")
            {
                var objCard = _tblCardService.GetCustomByCardNumber(emp.CardNumber);
                if (objCard != null)
                {
                    cardgroupid     = objCard.CardGroupID;
                    expiredate      = objCard.AccessExpireDate.ToString("yyyy/MM/dd");
                    customerid      = objCard.CustomerID;
                    customergroupid = objCard.CustomerGroupID;

                    if (obj.isusenewdate)
                    {
                        _tblCardService.UpdateCard(obj.actionV, userId, emp.CardNumber, emp.ExpireDate, true);
                    }
                }
            }

            if (emp.UserIDofFinger > 0)
            {
                //Lấy khách hàng
                var objCustomer = _tblCustomerService.GetByFingerID(emp.UserIDofFinger);
                if (objCustomer != null)
                {
                    if (obj.isusenewdate)
                    {
                        _tblCustomerService.UpdateCustomer(emp.UserIDofFinger.ToString(), emp.ExpireDate, true);
                    }
                }
            }

            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                var str = new StringBuilder();
                str.AppendLine("INSERT INTO tblAccessUploadProcess(Date, CardNumber, UserIDofFinger, Actions, CardGroupID, UserID, AccessLevelID, CustomerID, CustomerGroupID, SuccessControllerIDs, TotalControllerIDs, EventType, AccessDateExpire, Description) VALUES (");

                str.AppendLine("GETDATE()");
                str.AppendLine(string.Format(", '{0}'", emp.CardNumber));
                str.AppendLine(string.Format(", '{0}'", emp.UserIDofFinger));
                str.AppendLine(string.Format(", '{0}'", obj.actionV));
                str.AppendLine(string.Format(", '{0}'", cardgroupid));
                str.AppendLine(string.Format(", '{0}'", userId));
                str.AppendLine(string.Format(", '{0}'", emp.AccessLevelID));
                str.AppendLine(string.Format(", '{0}'", customerid));
                str.AppendLine(string.Format(", '{0}'", customergroupid));
                str.AppendLine(string.Format(", '{0}'", controllerid));
                str.AppendLine(string.Format(", '{0}'", controllerids));
                str.AppendLine(string.Format(", '{0}'", obj.eventtype));
                str.AppendLine(string.Format(", '{0}'", expiredate));
                str.AppendLine(string.Format(", N'{0}'", desc));

                str.AppendLine(")");

                var t = ExcuteSQL.Execute(str.ToString());

                result.isSuccess = t;
                result.Message   = "Thêm mới thành công";

                if (obj.isusenewdate && emp.CardNumber != "0")
                {
                    var str1 = new StringBuilder();

                    str1.AppendLine("INSERT INTO tblAccessUploadProcess(Date, CardNumber, UserIDofFinger, Actions, CardGroupID, UserID, AccessLevelID, CustomerID, CustomerGroupID, SuccessControllerIDs, TotalControllerIDs, EventType, AccessDateExpire, Description) VALUES (");

                    str1.AppendLine("GETDATE()");
                    str1.AppendLine(string.Format(", '{0}'", emp.CardNumber));
                    str1.AppendLine(string.Format(", '{0}'", emp.UserIDofFinger));
                    str1.AppendLine(string.Format(", '{0}'", "EXTEND"));
                    str1.AppendLine(string.Format(", '{0}'", cardgroupid));
                    str1.AppendLine(string.Format(", '{0}'", userId));
                    str1.AppendLine(string.Format(", '{0}'", emp.AccessLevelID));
                    str1.AppendLine(string.Format(", '{0}'", customerid));
                    str1.AppendLine(string.Format(", '{0}'", customergroupid));
                    str1.AppendLine(string.Format(", '{0}'", controllerid));
                    str1.AppendLine(string.Format(", '{0}'", controllerids));
                    str1.AppendLine(string.Format(", '{0}'", obj.eventtype));
                    str1.AppendLine(string.Format(", '{0}'", expiredate));
                    str1.AppendLine(string.Format(", N'{0}'", desc));

                    str1.AppendLine(")");

                    ExcuteSQL.Execute(str1.ToString());
                }
            }
            catch (Exception ex)
            {
                result.isSuccess = false;
                result.Message   = ex.Message;
            }

            return(result);
        }