Пример #1
0
        protected void gridviewAllocation_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
        {
            string[] args    = e.Parameters.Split('|');
            string   command = args[0];

            if (command.Equals("Delete"))
            {
                bool isSuccess = false;
                try
                {
                    if (args.Length < 2)
                    {
                        throw new Exception("Invalid parameters");
                    }
                    Guid       allocationId = Guid.Parse(args[1]);
                    Allocation allocation   = session.GetObjectByKey <Allocation>(allocationId);
                    if (allocation.VoucherAllocations != null && allocation.VoucherAllocations.Count > 0)
                    {
                        throw new Exception("The allocation has already reference to Voucher(s).");
                    }
                    allocation.Delete();
                    isSuccess = true;
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    if (isSuccess)
                    {
                        gridviewAllocation.JSProperties["cpEvent"] = "deleted";
                    }
                }
            }
        }