protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        // weonly process commands with a datasource (our image buttons)
        if (e.CommandSource == null)
        {
            return;
        }
        string typeOfControl = e.CommandSource.GetType().ToString();

        if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton"))
        {
            int         id   = 0;
            ImageButton imgb = (ImageButton)e.CommandSource;
            if (imgb.ID != "New" && imgb.ID != "Exit")
            {
                id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]];
            }
            switch (imgb.ID)
            {
            case "Select":
                break;

            case "Edit":
                break;

            case "Delete":
                pay = (from p in ctx.GeneralPayments
                       where p.GeneralPaymentId == id
                       select p).FirstOrDefault <GeneralPayment>();
                CntAriCli.GeneralPaymentDelete(pay, ctx);
                RefreshGrid(true);
                break;
            }
        }
    }
    protected void UnloadData(GeneralPayment pay)
    {
        if (pay != null)
        {
            serviceNote = pay.ServiceNote;
            CntAriCli.GeneralPaymentDelete(pay, ctx);
        }
        Clinic        clinic      = CntAriCli.GetClinic(int.Parse(rdcbClinic.SelectedValue), ctx);
        PaymentMethod payMethod   = CntAriCli.GetPaymentMethod(int.Parse(rdcbPaymentMethod.SelectedValue), ctx);
        DateTime      payDate     = (DateTime)rddpGeneralPaymentDate.SelectedDate;
        Decimal       amount      = (decimal)txtAmount.Value;
        string        description = txtComments.Text;

        pay = CntAriCli.GeneralPaymentNew(clinic, serviceNote, amount, payMethod, payDate, description, ctx);
    }