public JsonResult InsertOutgoing(string OutgoingFormJson, string OutgoingJson)
        {
            List <OutgoingEventModel> OutgoingList = null;

            OutgoingFormModel OutgoingForm = null;

            try
            {
                OutgoingList = JsonConvert.DeserializeObject <List <OutgoingEventModel> >(OutgoingJson);
                OutgoingForm = JsonConvert.DeserializeObject <OutgoingFormModel>(OutgoingFormJson);


                //檢查預約日期合不合法 , 若不合法 報錯!
                for (int i = 0; i < OutgoingList.Count; i++)
                {
                    CheckOutDatetime(OutgoingForm.SDate, OutgoingList[i].OutTime);//驗證時間是否
                    OutgoingList[i].OutTime = OutgoingList[i].OutTime.Replace(":", "");



                    CheckOutDatetime(OutgoingForm.SDate, OutgoingList[i].GoOutTime);//驗證時間是否
                    OutgoingList[i].GoOutTime = OutgoingList[i].GoOutTime.Replace(":", "");
                }


                OutgoingForm.OutMan         = LoginUserInfo.UserId;
                OutgoingForm.RecordMan      = LoginUserInfo.UserId;
                OutgoingForm.OutManCompany  = LoginUserInfo.Company;
                OutgoingForm.SDate          = OutgoingForm.SDate.Replace("-", "");
                OutgoingForm.OutDescription = "";



                if (ModelFactory.InsertOutgoing(OutgoingForm, OutgoingList, "A"))
                {
                    return(Json("1"));//代表已經處裡完
                }
                else
                {
                    return(Json("失敗!"));//失敗
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
            catch
            {
                return(Json("系統發生錯誤"));
            }
        }
Exemple #2
0
        public JsonResult InsertOutgoing(AppOutgoingModel AppOutgoing)
        {
            JsonresultModel ResultModel = new JsonresultModel();

            try
            {
                //檢查時間格式 是否正確
                CheckOutDatetime(AppOutgoing.SDate, AppOutgoing.STime);
                CheckOutDatetime(AppOutgoing.SDate, AppOutgoing.GoOutTime);



                OutgoingFormModel         OutgoingForm = new OutgoingFormModel();
                List <OutgoingEventModel> OutgoingList = new List <OutgoingEventModel>();


                //************************************
                OutgoingForm.OutMan         = AppOutgoing.OutMan;
                OutgoingForm.OutManCompany  = AppOutgoing.OutManCompany;
                OutgoingForm.RecordMan      = AppOutgoing.OutMan;//記錄人 等於 申請人
                OutgoingForm.SDate          = AppOutgoing.SDate;
                OutgoingForm.STime          = AppOutgoing.STime;
                OutgoingForm.OutDescription = "";



                OutgoingList.Add(new OutgoingEventModel()
                {
                    Location       = System.Web.HttpUtility.UrlDecode(AppOutgoing.Location),
                    CustomerName   = System.Web.HttpUtility.UrlDecode(AppOutgoing.CustomerName),
                    OutDescription = System.Web.HttpUtility.UrlDecode(AppOutgoing.OutDescription),
                    OutTime        = OutgoingForm.STime.Replace(":", ""),
                    GoOutTime      = AppOutgoing.GoOutTime.Replace(":", ""),
                    Equipment      = "1", //App
                });



                OutgoingForm.SDate = OutgoingForm.SDate.Replace("-", "");



                OutgoingModelFactory ModelFactory = new OutgoingModelFactory();


                if (ModelFactory.InsertOutgoing(OutgoingForm, OutgoingList, "A"))
                {
                    ResultModel.Result = "1";
                    return(Json(ResultModel, JsonRequestBehavior.AllowGet));//代表已經處裡完
                }
                else
                {
                    ResultModel.Result   = "0";
                    ResultModel.ErrorMsg = "新增外出失敗";
                    return(Json(ResultModel, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                ResultModel.Result   = "0";
                ResultModel.ErrorMsg = ex.Message;
                return(Json(ResultModel, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                ResultModel.Result   = "0";
                ResultModel.ErrorMsg = "系統發生錯誤";
                return(Json(ResultModel, JsonRequestBehavior.AllowGet));
            }
        }