Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString[SystemConstants.CategoryID] != null)
                {
                    int categoryID = Convert.ToInt32(Request.QueryString[SystemConstants.CategoryID]);


                    var dac = new AdministrationDAC();

                    AdministrationEDSC.CategoryDTRow dr = null;

                    if (categoryID != 0)
                    {
                        dr = dac.RetrieveCategory(categoryID);

                        CategoriesSetupUC1.Mode = SystemConstants.FormMode.Edit;
                    }
                    else
                    {
                        dr = new AdministrationEDSC.CategoryDTDataTable().NewCategoryDTRow();
                        CategoriesSetupUC1.Mode = SystemConstants.FormMode.New;
                    }

                    CategoriesSetupUC1.SetData(dr);
                }
                CheckSignIn();
            }
        }
Ejemplo n.º 2
0
        internal void SetData(AdministrationEDSC.CategoryDTRow dr)
        {
            SetDDL();
            hdnCategoryID.Value = dr.ID.ToString();

            if (!dr.IsNameNull())
            {
                txtAddEditName.Text = dr.Name;
                lblAddEditName.Text = dr.Name;
            }

            if (Mode == SystemConstants.FormMode.Edit)
            {
                AdministrationEDSC.CategoryDTDataTable dt = new AdministrationEDSC.CategoryDTDataTable();
                dt = new AdministrationDAC().RetrieveAllCategories();

                int counter  = 1;
                int parentID = 0;
                if (dr.Level2ParentID != 0)
                {
                    parentID = dr.Level2ParentID;
                }
                else if (dr.Level1ParentID != 0)
                {
                    parentID = dr.Level1ParentID;
                }

                bool find = false;
                foreach (AdministrationEDSC.CategoryDTRow brandDR in dt.Rows)
                {
                    if (brandDR.ID == parentID)
                    {
                        find = true;
                        break;
                    }
                    counter++;
                }
                if (find == false)
                {
                    counter = 0;
                }
                dropDownParent.SelectedIndex = counter;
                lblParent.Text = dropDownParent.SelectedItem.ToString();
            }
        }