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(); } }
private void gvLocationProduct_CellClick(object sender, Resco.Controls.SmartGrid.CellEventArgs e) { //click on delete column if (e.Cell.ColumnIndex == 2) { if (GlobalMessageBox.ShowQuestion("คุณต้องลบรายการ ใช่หรือไม่") == DialogResult.Yes) { var locationCode = gvLocationProduct.Cells[e.Cell.RowIndex, 0].Text; LocationCheckManager.DeleteByLocation(locationCode, GlobalContext.UserCode); this.BindGrid(); } } }
private void SaveData() { if (gvLocationProduct.DataSource != null) { try { Cursor.Current = Cursors.WaitCursor; LocationCheckManager.TransferToServer(); Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation("บันทึกข้อมูลไปยัง SAP สำเร็จ"); this.Close(); } catch (Exception ex) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError("บันทึกข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง " + ex.Message); BindGrid(); } } }
private void BindLocationAgenda() { this.bsAgenda.DataSource = LocationCheckManager.LocationCheckAgendaGetAllActive();; }
private void BindGrid() { var locationProduct = LocationCheckManager.GetByCreatedBy(GlobalContext.UserCode); gvLocationProduct.DataSource = locationProduct; }