private void OnDeleteGroup() { try { if (shtView.Rows.Count == 0) { return; } if (shtView.ActiveRowIndex < 0) { return; } // show confirm message MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new EVOFramework.Message(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo); if (dr != MessageDialogResult.Yes) { return; } //NZString TransID = new NZString(null, shtView.Cells[shtView.ActiveRowIndex, (int)eColView.ISSUE_NO].Value); //NZString RefNo = new NZString(null, shtView.Cells[shtView.ActiveRowIndex, (int)eColView.REF_NO].Value); NZString TransferNo = new NZString(null, shtView.Cells[shtView.ActiveRowIndex, (int)eColView.SLIP_NO].Value); IssueByOrderController ctl = new IssueByOrderController(); ctl.DeleteGroupTransaction(TransferNo); //ไล่ลบจากล่างขึ้นบน เพราะว่าไม่งั้นindex จะเลื่อนแล้วจะลบไม่ครบ for (int iRowIndex = shtView.RowCount - 1; iRowIndex >= 0; iRowIndex--) { if (TransferNo.NVL("").Equals(shtView.GetValue(iRowIndex, (int)eColView.SLIP_NO))) { shtView.Rows.Remove(iRowIndex, 1); } } //LoadData(); } catch (BusinessException err) { MessageDialog.ShowBusiness(this, err.Error.Message); err.Error.FocusOnControl(); } catch (ValidateException err) { MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message); err.ErrorResults[0].FocusOnControl(); } catch (Exception err) { MessageDialog.ShowBusiness(this, err.Message); } }
private void OnDelete() { try { if (shtView.Rows.Count == 0) { return; } if (shtView.ActiveRowIndex < 0) { return; } // show confirm message MessageDialogResult dr = MessageDialog.ShowConfirmation(this, new EVOFramework.Message(Messages.eConfirm.CFM9002.ToString()), MessageDialogButtons.YesNo); if (dr != MessageDialogResult.Yes) { return; } NZString TransID = new NZString(null, shtView.Cells[shtView.ActiveRowIndex, (int)eColView.ISSUE_NO].Value); NZString RefNo = new NZString(null, shtView.Cells[shtView.ActiveRowIndex, (int)eColView.REF_NO].Value); IssueByOrderController ctl = new IssueByOrderController(); ctl.DeleteTransaction(TransID, RefNo); shtView.RemoveRows(shtView.ActiveRowIndex, 1); //LoadData(); } catch (BusinessException err) { MessageDialog.ShowBusiness(this, err.Error.Message); err.Error.FocusOnControl(); } catch (ValidateException err) { MessageDialog.ShowBusiness(this, err.ErrorResults[0].Message); err.ErrorResults[0].FocusOnControl(); } catch (Exception err) { MessageDialog.ShowBusiness(this, err.Message); } }