Пример #1
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         JobsMainID = -1;
         Session.Remove("JobsMainID");
         Session.Remove("Position1");
         Session.Remove("Position2");
         GridEditableItem   item         = e.Item as GridEditableItem;
         RadAutoCompleteBox txtPosition1 = item.FindControl("txtPosition1") as RadAutoCompleteBox;
         RadAutoCompleteBox txtPosition2 = item.FindControl("txtPosition2") as RadAutoCompleteBox;
         RadDropDownList    ddlJobsMain  = item.FindControl("ddlJobsMain") as RadDropDownList;
         RadDropDownList    ddlPosition1 = item.FindControl("ddlPosition1") as RadDropDownList;
         RadDropDownList    ddlPosition2 = item.FindControl("ddlPosition2") as RadDropDownList;
         try {
             DistanceB          currDistance = e.Item.DataItem as DistanceB;
             JobsMainController cont         = new JobsMainController();
             ddlJobsMain.DataSource     = cont.GetJobsMain();
             ddlJobsMain.DataTextField  = "Name";
             ddlJobsMain.DataValueField = "ID";
             ddlJobsMain.DataBind();
             DistancesController dcont   = new DistancesController();
             List <string>       distPos = dcont.GetDistinctPositions();
             ddlPosition1.DataSource = distPos;
             ddlPosition1.DataBind();
             ddlPosition2.DataSource = distPos;
             ddlPosition2.DataBind();
             if (currDistance != null)
             {
                 txtPosition1.Entries.Add(new AutoCompleteBoxEntry(currDistance.Position1, currDistance.Position1));
                 txtPosition2.Entries.Add(new AutoCompleteBoxEntry(currDistance.Position2, currDistance.Position2));
                 ddlJobsMain.SelectedIndex = ddlJobsMain.FindItemByValue(currDistance.JobsMainID.ToString()).Index;
                 Session["JobsMainID"]     = currDistance.JobsMainID;
                 Session["Position1"]      = currDistance.Position1;
                 Session["Position2"]      = currDistance.Position2;
             }
             else
             {
                 ddlJobsMain.SelectedIndex = 0;
                 Session["JobsMainID"]     = ddlJobsMain.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
     if (e.Item is GridFilteringItem)
     {
         GridFilteringItem filterItem = (GridFilteringItem)e.Item;
         RadDropDownList   cflist     = (RadDropDownList)filterItem.FindControl("ddlJobsMainFilter");
         try {
             JobsMainController ccont = new JobsMainController();
             cflist.DataSource     = ccont.GetJobsMain();
             cflist.DataTextField  = "Name";
             cflist.DataValueField = "ID";
             cflist.DataBind();
             cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
         }
         catch (Exception) { }
     }
 }
Пример #2
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         placeID = -1;
         Session.Remove("PlaceID");
         countryID = -1;
         Session.Remove("CountryID");
         GridEditableItem item         = e.Item as GridEditableItem;
         RadDropDownList  ddlPlaces    = item.FindControl("ddlPlaces") as RadDropDownList;
         RadDropDownList  ddlCountries = item.FindControl("ddlCountries") as RadDropDownList;
         TextBox          txtNameGR    = (TextBox)item["NameGR"].Controls[0];
         txtNameGR.Width = Unit.Pixel(300);
         TextBox txtNameEN = (TextBox)item["NameEN"].Controls[0];
         txtNameEN.Width = Unit.Pixel(300);
         try {
             EventB currEvent          = e.Item.DataItem as EventB;
             CountriesController ccont = new CountriesController();
             PlacesController    cont  = new PlacesController();
             ddlCountries.DataSource     = ccont.GetCountries();
             ddlCountries.DataTextField  = "NameGR";
             ddlCountries.DataValueField = "ID";
             ddlCountries.DataBind();
             if (currEvent != null)
             {
                 ddlCountries.SelectedIndex = ddlCountries.FindItemByValue(currEvent.Place.CountryID.ToString()).Index;
                 Session["CountryID"]       = currEvent.Place.CountryID;
                 ddlPlaces.DataSource       = cont.GetPlaces().Where(k => k.CountryID == currEvent.Place.CountryID);
                 ddlPlaces.DataTextField    = "NameGR";
                 ddlPlaces.DataValueField   = "ID";
                 ddlPlaces.DataBind();
                 ddlPlaces.SelectedIndex = ddlPlaces.FindItemByValue(currEvent.PlaceID.ToString()).Index;
                 Session["PlaceID"]      = currEvent.PlaceID;
             }
             else
             {
                 ddlCountries.SelectedIndex = 0;
                 Session["CountryID"]       = ddlCountries.SelectedItem.Value;
                 ddlPlaces.DataSource       = cont.GetPlaces().Where(k => k.CountryID == int.Parse(ddlCountries.SelectedItem.Value));
                 ddlPlaces.DataTextField    = "NameGR";
                 ddlPlaces.DataValueField   = "ID";
                 ddlPlaces.DataBind();
                 ddlPlaces.SelectedIndex = 0;
                 Session["PlaceID"]      = ddlPlaces.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
 }
Пример #3
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         newID = -1;
         Session.Remove("CountryID");
         GridEditableItem item      = e.Item as GridEditableItem;
         TextBox          txtNameGR = (TextBox)item["NameGR"].Controls[0];
         txtNameGR.Width = Unit.Pixel(300);
         TextBox txtNameEN = (TextBox)item["NameEN"].Controls[0];
         txtNameEN.Width = Unit.Pixel(300);
         RadDropDownList list = item.FindControl("ddlCountries") as RadDropDownList;
         try {
             PlaceB currPlace         = e.Item.DataItem as PlaceB;
             CountriesController cont = new CountriesController();
             list.DataSource     = cont.GetCountries();
             list.DataTextField  = "NameGR";
             list.DataValueField = "ID";
             list.DataBind();
             if (currPlace != null)
             {
                 list.SelectedIndex   = list.FindItemByValue(currPlace.CountryID.ToString()).Index;
                 Session["CountryID"] = currPlace.CountryID;
             }
             else
             {
                 list.SelectedIndex   = 0;
                 Session["CountryID"] = list.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
     if (e.Item is GridFilteringItem)
     {
         GridFilteringItem filterItem = (GridFilteringItem)e.Item;
         RadDropDownList   cflist     = (RadDropDownList)filterItem.FindControl("ddlCountryFilter");
         try {
             CountriesController ccont = new CountriesController();
             cflist.DataSource     = ccont.GetCountries();
             cflist.DataTextField  = "NameGR";
             cflist.DataValueField = "ID";
             cflist.DataBind();
             cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
         }
         catch (Exception) { }
     }
 }
Пример #4
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item.OwnerTableView.Name == "Master")
     {
         if (e.Item is GridEditableItem && e.Item.IsInEditMode)
         {
             SalesType = -1;
             Session.Remove("SalesType");
             GridEditableItem item = e.Item as GridEditableItem;
             try {
                 SaleB           currSale = e.Item.DataItem as SaleB;
                 RadDropDownList list     = item.FindControl("ddlSaleType") as RadDropDownList;
                 list.Items.Clear();
                 list.Items.Add(new DropDownListItem("Κλιμακωτά", "1"));
                 list.Items.Add(new DropDownListItem("Σε όλο το ποσό", "2"));
                 list.DataBind();
                 if (currSale != null)
                 {
                     list.SelectedIndex   = list.FindItemByValue(currSale.Type.ToString()).Index;
                     Session["SalesType"] = currSale.Type;
                 }
                 else
                 {
                     list.SelectedIndex   = 0;
                     Session["SalesType"] = list.SelectedItem.Value;
                 }
             }
             catch (Exception) { }
         }
         else if (e.Item is GridDataItem)
         {
             GridDataItem item     = e.Item as GridDataItem;
             Label        lblST    = item.FindControl("lblSaleType") as Label;
             SaleB        currSale = e.Item.DataItem as SaleB;
             if (currSale.Type == 1)
             {
                 lblST.Text = "Κλιμακωτά";
             }
             else if (currSale.Type == 2)
             {
                 lblST.Text = "Σε όλο το ποσό";
             }
         }
     }
 }
Пример #5
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         newID = -1;
         Session.Remove("UserGroupID");
         GridEditableItem item = e.Item as GridEditableItem;
         RadDropDownList  list = item.FindControl("ddlUserGroups") as RadDropDownList;
         try {
             UserB currUser            = e.Item.DataItem as UserB;
             UserGroupsController cont = new UserGroupsController();
             list.DataSource     = cont.GetUserGroups();
             list.DataTextField  = "Name";
             list.DataValueField = "ID";
             list.DataBind();
             if (currUser != null)
             {
                 list.SelectedIndex     = list.FindItemByValue(currUser.UserGroupID.ToString()).Index;
                 Session["UserGroupID"] = currUser.UserGroupID;
             }
             else
             {
                 list.SelectedIndex     = 0;
                 Session["UserGroupID"] = list.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
     if (e.Item is GridFilteringItem)
     {
         GridFilteringItem filterItem = (GridFilteringItem)e.Item;
         RadDropDownList   flist      = (RadDropDownList)filterItem.FindControl("ddlUserGroupsFilter");
         try {
             UserGroupsController cont = new UserGroupsController();
             flist.DataSource     = cont.GetUserGroups();
             flist.DataTextField  = "Name";
             flist.DataValueField = "ID";
             flist.DataBind();
             flist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
         }
         catch (Exception) { }                                                                        //combo.Items.Add(new RadComboBoxItem("New"));
     }
 }
Пример #6
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         CustomerID = -1;
         Session.Remove("CustomerID");
         LineTypeID = -1;
         Session.Remove("LineTypeID");
         GridEditableItem item        = e.Item as GridEditableItem;
         RadDropDownList  ddlCustomer = item.FindControl("ddlCustomer") as RadDropDownList;
         RadDropDownList  ddlLineType = item.FindControl("ddlLineType") as RadDropDownList;
         try {
             CountryPricelistB   currPricelist = e.Item.DataItem as CountryPricelistB;
             CustomersController cont          = new CustomersController();
             ddlCustomer.DataSource     = cont.GetProviders();
             ddlCustomer.DataTextField  = "NameGR";
             ddlCustomer.DataValueField = "ID";
             ddlCustomer.DataBind();
             LineTypesController cont2 = new LineTypesController();
             ddlLineType.DataSource     = cont2.GetLineTypes();
             ddlLineType.DataTextField  = "Name";
             ddlLineType.DataValueField = "ID";
             ddlLineType.DataBind();
             if (currPricelist != null)
             {
                 ddlCustomer.SelectedIndex = ddlCustomer.FindItemByValue(currPricelist.CustomerID.ToString()).Index;
                 Session["CustomerID"]     = currPricelist.CustomerID;
                 ddlLineType.SelectedIndex = ddlLineType.FindItemByValue(currPricelist.LineTypeID.ToString()).Index;
                 Session["LineTypeID"]     = currPricelist.LineTypeID;
             }
             else
             {
                 ddlCustomer.SelectedIndex = 0;
                 Session["CustomerID"]     = ddlCustomer.SelectedItem.Value;
                 ddlLineType.SelectedIndex = 0;
                 Session["LineTypeID"]     = ddlLineType.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
 }
Пример #7
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item.OwnerTableView.Name == "Master")
     {
         if (e.Item is GridFilteringItem)
         {
             GridFilteringItem filterItem = (GridFilteringItem)e.Item;
             RadDropDownList   clist      = (RadDropDownList)filterItem.FindControl("ddlJobsMainFilter");
             try {
                 JobsMainController jcont = new JobsMainController();
                 clist.DataSource     = jcont.GetJobsMain();
                 clist.DataTextField  = "Name";
                 clist.DataValueField = "ID";
                 clist.DataBind();
                 clist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             }
             catch (Exception) { }
         }
         if (e.Item is GridEditableItem && e.Item.IsInEditMode)
         {
             SalesID = -1;
             Session.Remove("SalesID");
             JobsMainID = -1;
             Session.Remove("JobsMainID");
             JobTypesID = -1;
             Session.Remove("JobTypesID");
             GridEditableItem item        = e.Item as GridEditableItem;
             RadDropDownList  ddlSale     = item.FindControl("ddlSale") as RadDropDownList;
             RadDropDownList  ddlJobsMain = item.FindControl("ddlJobsMain") as RadDropDownList;
             RadDropDownList  ddlJobTypes = item.FindControl("ddlJobTypes") as RadDropDownList;
             try {
                 JobB            currJob = e.Item.DataItem as JobB;
                 SalesController cont    = new SalesController();
                 ddlSale.DataSource     = cont.GetSales();
                 ddlSale.DataTextField  = "Name";
                 ddlSale.DataValueField = "ID";
                 ddlSale.DataBind();
                 ddlSale.Items.Insert(0, new DropDownListItem("Χωρίς Έκπτωση", "0"));
                 JobsMainController cont2 = new JobsMainController();
                 ddlJobsMain.DataSource     = cont2.GetJobsMain();
                 ddlJobsMain.DataTextField  = "Name";
                 ddlJobsMain.DataValueField = "ID";
                 ddlJobsMain.DataBind();
                 JobTypesController cont3 = new JobTypesController();
                 ddlJobTypes.DataSource     = cont3.GetJobTypes();
                 ddlJobTypes.DataTextField  = "Name";
                 ddlJobTypes.DataValueField = "ID";
                 ddlJobTypes.DataBind();
                 if (currJob != null)
                 {
                     if (currJob.SalesID != null)
                     {
                         ddlSale.SelectedIndex = ddlSale.FindItemByValue(currJob.SalesID.ToString()).Index;
                         Session["SalesID"]    = currJob.SalesID;
                     }
                     else
                     {
                         ddlSale.SelectedIndex = 0;
                         Session["SalesID"]    = ddlSale.SelectedItem.Value;
                     }
                     ddlJobsMain.SelectedIndex = ddlJobsMain.FindItemByValue(currJob.JobsMainID.ToString()).Index;
                     Session["JobsMainID"]     = currJob.JobsMainID;
                     ddlJobTypes.SelectedIndex = ddlJobTypes.FindItemByValue(currJob.JobTypesID.ToString()).Index;
                     Session["JobTypesID"]     = currJob.JobTypesID;
                 }
                 else
                 {
                     ddlSale.SelectedIndex     = 0;
                     Session["SalesID"]        = ddlSale.SelectedItem.Value;
                     ddlJobsMain.SelectedIndex = 0;
                     Session["JobsMainID"]     = ddlJobsMain.SelectedItem.Value;
                     ddlJobTypes.SelectedIndex = 0;
                     Session["JobTypesID"]     = ddlJobTypes.SelectedItem.Value;
                 }
             }
             catch (Exception) { }
         }
         else if (e.Item is GridDataItem)
         {
             GridDataItem item    = e.Item as GridDataItem;
             Label        lblST   = item.FindControl("lblSale") as Label;
             JobB         currJob = e.Item.DataItem as JobB;
             if (currJob.SalesID == null)
             {
                 lblST.Text = "Χωρίς Έκπτωση";
             }
             else
             {
                 lblST.Text = currJob.Sale.Name;
             }
         }
     }
 }
Пример #8
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         countryID = -1;
         Session.Remove("CountryID");
         customerTypeID = -1;
         Session.Remove("CustomerTypeID");
         languageID = -1;
         Session.Remove("LanguageID");
         userID = -1;
         Session.Remove("UserID");
         GridEditableItem item             = e.Item as GridEditableItem;
         RadDropDownList  ddlCountries     = item.FindControl("ddlCountries") as RadDropDownList;
         RadDropDownList  ddlCustomerTypes = item.FindControl("ddlCustomerTypes") as RadDropDownList;
         RadDropDownList  ddlLanguages     = item.FindControl("ddlLanguages") as RadDropDownList;
         RadDropDownList  ddlUsers         = item.FindControl("ddlUsers") as RadDropDownList;
         try {
             CustomerB           currCustomer  = e.Item.DataItem as CustomerB;
             CountriesController countriesCont = new CountriesController();
             ddlCountries.DataSource     = countriesCont.GetCountries();
             ddlCountries.DataTextField  = "NameGR";
             ddlCountries.DataValueField = "ID";
             ddlCountries.DataBind();
             if (currCustomer != null)
             {
                 ddlCountries.SelectedIndex = ddlCountries.FindItemByValue(currCustomer.CountryID.ToString()).Index;
                 Session["CountryID"]       = currCustomer.CountryID;
             }
             else
             {
                 ddlCountries.SelectedIndex = ddlCountries.FindItemByValue("1").Index;;
                 Session["CountryID"]       = ddlCountries.SelectedItem.Value;
             }
             CustomerTypesController customerTypesCont = new CustomerTypesController();
             ddlCustomerTypes.DataSource     = customerTypesCont.GetCustomerTypes();
             ddlCustomerTypes.DataTextField  = "NameGR";
             ddlCustomerTypes.DataValueField = "ID";
             ddlCustomerTypes.DataBind();
             if (currCustomer != null)
             {
                 ddlCustomerTypes.SelectedIndex = ddlCustomerTypes.FindItemByValue(currCustomer.CustomerTypeID.ToString()).Index;
                 Session["CustomerTypeID"]      = currCustomer.CustomerTypeID;
             }
             else
             {
                 ddlCustomerTypes.SelectedIndex = 0;
                 Session["CustomerTypeID"]      = ddlCustomerTypes.SelectedItem.Value;
             }
             LanguagesController languagesCont = new LanguagesController();
             ddlLanguages.DataSource     = languagesCont.GetLanguages();
             ddlLanguages.DataTextField  = "Name";
             ddlLanguages.DataValueField = "ID";
             ddlLanguages.DataBind();
             if (currCustomer != null)
             {
                 ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue(currCustomer.LanguageID.ToString()).Index;
                 Session["LanguageID"]      = currCustomer.LanguageID;
             }
             else
             {
                 ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue("1").Index;
                 Session["LanguageID"]      = ddlLanguages.SelectedItem.Value;
             }
             UsersController usersCont = new UsersController();
             ddlUsers.DataSource     = usersCont.GetUsers();
             ddlUsers.DataTextField  = "NameGR";
             ddlUsers.DataValueField = "ID";
             ddlUsers.DataBind();
             if (currCustomer != null)
             {
                 ddlUsers.SelectedIndex = ddlUsers.FindItemByValue(currCustomer.UserID.ToString()).Index;
                 Session["UserID"]      = currCustomer.UserID;
             }
             else
             {
                 ddlUsers.SelectedIndex = 0;
                 Session["UserID"]      = ddlUsers.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
     if (e.Item is GridFilteringItem)
     {
         GridFilteringItem filterItem = (GridFilteringItem)e.Item;
         RadDropDownList   cflist     = (RadDropDownList)filterItem.FindControl("ddlCountryFilter");
         RadDropDownList   ctflist    = (RadDropDownList)filterItem.FindControl("ddlCustomerTypeFilter");
         RadDropDownList   lflist     = (RadDropDownList)filterItem.FindControl("ddlLanguageFilter");
         RadDropDownList   uflist     = (RadDropDownList)filterItem.FindControl("ddlUserFilter");
         try {
             CountriesController ccont = new CountriesController();
             cflist.DataSource     = ccont.GetCountries();
             cflist.DataTextField  = "NameGR";
             cflist.DataValueField = "ID";
             cflist.DataBind();
             cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             CustomerTypesController ctcont = new CustomerTypesController();
             ctflist.DataSource     = ctcont.GetCustomerTypes();
             ctflist.DataTextField  = "NameGR";
             ctflist.DataValueField = "ID";
             ctflist.DataBind();
             ctflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             LanguagesController lcont = new LanguagesController();
             lflist.DataSource     = lcont.GetLanguages();
             lflist.DataTextField  = "Name";
             lflist.DataValueField = "ID";
             lflist.DataBind();
             lflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             UsersController ucont = new UsersController();
             uflist.DataSource     = ucont.GetUsers();
             uflist.DataTextField  = "NameGR";
             uflist.DataValueField = "ID";
             uflist.DataBind();
             uflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
         }
         catch (Exception) { }
     }
 }
Пример #9
0
    // Set the controls by the value of the parameters
    private void SetControlObjectByValue(Control aControl, string aValue)
    {
        string _type = aControl.GetType().Name;

        if (_type == "RadTextBox")
        {
            RadTextBox _box = (RadTextBox)aControl;
            _box.Text = aValue;
        }
        else if (_type == "RadDropDownList")
        {
            RadDropDownList  _list = (RadDropDownList)aControl;
            DropDownListItem _item = _list.FindItemByValue(aValue);
            int _selectedIndex     = 0;
            if (_item != null)
            {
                _selectedIndex = _item.Index;
            }
            _list.SelectedIndex = _selectedIndex;
        }
        else if (_type == "RadNumericTextBox")
        {
            RadNumericTextBox _numeric = (RadNumericTextBox)aControl;
            _numeric.Value = Convert.ToDouble(aValue);
        }
        else if (_type == "RadSearchBox")
        {
            RadSearchBox _search = (RadSearchBox)aControl;
            if (aValue.Contains('^'))
            {
                string[] _splitForContext = aValue.Split('^');
                _search.Text = _splitForContext[0].Trim();
                int _selectedCtx = Convert.ToInt32(_splitForContext[1].Trim());
                if (_selectedCtx != -1)
                {
                    _search.SearchContext.Items[_selectedCtx].Selected = true;
                }
            }
            else
            {
                _search.Text = aValue;
            }
        }
        else if (_type == "RadComboBox")
        {
            RadComboBox _combo = (RadComboBox)aControl;
            if (_combo.CheckBoxes)
            {
                for (int i = 0; i < _combo.Items.Count; i++)
                {
                    _combo.Items[i].Checked = aValue[i] == '1';
                }
            }
            else
            {
                RadComboBoxItem _item = _combo.FindItemByValue(aValue);
                if (_item != null)
                {
                    _item.Selected = true;
                }
                else
                {
                    _combo.Text = aValue;
                }
            }
        }
        else if (_type == "RadButton")
        {
            RadButton _button = (RadButton)aControl;

            // TODO: Set all checks here
            if (_button.ToggleType == ButtonToggleType.CustomToggle)
            {
                _button.SelectedToggleStateIndex = Convert.ToInt32(aValue);
            }

            // For everything else
            else
            {
                _button.Checked = aValue == "1";
            }
        }
        else if (_type == "RadDatePicker")
        {
            RadDatePicker _date = (RadDatePicker)aControl;
            _date.SelectedDate = DateTime.Parse(aValue);
        }
        else if (_type == "RadTabStrip")
        {
            RadTabStrip _tabstrip = (RadTabStrip)aControl;
            int         _index    = Convert.ToInt32(aValue);
            _tabstrip.SelectedIndex           = _index;
            _tabstrip.MultiPage.SelectedIndex = _index;
        }
    }
 protected void gridMain_ItemCreated(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
     {
         GridEditableItem item = e.Item as GridEditableItem;
         var ID = (int)item.GetDataKeyValue("ID");
         using (var dbContext = new OTERTConnStr()) {
             var docRep = dbContext.DocumentReplacemets.Where(n => n.ID == ID).FirstOrDefault();
             if (docRep != null)
             {
                 Panel pnlText        = (Panel)item.FindControl("pnlText");
                 Panel pnlImage       = (Panel)item.FindControl("pnlImage");
                 Panel pnlTextWidth   = (Panel)item.FindControl("pnlTextWidth");
                 Panel pnlImageWidth  = (Panel)item.FindControl("pnlImageWidth");
                 Panel pnlTextHeight  = (Panel)item.FindControl("pnlTextHeight");
                 Panel pnlImageHeight = (Panel)item.FindControl("pnlImageHeight");
                 Panel pnlPageNo      = (Panel)item.FindControl("pnlPageNo");
                 Panel pnlDate        = (Panel)item.FindControl("pnlDate");
                 if (docRep.Type == "Image" || docRep.Type == "Cell_Image")
                 {
                     pnlText.Visible                    = false;
                     pnlTextWidth.Visible               = false;
                     pnlTextHeight.Visible              = false;
                     pnlImage.Visible                   = true;
                     pnlImageWidth.Visible              = true;
                     pnlImageHeight.Visible             = true;
                     pnlPageNo.Visible                  = false;
                     pnlDate.Visible                    = false;
                     item["ImageWidth"].Parent.Visible  = true;
                     item["ImageHeight"].Parent.Visible = true;
                 }
                 else if (docRep.Type == "PageNo" || docRep.Type == "Cell_PageNo")
                 {
                     pnlText.Visible                    = false;
                     pnlTextWidth.Visible               = false;
                     pnlTextHeight.Visible              = false;
                     pnlImage.Visible                   = false;
                     pnlImageWidth.Visible              = false;
                     pnlImageHeight.Visible             = false;
                     pnlPageNo.Visible                  = true;
                     pnlDate.Visible                    = false;
                     item["ImageWidth"].Parent.Visible  = false;
                     item["ImageHeight"].Parent.Visible = false;
                     RadDropDownList ddlText = item.FindControl("ddlText") as RadDropDownList;
                     ddlText.SelectedIndex = ddlText.FindItemByValue(docRep.Text).Index;
                 }
                 else if (docRep.Type == "Date" || docRep.Type == "Cell_Date")
                 {
                     pnlText.Visible                    = false;
                     pnlTextWidth.Visible               = false;
                     pnlTextHeight.Visible              = false;
                     pnlImage.Visible                   = false;
                     pnlImageWidth.Visible              = false;
                     pnlImageHeight.Visible             = false;
                     pnlPageNo.Visible                  = false;
                     pnlDate.Visible                    = true;
                     item["ImageWidth"].Parent.Visible  = false;
                     item["ImageHeight"].Parent.Visible = false;
                     RadDropDownList ddlDate = item.FindControl("ddlDate") as RadDropDownList;
                     ddlDate.SelectedIndex = ddlDate.FindItemByValue(docRep.Text).Index;
                 }
                 else
                 {
                     pnlText.Visible                    = true;
                     pnlTextWidth.Visible               = true;
                     pnlTextHeight.Visible              = true;
                     pnlImage.Visible                   = false;
                     pnlImageWidth.Visible              = false;
                     pnlImageHeight.Visible             = false;
                     pnlPageNo.Visible                  = false;
                     pnlDate.Visible                    = false;
                     item["ImageWidth"].Parent.Visible  = false;
                     item["ImageHeight"].Parent.Visible = false;
                 }
             }
         }
     }
 }
    // Notes & Destination Project Picker
    protected void BuildNotesTooltip(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs args)
    {
        String TempLeadID = args.Value;

        // Find destination note box
        RadTextBox rtb_dest_note = new RadTextBox();

        foreach (GridDataItem item in rg_leads.Items)
        {
            String ThisRowTempLeadID = item["TempLeadID"].Text;
            if (TempLeadID == ThisRowTempLeadID)
            {
                rtb_dest_note = (RadTextBox)item["Notes"].FindControl("tb_notes");
                break;
            }
        }

        Panel p = new Panel();

        Label lbl_notes_title = new Label();

        lbl_notes_title.CssClass = "MediumTitle";
        lbl_notes_title.Text     = "Lead Notes and Actions";
        lbl_notes_title.Attributes.Add("style", "font-weight:500; margin-top:0px; margin-bottom:6px; position:relative; top:-3px;");

        RadTextBox rtb_note = new RadTextBox();

        rtb_note.ID       = "rtb_note_" + TempLeadID;
        rtb_note.Height   = 140;
        rtb_note.Width    = 590;
        rtb_note.TextMode = InputMode.MultiLine;
        rtb_note.Text     = rtb_dest_note.Text;

        RadButton rb_clear_note = new RadButton();

        rb_clear_note.ID = "rb_clear_note_" + TempLeadID;
        rb_clear_note.Attributes.Add("style", "float:left; margin:4px 4px 4px 1px;");
        rb_clear_note.Skin            = "Bootstrap";
        rb_clear_note.Text            = "Clear Notes";
        rb_clear_note.Click          += rb_clear_note_Click;
        rb_clear_note.CommandArgument = TempLeadID;

        RadButton rb_clear_all_notes = new RadButton();

        rb_clear_all_notes.ID = "rb_clear_all_notes_" + TempLeadID;
        rb_clear_all_notes.Attributes.Add("style", "float:left; margin:4px 0px 4px 1px;");
        rb_clear_all_notes.Skin            = "Bootstrap";
        rb_clear_all_notes.Text            = "Clear All Notes";
        rb_clear_all_notes.Click          += rb_clear_note_Click;
        rb_clear_all_notes.CommandArgument = TempLeadID;

        RadButton rb_add_note = new RadButton();

        rb_add_note.ID = "rb_add_note_" + TempLeadID;
        rb_add_note.Attributes.Add("style", "float:right; margin:4px 1px 4px 4px;");
        rb_add_note.Skin            = "Bootstrap";
        rb_add_note.Text            = "Save Note/Next Action";
        rb_add_note.Click          += rb_add_note_Click;
        rb_add_note.CommandArgument = TempLeadID;

        RadButton rb_add_note_to_all = new RadButton();

        rb_add_note_to_all.ID = "rb_add_note_to_all_" + TempLeadID;
        rb_add_note_to_all.Attributes.Add("style", "float:right; margin:4px 1px 4px 4px;");
        rb_add_note_to_all.Skin            = "Bootstrap";
        rb_add_note_to_all.Text            = "Save Note/Next Action to All";
        rb_add_note_to_all.Click          += rb_add_note_Click;
        rb_add_note_to_all.CommandArgument = TempLeadID;

        // Next Action stuff
        Panel p_next_action = new Panel();

        p_next_action.CssClass = "NextActionContainer";
        p_next_action.Attributes.Add("style", "margin-top:50px; padding-top:10px;");

        Label lbl_next_action = new Label();

        lbl_next_action.Text     = "Next Action:";
        lbl_next_action.CssClass = "SmallTitle";
        lbl_next_action.Attributes.Add("style", "float:left; padding:5px 5px 0px 5px;");

        RadDropDownList dd_next_action_type = new RadDropDownList(); // needs binding

        dd_next_action_type.ID     = "dd_next_action_type_" + TempLeadID;
        dd_next_action_type.Width  = 100;
        dd_next_action_type.Height = 30;
        dd_next_action_type.Attributes.Add("style", "margin-right:5px; position:relative; top:-2px;");
        dd_next_action_type.ZIndex          = 99999999;
        dd_next_action_type.ExpandDirection = DropDownListExpandDirection.Up;
        dd_next_action_type.Skin            = "Bootstrap";

        String qry = "SELECT * FROM dbl_action_type ORDER BY ActionType";

        dd_next_action_type.DataSource     = SQL.SelectDataTable(qry, null, null);
        dd_next_action_type.DataTextField  = "ActionType";
        dd_next_action_type.DataValueField = "ActionTypeID";
        dd_next_action_type.DataBind();

        RadDateTimePicker rdp_next_action = new RadDateTimePicker();

        rdp_next_action.ID             = "rd_next_action_" + TempLeadID;
        rdp_next_action.Skin           = "Bootstrap";
        rdp_next_action.ZIndex         = 99999999;
        rdp_next_action.Width          = 200;
        rdp_next_action.PopupDirection = DatePickerPopupDirection.TopLeft;

        RadButton rb_remove_all_next_action = new RadButton();

        rb_remove_all_next_action.ID = "rb_remove_all_next_action_" + TempLeadID;
        rb_remove_all_next_action.Attributes.Add("style", "float:right;");
        rb_remove_all_next_action.Skin            = "Bootstrap";
        rb_remove_all_next_action.Text            = "Remove All Next Actions";
        rb_remove_all_next_action.Click          += rb_clear_note_Click;
        rb_remove_all_next_action.CommandArgument = TempLeadID;

        // Attempt to set a previously set next action/destination project
        HiddenField hf_nat = new HiddenField()
        {
            ID = "hf_nat_" + TempLeadID
        };
        HiddenField hf_nad = new HiddenField()
        {
            ID = "hf_nad_" + TempLeadID
        };
        String DestinationProjectID = String.Empty;

        qry = "SELECT DestinationProjectID, NextActionTypeID, NextActionDate FROM dbl_temp_leads WHERE TempLeadID=@TempLeadID";
        DataTable dt_next_action = SQL.SelectDataTable(qry, "@TempLeadID", TempLeadID);

        if (dt_next_action.Rows.Count > 0)
        {
            DestinationProjectID = dt_next_action.Rows[0]["DestinationProjectID"].ToString();

            DateTime d = new DateTime();
            if (DateTime.TryParse(dt_next_action.Rows[0]["NextActionDate"].ToString(), out d))
            {
                rdp_next_action.SelectedDate = d;
                hf_nad.Value = d.ToString();
            }

            String app_type = dt_next_action.Rows[0]["NextActionTypeID"].ToString();
            if (dd_next_action_type.FindItemByValue(app_type) != null)
            {
                dd_next_action_type.SelectedIndex = dd_next_action_type.FindItemByValue(app_type).Index;
                hf_nat.Value = dd_next_action_type.SelectedItem.Value;
            }
        }

        p_next_action.Controls.Add(lbl_next_action);
        p_next_action.Controls.Add(dd_next_action_type);
        p_next_action.Controls.Add(rdp_next_action);
        p_next_action.Controls.Add(rb_remove_all_next_action);
        p_next_action.Controls.Add(hf_nat);
        p_next_action.Controls.Add(hf_nad);

        // Destination Project stuff
        Panel p_dest_project = new Panel();

        p_dest_project.Attributes.Add("style", "margin-top:24px;");

        Label lbl_dest_title = new Label();

        lbl_dest_title.CssClass = "MediumTitle";
        lbl_dest_title.Text     = "Pick a Project/Bucket for this Lead (optional, overrides target on import)...";
        lbl_dest_title.Attributes.Add("style", "font-weight:500; margin-top:0px; margin-bottom:6px; position:relative; top:-3px;");

        RadDropDownList dd_project = new RadDropDownList();

        dd_project.ID     = "dd_project_" + TempLeadID;
        dd_project.Width  = 200;
        dd_project.Height = 30;
        dd_project.Attributes.Add("style", "margin-right:5px;");
        dd_project.ZIndex                = 99999999;
        dd_project.ExpandDirection       = DropDownListExpandDirection.Up;
        dd_project.Skin                  = "Bootstrap";
        dd_project.AutoPostBack          = true;
        dd_project.SelectedIndexChanged += dd_project_SelectedIndexChanged;

        RadDropDownList dd_bucket = new RadDropDownList();

        dd_bucket.ID     = "dd_bucket_" + TempLeadID;
        dd_bucket.Width  = 200;
        dd_bucket.Height = 30;
        dd_bucket.Attributes.Add("style", "margin-right:5px;");
        dd_bucket.ZIndex          = 99999999;
        dd_bucket.ExpandDirection = DropDownListExpandDirection.Up;
        dd_bucket.Skin            = "Bootstrap";

        RadButton rb_save_dest_proj = new RadButton();

        rb_save_dest_proj.ID = "btn_save_proj_" + TempLeadID;
        rb_save_dest_proj.Attributes.Add("style", "float:right; position:relative; top:-1px;");
        rb_save_dest_proj.Skin             = "Bootstrap";
        rb_save_dest_proj.Text             = "Save Destination Project";
        rb_save_dest_proj.Click           += rb_save_dest_proj_Click;
        rb_save_dest_proj.CommandArgument  = TempLeadID;
        rb_save_dest_proj.CausesValidation = false;
        // Set CommandName to the currently selected bucketID on save
        rb_save_dest_proj.OnClientClicking = "function(button, args){ var dd = $find('ctl00_Body_" + dd_bucket.ClientID + "'); $find('ctl00_Body_" + rb_save_dest_proj.ClientID + "').set_commandName(dd.get_selectedItem().get_value()); }";

        String SelectedProjectID = String.Empty;
        String SelectedBucketID  = String.Empty;

        if (DestinationProjectID != String.Empty)
        {
            SelectedProjectID = LeadsUtil.GetProjectParentIDFromID(DestinationProjectID);
            SelectedBucketID  = DestinationProjectID;
        }

        // Bind projects & select if possible
        LeadsUtil.BindProjects(dd_project, dd_bucket, SelectedProjectID, SelectedBucketID, true, true);
        dd_project.Items.Insert(0, new DropDownListItem(String.Empty, String.Empty));
        dd_bucket.Items.Insert(0, new DropDownListItem(String.Empty, String.Empty));

        if (DestinationProjectID == String.Empty)
        {
            dd_project.SelectedIndex = 0;
            dd_bucket.SelectedIndex  = 0;
        }

        p_dest_project.Controls.Add(lbl_dest_title);
        p_dest_project.Controls.Add(dd_project);
        p_dest_project.Controls.Add(dd_bucket);
        p_dest_project.Controls.Add(rb_save_dest_proj);

        p.Controls.Add(lbl_notes_title);
        p.Controls.Add(rtb_note);
        p.Controls.Add(new Label()
        {
            Text = "<br/>"
        });
        p.Controls.Add(rb_clear_note);
        p.Controls.Add(rb_clear_all_notes);
        p.Controls.Add(rb_add_note);
        p.Controls.Add(rb_add_note_to_all);
        p.Controls.Add(p_next_action);
        p.Controls.Add(p_dest_project);

        args.UpdatePanel.ContentTemplateContainer.Controls.Add(p);
        args.UpdatePanel.ChildrenAsTriggers = true;
    }
Пример #12
0
        /// <summary>
        /// Permite pararse en un item del DropDownList deacuerdo a su valor
        /// </summary>
        /// <param name="myDropDownList">Objeto DropDownList el cual actualizar</param>
        /// <param name="item_value">Valor a buscar en el DropDownLis</param>
        /// <remarks>
        /// <list> Creado: Enero 17 de 2013 - Ing. David Pineda </list>
        /// </remarks>
        public static void selectIndexByValue(ref RadDropDownList myDropDownList, string item_value)
        {
            if (myDropDownList == null)
            {
                throw new ArgumentNullException("El argumento myDropDownList es nulo");
            }

            if (item_value == string.Empty)
            {
                throw new ArgumentException("El argumento item_value esta vacio");
            }

            if (myDropDownList.Items.Count > 0)
            {
                try
                {
                    myDropDownList.SelectedIndex = myDropDownList.FindItemByValue(item_value).Index;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }