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 == "servicesubcategory"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        // 
        if (Request.QueryString["ServiceSubCategoryId"] != null)
        {
            serviceSubCategoryId = Int32.Parse(Request.QueryString["ServiceSubCategoryId"]);
            serSub = CntAriCli.GetServiceSubcategory(serviceSubCategoryId, ctx);
            LoadData(serSub);
        }
        else
        {
            LoadServiceCategory(null);
        }
    }
 protected void UnloadData(ServiceSubCategory ser)
 {
     ser.Name = txtName.Text;
     ser.ServiceCategory = CntAriCli.GetServiceCategory(Int32.Parse(rdcbServiceCategory.SelectedValue), ctx);
 }
 protected bool CreateChange()
 {
     if (!DataOk())
         return false;
     if (serSub == null)
     {
         serSub = new ServiceSubCategory();
         UnloadData(serSub);
         ctx.Add(serSub);
     }
     else
     {
         serSub = CntAriCli.GetServiceSubcategory(serviceSubCategoryId, ctx);
         UnloadData(serSub);
     }
     ctx.SaveChanges();
     return true;
 }
 protected void LoadData(ServiceSubCategory serSub)
 {
     txtServiceSubCategoryId.Text = serSub.ServiceSubCategoryId.ToString();
     txtName.Text = serSub.Name;
     LoadServiceCategory(serSub.ServiceCategory);
 }
Example #5
0
 protected void LoadServiceSubCategory(ServiceSubCategory sscat)
 {
     // clear previous items 
     rdcServiceSubCategory.Items.Clear();
     foreach (ServiceSubCategory s in ctx.ServiceSubCategories)
     {
         rdcServiceSubCategory.Items.Add(new RadComboBoxItem(s.Name, s.ServiceSubCategoryId.ToString()));
     }
     if (sscat != null)
     {
         rdcServiceSubCategory.SelectedValue = sscat.ServiceSubCategoryId.ToString();
     }
     else
     {
         rdcServiceSubCategory.Items.Add(new RadComboBoxItem(" ", ""));
         rdcServiceSubCategory.SelectedValue = "";
     }
 }