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; LocationCheckProductManager.Delete(locationCode); this.BindGrid(); } } }
private void Add() { try { Cursor.Current = Cursors.WaitCursor; var products = (List <ProductLocation>)bsProductLocation.DataSource; var warehouseCode = GlobalContext.WarehouseCode; var userID = GlobalContext.UserCode; var employeeCode = txtEmployeeCode.Text.Trim(); int displayOrder = 0; foreach (var item in products) { item.SalePriceSpecified = true; item.ShopPriceSpecified = true; item.DisplayOrder = displayOrder; item.DisplayOrderSpecified = true; item.CreateDateSpecified = true; item.OfficerID = employeeCode; item.WarehouseCode = warehouseCode; item.UserID = userID; item.LocationCode = txtLocationCode.Text; item.DocumentDate = this.dtChangePrice.Value; displayOrder++; } if (OfflineMode) { LocationCheckProductManager.Add(products); } else { ServiceHelper.MobileServices.ProductLocationAddHandHeldLocation(GlobalContext.BranchCode, products.ToArray()); } //clear controls this.ClearBindingControl(); //GlobalMessageBox.ShowInfomation("บันทึกข้อมูลเรียบร้อย"); } catch (Exception ex) { var message = "เกิดข้อผิดพลาดในการบันทึกข้อมูล ดังนี้ \n" + ex.Message; GlobalMessageBox.ShowError(message); } finally { Cursor.Current = Cursors.Default; } }
private void SaveData() { if (gvLocationProduct.DataSource != null) { try { Cursor.Current = Cursors.WaitCursor; LocationCheckProductManager.TransferToServer(); Cursor.Current = Cursors.Default; GlobalMessageBox.ShowInfomation("บันทึกข้อมูลไปยัง Server สำเร็จ"); this.Close(); } catch (Exception ex) { Cursor.Current = Cursors.Default; GlobalMessageBox.ShowError("บันทึกข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง " + ex.Message); BindGrid(); } } }
private void BindGrid() { var locationProduct = LocationCheckProductManager.GetByCreatedBy(GlobalContext.UserCode); gvLocationProduct.DataSource = locationProduct; }