Esempio n. 1
0
    protected void LanesRadGrid_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        GridDataItem       dataItem   = (GridDataItem)e.DetailTableView.ParentItem;
        CagetypeServiceDAO cts        = new CagetypeServiceDAO();
        string             cageTypeId = dataItem.GetDataKeyValue("cage_type_id").ToString();

        e.DetailTableView.DataSource = cts.GetCageServices(cageTypeId).Tables[0];
    }
Esempio n. 2
0
    protected void CageTypesRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        //if (e.Item is GridCommandItem)
        //{
        //    Button addButton = e.Item.FindControl("AddNewRecordButton") as Button;
        //    addButton.Visible = false;
        //    LinkButton lnkButton = (LinkButton)e.Item.FindControl("InitInsertButton");
        //    lnkButton.Visible = false;
        //}

        //Control cont = e.Item.NamingContainer;
        if (e.Item is GridDataItem && !e.Item.Expanded)
        {
            GridDataItem dataItem    = e.Item as GridDataItem;
            string       contactName = dataItem.GetDataKeyValue("cage_type_id").ToString();

            Button button = dataItem["DeleteColumn"].Controls[0] as Button;
            button.Attributes["onclick"] = "return confirm('Are you sure you want to delete cage type " +
                                           contactName + "?')";
        }

        if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
        {
            if (e.Item.ItemIndex < 0)
            {
                // Inserting Cage Type

                GridEditableItem editedItem = e.Item as GridEditableItem;


                ((RadTextBox)e.Item.FindControl("txtCageType")).Enabled = true;

                ((Label)(e.Item.FindControl("lblCageType"))).Visible = false;

                RadComboBox rcbCarriers  = (RadComboBox)e.Item.FindControl("rcbCarriers");
                RadComboBox rcbCarriers2 = (RadComboBox)e.Item.FindControl("rcbCarriers2");
                CarrierDAO  carrier      = new CarrierDAO();
                rcbCarriers.DataSource     = carrier.GetCarriers();
                rcbCarriers.DataTextField  = "carrier_descr";
                rcbCarriers.DataValueField = "carrier_id";
                rcbCarriers.Items.Add(new RadComboBoxItem("Select Carrier"));
                rcbCarriers.DataBind();
                RadComboBoxItem rcbItem = new RadComboBoxItem("Select Carrier", "-1");
                rcbCarriers.Items.Add(rcbItem);
                rcbCarriers.SelectedValue = "-1";

                rcbCarriers2.DataSource     = carrier.GetCarriers();
                rcbCarriers2.DataTextField  = "carrier_descr";
                rcbCarriers2.DataValueField = "carrier_id";
                rcbCarriers2.Items.Add(new RadComboBoxItem("Select Carrier"));
                rcbCarriers2.DataBind();
                rcbCarriers2.Items.Add(rcbItem);
                rcbCarriers2.SelectedValue = "-1";

                RadComboBox           rcbStoreDeliveryGroup = (RadComboBox)e.Item.FindControl("rcbStoreDeliveryGroup");
                StoreDeliveryGroupDAO storeDeliveryGroup    = new StoreDeliveryGroupDAO();
                rcbStoreDeliveryGroup.DataSource     = storeDeliveryGroup.GetStoreDeliveryGroups();
                rcbStoreDeliveryGroup.DataTextField  = "group_name";
                rcbStoreDeliveryGroup.DataValueField = "group_id";
                rcbStoreDeliveryGroup.DataBind();
                RadComboBoxItem rcbItemStoreDeliveryGroup = new RadComboBoxItem("None", "-1");
                rcbStoreDeliveryGroup.Items.Add(rcbItemStoreDeliveryGroup);
                rcbStoreDeliveryGroup.SelectedValue = "-1";

                CagetypeDAO cagetypedao  = new CagetypeDAO();
                RadComboBox rcbCntryGrps = (RadComboBox)e.Item.FindControl("rcbCntryGrps");
                rcbCntryGrps.DataSource     = cagetypedao.GetCountryGroups();
                rcbCntryGrps.DataTextField  = "country_group_descr";
                rcbCntryGrps.DataValueField = "country_group_id";
                rcbCntryGrps.DataBind();
                RadComboBoxItem rcbitemCntryGrp = new RadComboBoxItem("All", "-1");
                rcbCntryGrps.Items.Add(rcbitemCntryGrp);
                rcbCntryGrps.SelectedValue = "-1";
            }
            else
            {
                // Editing Cage Type


                GridEditableItem editedItem = e.Item as GridEditableItem;

                string      cagetype = editedItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cage_type_id"].ToString();
                DataRowView row      = (DataRowView)e.Item.DataItem;

                ((Label)(e.Item.FindControl("lblCageType"))).Visible = true;
                ((Label)(e.Item.FindControl("lblCageType"))).Text    = cagetype;

                ((RadTextBox)(e.Item.FindControl("txtCageType"))).Visible = false;


                ((RadTextBox)e.Item.FindControl("txtCageTypeDescr")).Text = (string)row.Row["cage_type_descr"];

                string despatchable_ind = (string)row.Row["despatchable_ind"];
                if (despatchable_ind == "T")
                {
                    ((CheckBox)e.Item.FindControl("cbDespatchableInd")).Checked = true;
                }
                else
                {
                    ((CheckBox)e.Item.FindControl("cbDespatchableInd")).Checked = false;
                }

                RadComboBox rcbCarriers = (RadComboBox)e.Item.FindControl("rcbCarriers");
                CarrierDAO  carrier     = new CarrierDAO();
                rcbCarriers.DataSource     = carrier.GetCarriers();
                rcbCarriers.DataTextField  = "carrier_descr";
                rcbCarriers.DataValueField = "carrier_id";
                rcbCarriers.SelectedValue  = (string)row.Row["carrier_id"];
                rcbCarriers.DataBind();

                RadComboBox rcbCarriers2 = (RadComboBox)e.Item.FindControl("rcbCarriers2");
                rcbCarriers2.DataSource     = carrier.GetCarriers();
                rcbCarriers2.DataTextField  = "carrier_descr";
                rcbCarriers2.DataValueField = "carrier_id";
                rcbCarriers2.SelectedValue  = (string)row.Row["carrier_id"];
                rcbCarriers2.DataBind();

                RadComboBox           rcbStoreDeliveryGroup = (RadComboBox)e.Item.FindControl("rcbStoreDeliveryGroup");
                StoreDeliveryGroupDAO storeDeliveryGroup    = new StoreDeliveryGroupDAO();
                rcbStoreDeliveryGroup.DataSource     = storeDeliveryGroup.GetStoreDeliveryGroups();
                rcbStoreDeliveryGroup.DataTextField  = "group_name";
                rcbStoreDeliveryGroup.DataValueField = "group_id";
                rcbStoreDeliveryGroup.DataBind();
                RadComboBoxItem rcbItemStoreDeliveryGrp = new RadComboBoxItem("None", "-1");
                rcbStoreDeliveryGroup.Items.Add(rcbItemStoreDeliveryGrp);

                if (row.Row["sd_group_id"] is System.DBNull)
                {
                    rcbStoreDeliveryGroup.SelectedValue = "-1";
                }
                else
                {
                    Int64 stgroupid = (Int64)row.Row["sd_group_id"];
                    rcbStoreDeliveryGroup.SelectedValue = stgroupid.ToString();
                }


                CagetypeDAO cagetypedao  = new CagetypeDAO();
                RadComboBox rcbCntryGrps = (RadComboBox)e.Item.FindControl("rcbCntryGrps");
                rcbCntryGrps.DataSource     = cagetypedao.GetCountryGroups();
                rcbCntryGrps.DataTextField  = "country_group_descr";
                rcbCntryGrps.DataValueField = "country_group_id";
                rcbCntryGrps.DataBind();
                RadComboBoxItem rcbitemCntryGrp = new RadComboBoxItem("All", "-1");
                rcbCntryGrps.Items.Add(rcbitemCntryGrp);

                if (row.Row["country_group_id"] is System.DBNull)
                {
                    rcbCntryGrps.SelectedValue = "-1";
                }
                else
                {
                    rcbCntryGrps.SelectedValue = (string)row.Row["country_group_id"];
                }
                RadListBox         rlbFrom = (RadListBox)e.Item.FindControl("RadListBoxFrom");
                RadListBox         rlbTo   = (RadListBox)e.Item.FindControl("RadListBoxTo");
                CagetypeServiceDAO cts     = new CagetypeServiceDAO();
                rlbFrom.DataSource = cts.GetAvailableServices(cagetype).Tables[0];
                rlbTo.DataSource   = cts.GetCageServices(cagetype).Tables[0];
                rlbFrom.DataBind();
                rlbTo.DataBind();
            }
        }
    }