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; }
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); }