示例#1
0
        private void grid_CommandCellClick(object sender, EventArgs e)
        {
            GridCommandCellElement gridCell = (GridCommandCellElement)sender;

            if (gridCell.ColumnInfo.Name.ToLower() == "btndelete")
            {
                if (DialogResult.Yes == RadMessageBox.Show("Are you sure you want to delete a Invoice ? ", "", MessageBoxButtons.YesNo, RadMessageIcon.Question))
                {
                    int             InvoiceId = grdLister.CurrentRow.Cells["Id"].Value.ToInt();
                    invoice_Payment obj       = General.GetObject <invoice_Payment>(c => c.invoiceId == InvoiceId);
                    if (obj == null)
                    {
                        RadGridView grid = gridCell.GridControl;
                        grid.CurrentRow.Delete();
                    }
                    else
                    {
                        ENUtils.ShowMessage("You Cannot Delete a Record Payment Exits..");
                    }
                }
            }
            else if (gridCell.ColumnInfo.Name.ToLower() == "btnedit")
            {
                ViewDetailForm();
            }
        }
示例#2
0
        void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
        {
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove)
            {
                objMaster = new InvoiceBO();

                try
                {
                    objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt());

                    int             InvoiceId = grdLister.CurrentRow.Cells["Id"].Value.ToInt();
                    invoice_Payment obj       = General.GetObject <invoice_Payment>(c => c.invoiceId == InvoiceId);
                    if (obj == null)
                    {
                        objMaster.Delete(objMaster.Current);
                    }
                    else
                    {
                        ENUtils.ShowMessage("You Can not delete a record..");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    if (objMaster.Errors.Count > 0)
                    {
                        ENUtils.ShowMessage(objMaster.ShowErrors());
                    }
                    else
                    {
                        ENUtils.ShowMessage(ex.Message);
                    }
                    e.Cancel = true;
                }
            }
        }