protected void Page_Init(object sender, EventArgs e)
    {
        ctx = new AriClinicContext("AriClinicContext");
        // security control, it must be a user logged
        if (Session["User"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "taxwt"
                            select p).FirstOrDefault <Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        //
        if (Request.QueryString["TaxWithholdingTypeId"] != null)
        {
            taxWithholdingTypeId = Int32.Parse(Request.QueryString["TaxWithholdingTypeId"]);
            taxwt = CntAriCli.GetTaxWithholdingType(taxWithholdingTypeId, ctx);
            LoadData(taxwt);
        }
    }
 protected bool CreateChange()
 {
     if (!DataOk())
     {
         return(false);
     }
     if (taxwt == null)
     {
         taxwt = new TaxWithholdingType();
         UnloadData(taxwt);
         ctx.Add(taxwt);
     }
     else
     {
         taxwt = CntAriCli.GetTaxWithholdingType(taxWithholdingTypeId, ctx);
         UnloadData(taxwt);
     }
     ctx.SaveChanges();
     return(true);
 }
Exemple #3
0
    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":
                TaxWithholdingType taxt = (from t in ctx.TaxWithholdingTypes
                                           where t.TaxWithholdingTypeId == id
                                           select t).FirstOrDefault <TaxWithholdingType>();
                ctx.Delete(taxt);
                ctx.SaveChanges();
                RefreshGrid();
                break;
            }
        }
    }
 protected void UnloadData(TaxWithholdingType taxt)
 {
     taxt.Name       = txtName.Text;
     taxt.Percentage = Decimal.Parse(txtPercentage.Text);
 }
 protected void LoadData(TaxWithholdingType taxt)
 {
     txtTaxWithholdingTypeId.Text = taxt.TaxWithholdingTypeId.ToString();
     txtName.Text       = taxt.Name;
     txtPercentage.Text = String.Format("{0:0.00}", taxt.Percentage);
 }