public void TestSyncUp(string pDeliveryID = "", string pDrumCode = "", string pDeliveryDetailID = "") { var currentdate = StoredProcedure.GetCurrentDate(); var cmsService = new MobileService(); CMS_Delivery _Delivery = new CMS_Delivery(); var cri = new MobileCri(); cri.Delivery_ID = NumUtil.ParseInteger(pDeliveryID); var result = cmsService.GetCMSDelivery(cri); if (result.Code == ReturnCode.SUCCESS) { var deliverys = result.Object as List <CMS_Delivery>; if (deliverys != null && deliverys.Count() == 1) { _Delivery = deliverys.FirstOrDefault(); _Delivery.Delivery_ID = _Delivery.Delivery_ID; _Delivery.Delivery_Order_No = _Delivery.Delivery_Order_No; _Delivery.Completed = true; _Delivery.Update_By = "Test"; _Delivery.Update_On = currentdate; List <CMS_Delivery_Detail> _Details = new List <CMS_Delivery_Detail>(); CMS_Delivery_Detail _Detail = new CMS_Delivery_Detail(); _Detail.CMS_Delivery_Detail_ID = NumUtil.ParseInteger(pDeliveryDetailID);; _Detail.Delivery_ID = _Delivery.Delivery_ID; _Detail.Drum_Code = pDrumCode; _Detail.Update_By = "Test"; _Detail.Update_On = currentdate; _Detail.Date_Delivered = currentdate; _Details.Add(_Detail); _Delivery.CMS_Delivery_Detail = _Details; } } var result2 = cmsService.UpdateCMSDelivery(_Delivery); }
public JsonResult SyncUpDeliverysByRecord(CMSDeliveryWModels SyncUpData) { var currentdate = StoredProcedure.GetCurrentDate(); var cmsService = new MobileService(); Boolean IsPass = false; var _result = new wResult(); if (SyncUpData != null) { IsPass = false; CMS_Delivery _Delivery = new CMS_Delivery(); var cri = new MobileCri(); cri.Delivery_ID = SyncUpData.Delivery_ID; var result = cmsService.GetCMSDelivery(cri); if (result.Code == ReturnCode.SUCCESS) { var deliverys = result.Object as List <CMS_Delivery>; if (deliverys != null && deliverys.Count() == 1) { IsPass = true; _Delivery = deliverys.FirstOrDefault(); _Delivery.Delivery_ID = SyncUpData.Delivery_ID; _Delivery.Delivery_Order_No = SyncUpData.Delivery_Order_No; _Delivery.Completed = true; _Delivery.Update_By = SyncUpData.Update_By; _Delivery.Update_On = currentdate; List <CMS_Delivery_Detail> _Details = new List <CMS_Delivery_Detail>(); if (SyncUpData.DeliveryDetail != null) { foreach (var row2 in SyncUpData.DeliveryDetail) { CMS_Delivery_Detail _Detail = new CMS_Delivery_Detail(); _Detail.CMS_Delivery_Detail_ID = row2.CMS_Delivery_Detail_ID; _Detail.Delivery_ID = row2.Delivery_ID; _Detail.Drum_Code = row2.Drum_Code.Trim(); _Detail.Update_By = SyncUpData.Update_By; _Detail.Update_On = currentdate; _Detail.Date_Delivered = DateUtil.ToDate(row2.Date_Delivered); _Details.Add(_Detail); } _Delivery.CMS_Delivery_Detail = _Details; } } if (!IsPass) { _result.status = "1"; _result.message = "Error! can not found Delivery"; return(Json(new { Data = _result }, JsonRequestBehavior.AllowGet)); } var result2 = cmsService.UpdateCMSDelivery(_Delivery); if (result2.Code == ReturnCode.SUCCESS) { _result.status = "200"; _result.message = "Update successfully"; } else { _result.status = "1"; _result.message = "Error! can not update data"; } } } else { _result.status = "1"; _result.message = "Error! can not update data"; } return(Json(new { Data = _result }, JsonRequestBehavior.AllowGet)); }