private void Add() { if (this.ValidateForm()) { try { if (OfflineMode) { Cursor.Current = Cursors.WaitCursor; var agenda = (List <LocationCheckPeriodAgenda>)bsAgenda.DataSource; LocationCheckManager.Add(txtLocationCode.Text.Trim() , txtEmployeeCode.Text.Trim() , agenda); } else { var locationCheck = new LocationCheck(); locationCheck.Location = txtLocationCode.Text.Trim(); locationCheck.OfficerCode = txtEmployeeCode.Text.Trim(); locationCheck.CheckerCode = GlobalContext.UserCode; locationCheck.WarehouseCode = GlobalContext.WarehouseCode; locationCheck.PeriodId = LocationCheckManager.GetCurrentPeriodId(); locationCheck.PeriodIdSpecified = true; var locationCheckDetail = new List <LocationCheckDetail>(); var agenda = (List <LocationCheckPeriodAgenda>)bsAgenda.DataSource; foreach (var item in agenda) { locationCheckDetail.Add(new LocationCheckDetail { PeriodAgendaId = item.AgendaTemplateId, PeriodAgendaIdSpecified = true, AgendaValue = item.CheckedValue, IsChecked = item.Checked, IsCheckedSpecified = true, }); } ServiceHelper.MobileServices.LocationCheckAdd(GlobalContext.BranchCode, locationCheck, locationCheckDetail.ToArray()); } Cursor.Current = Cursors.Default; } catch (Exception ex) { Cursor.Current = Cursors.Default; var message = "เกิดข้อผิดพลาดในการบันทึกข้อมูล ดังนี้ \n" + ex.Message; GlobalMessageBox.ShowError(message); } //clear controls this.ClearBindingControl(); } }
public static void TransferToServer() { var userCode = GlobalContext.UserCode; var locationCheckProductTable = GetByCreatedBy(userCode); LocationCheck locationCheck = null; foreach (DataRow item in locationCheckProductTable.Rows) { locationCheck = new LocationCheck { Location = item["LocationCode"].ToString(), CheckerCode = item["CheckerCode"].ToString(), OfficerCode = item["OfficerCode"].ToString(), WarehouseCode = item["WarehouseCode"].ToString(), PeriodId = GetCurrentPeriodId(), PeriodIdSpecified = true }; var locationCheckTable = GetByLocation(locationCheck.Location, userCode); var locationCheckDetail = new List <LocationCheckDetail>(); foreach (DataRow row in locationCheckTable.Rows) { locationCheckDetail.Add(new LocationCheckDetail { PeriodAgendaId = Convert.ToInt32(row["AgendaId"]), PeriodAgendaIdSpecified = true, AgendaValue = row["AgendaValue"] as string, IsChecked = Convert.ToBoolean(row["IsChecked"]), IsCheckedSpecified = true }); } ServiceHelper.MobileServices.LocationCheckAdd(GlobalContext.BranchCode, locationCheck, locationCheckDetail.ToArray()); DeleteByLocation(locationCheck.Location, userCode); } }