상속: System.Web.UI.WebControls.ListControl, IScriptControl, IPostBackDataHandler, INamingContainer, IControlResolver
    protected void ManageEditRow()
    {
        if (grid.EditIndex != -1)
        {
            GridViewRow editRow = grid.Rows[grid.EditIndex];
            AjaxControlToolkit.ComboBox comboProduct = editRow.FindControl(TEXT_BOX_IDS[1]) as AjaxControlToolkit.ComboBox;
            AjaxControlToolkit.ComboBox comboFrom    = editRow.FindControl(TEXT_BOX_IDS[2]) as AjaxControlToolkit.ComboBox;
            AjaxControlToolkit.ComboBox comboTo      = editRow.FindControl(TEXT_BOX_IDS[3]) as AjaxControlToolkit.ComboBox;

            int productId;
            try {
                if (comboProduct != null)
                {
                    string id = GetDatabaseField("ProdID", "ProdDesc", comboProduct.SelectedValue, "tblprodfore");
                    productId = int.Parse(id);
                    List <string> operList = GetOperList("opnam1", productId);
                    if (comboFrom != null)
                    {
                        FillComboOper(comboFrom, operList);
                    }
                    if (comboTo != null)
                    {
                        FillComboOper(comboTo, operList);
                    }
                }
            } catch (Exception) { }
        }
    }
    private void comboFill(AjaxControlToolkit.ComboBox combo)
    {
        /*string command = "SELECT LaborDesc FROM tbllabor;";
         * OleDbCommand oleComm = new OleDbCommand(command, oleConn);
         * OleDbDataAdapter oleAdapter = new OleDbDataAdapter();
         * DataTable dt = new DataTable();
         * oleAdapter.Fill(dt);
         * combo.DataSource = dt;
         * combo.DataBind();*/
        List <string> list   = new List <string>();
        ListItem      item   = new ListItem("apples");
        ListItem      item2  = new ListItem("pears");
        ArrayList     myList = new ArrayList();

        myList.Add(new ListItem("apples", "1"));
        myList.Add(new ListItem("pears", "2"));
        myList.Add(new ListItem("bananas", "3"));
        foreach (ListItem it in myList)
        {
            combo.Items.Add(it);
        }
        //string propertyValue = DataBinder.Eval(row.DataItem, bindExpression).ToString();
        //combo.Text = propertyValue;
        ;
    }
예제 #3
0
    public static void ObtenComboAjax(AjaxControlToolkit.ComboBox oComboAjax, System.Data.SqlClient.SqlDataReader dr)
    {
        if ((oComboAjax.Items.Count > 0))
        {
            oComboAjax.Items.Clear();
        }//end if

        try
        {
            oComboAjax.Items.Add("--");
            if (!(dr == null))
            {
                while (dr.Read())
                {
                    //Agrega elementos a la lista
                    ListItem newItem = new ListItem();
                    newItem.Value = dr.GetValue(0).ToString();
                    newItem.Text  = dr.GetValue(1).ToString();
                    oComboAjax.Items.Add(new ListItem(newItem.Text, newItem.Value));
                }
            } //end if;
        }
        catch (Exception ex)
        {
            throw new Exception("Se ha producido un error en el metodo ObtenCombo ", ex);
        } //end try
    }     //end ObtenCombo
예제 #4
0
    protected void ddlItemwoden_OnSelectedIndexChanged_(object sender, EventArgs e)
    {
        try
        {
            AjaxControlToolkit.ComboBox ddlItemwoden = (AjaxControlToolkit.ComboBox)sender;
            GridViewRow grd     = (GridViewRow)ddlItemwoden.Parent.Parent;
            int         currrow = grd.RowIndex;
            string      a       = ViewState["ddlItem"].ToString();
            Ds = new DataSet();
            Ds = Obj_RequisitionCafeteria.GetItemDataAccordingToID(Convert.ToInt32(a), out StrError);

            DataTable dt = new DataTable();
            dt = Ds.Tables[0];
            DataTable dt1 = new DataTable();
            dt1 = Ds.Tables[1];
            DataTable dt2 = new DataTable();
            dt2 = Ds.Tables[2];
            DataTable dt3 = new DataTable();
            dt3 = Ds.Tables[3];

            ViewState["ParticularItem"] = Ds.Tables[0];
            DataTable dtt = new DataTable();
            dtt = (DataTable)ViewState["ParticularItem"];
            if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0)
            {
            }
            else
            {
            }
            //  GetAvaliableQuantityForItem(currrow);


            #region [Bind ItemDescription and UnitConverSion]
            if (Ds.Tables[2].Rows.Count > 0)
            {
            }
            if (Ds.Tables[3].Rows.Count > 0)
            {
            }

            if (Ds.Tables[2].Rows.Count > 1)
            {
                //((AjaxControlToolkit.ComboBox)grdwoodenbox.Rows[currrow].FindControl("ddlItemwoden")).Focus();
            }
            else
            {
            }
            #endregion
        }
        catch (Exception ex)
        {
        }
    }
    private void combo_DataBinding(object sender, EventArgs e)
    {
        AjaxControlToolkit.ComboBox combo = sender as AjaxControlToolkit.ComboBox;
        GridViewRow row = (GridViewRow)combo.NamingContainer;

        if (row.DataItem != null && combo.Items.Count > 0)
        {
            string propertyValue = DataBinder.Eval(row.DataItem, bindExpression).ToString();
            if (combo.Items.FindByText(propertyValue) == null)
            {
                combo.Items.Add(propertyValue);
            }
            combo.Text = propertyValue;
        }
    }
    protected void EquipType_Changed(object sender, EventArgs e)
    {
        AjaxControlToolkit.ComboBox combo = sender as AjaxControlToolkit.ComboBox;
        GridViewRow row       = combo.NamingContainer as GridViewRow;
        TextBox     txtGrpSiz = row.FindControl("txtEdit4") as TextBox;

        if (combo.Text.Equals("Standard"))
        {
            txtGrpSiz.Text = "1";
        }
        else
        {
            txtGrpSiz.Text = "-1";
        }
    }
예제 #7
0
    protected void FillAllowableComponentsDdl(AjaxControlToolkit.ComboBox ddl)
    {
        {
            ClassE calc = new ClassE(GetDirectory() + userDir);
            calc = new ClassE(GetDirectory() + userDir);
            calc.runsql("DELETE tblPossibleComp.* from tblPossibleComp;");
            try
            {
                calc.MakePossibleTable(int.Parse(dropListProducts.SelectedValue));
            }
            catch (Exception) { }
            calc.Close();
        }

        OleDbConnection  connec         = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + GetDirectory() + userDir + MAIN_USER_DATABASE + ";");
        string           commandRouting = "Select tblPossibleComp.* from tblPossibleComp ORDER BY ProdDesc;";
        OleDbCommand     cmd            = new OleDbCommand(commandRouting, connec);
        OleDbDataAdapter adapter        = new OleDbDataAdapter(cmd); //
        {
            try
            {
                connec.Open();
                DataTable ds = new DataTable();
                adapter.Fill(ds);
                if (ddl != null)
                {
                    ddl.Items.Clear();
                    for (int i = 0; i < ds.Rows.Count; i++)
                    {
                        ListItem item = new ListItem(ds.Rows[i]["ProdDesc"].ToString(), ds.Rows[i]["ProdID"].ToString());
                        ddl.Items.Add(item);
                    }
                }
                connec.Close();
            }
            catch (Exception ex)
            {
                try
                {
                    connec.Close();
                    connec = null;
                }
                catch { }
                string message = ex.Message;
            }
        }
    }
    protected void SelectedProduct_Changed(object sender, EventArgs e)
    {
        AjaxControlToolkit.ComboBox comboProduct = sender as AjaxControlToolkit.ComboBox;
        GridViewRow row = comboProduct.NamingContainer as GridViewRow;

        AjaxControlToolkit.ComboBox comboFrom = row.FindControl("comboEdit2") as AjaxControlToolkit.ComboBox;
        AjaxControlToolkit.ComboBox comboTo   = row.FindControl("comboEdit3") as AjaxControlToolkit.ComboBox;
        if (!comboProduct.SelectedValue.Equals(""))
        {
            if (comboFrom != null)
            {
                comboFrom.Enabled = true;
            }
            if (comboTo != null)
            {
                comboTo.Enabled = true;
            }
        }
    }
예제 #9
0
    protected override void SetData()
    {
        base.SetData();
        GridViewRow row = grid.FooterRow;

        if (row != null)
        {
            AjaxControlToolkit.ComboBox comboDesc = row.FindControl("comboEdit8") as AjaxControlToolkit.ComboBox;
            if (comboDesc != null)
            {
                comboDesc.SelectedValue = "NONE";
                comboDesc.DropDownStyle = AjaxControlToolkit.ComboBoxStyle.DropDownList;
            }
            AjaxControlToolkit.ComboBox comboEquipType = row.FindControl("comboEdit3") as AjaxControlToolkit.ComboBox;
            if (comboEquipType != null)
            {
                comboEquipType.SelectedValue = "Standard";
                comboEquipType.DropDownStyle = AjaxControlToolkit.ComboBoxStyle.DropDownList;
            }
        }
    }
    protected void FillComboOper(AjaxControlToolkit.ComboBox combo, List <string> opers)
    {
        string selectedValue = null;

        if (combo.SelectedValue != null)
        {
            selectedValue = combo.SelectedValue;
        }
        combo.Items.Clear();
        for (int i = 0; i < opers.Count; i++)
        {
            combo.Items.Add(opers[i]);
        }
        if (selectedValue != null)
        {
            if (combo.Items.FindByValue(selectedValue) != null)
            {
                combo.SelectedValue = selectedValue;
            }
        }
    }
 protected override void SetData()
 {
     SetTableStrings();
     tableSync.UpdateOpNumbers();
     base.SetData();
     if (grid.FooterRow != null)
     {
         AjaxControlToolkit.ComboBox comboProduct = grid.FooterRow.FindControl("comboEdit1") as AjaxControlToolkit.ComboBox;
         AjaxControlToolkit.ComboBox comboOper    = grid.FooterRow.FindControl("comboEdit2") as AjaxControlToolkit.ComboBox;
         if (comboProduct != null && comboProduct.Items.Count == 0)
         {
             thirdPanel.Visible = false;
             Master.ShowErrorMessage("No products are defined yet. Please go to the input products page and create a product first.");
         }
         else if (comboOper != null && comboOper.Items.Count == 0)
         {
             Master.ShowErrorMessage("No operations are defined yet. Please go to the input operations page and create some operation.");
             thirdPanel.Visible = false;
         }
     }
 }
    protected void GrpSiz_Changed(object sender, EventArgs e)
    {
        TextBox     txtGrpSiz = sender as TextBox;
        GridViewRow row       = txtGrpSiz.NamingContainer as GridViewRow;

        AjaxControlToolkit.ComboBox combo = row.FindControl("comboEdit3") as AjaxControlToolkit.ComboBox;

        string postbackControlId = "";

        try
        {
            if (ScriptManager.GetCurrent(txtGrpSiz.Page).IsInAsyncPostBack)
            {
                postbackControlId = DbPage.GetAsyncPostBackControlID(txtGrpSiz.Page);
            }
            else
            {
                postbackControlId = DbPage.GetPostBackControl(txtGrpSiz.Page).ID;
            }
        }
        catch (Exception) { }
        if (!postbackControlId.EndsWith(combo.ID))
        {
            int num = 0;
            try
            {
                num = int.Parse(txtGrpSiz.Text);
                if (num == -1)
                {
                    combo.SelectedValue = "Delay";
                }
                else if (num > 0)
                {
                    combo.SelectedValue = "Standard";
                }
                //txtGrpSiz.Text = 10 + "";
            }
            catch (Exception) { }
        }
    }
예제 #13
0
/// <summary>
/// Use this when adding ACT Comboboxes that may be initially hidden when loaded.
/// It registers all comboboxes into a client-side array. If the user writes
/// scripts that make the ACT Comboboxes visible, they should call
/// ActComboBoxMadeVisible_All(), a client-side method.
/// </summary>
    public static void RegisterComboBox(AjaxControlToolkit.ComboBox pComboBox)
    {
        ClientScriptManager vClientScript = pComboBox.Page.ClientScript;

        if (!vClientScript.IsClientScriptBlockRegistered("ActComboBoxFixer"))
        {
            string vScript =
                "function ActComboBoxMadeVisible_All()\r\n" +
                "{\r\n" +
                "   if (window.gActComboboxes)\r\n" +
                "      for (var vI = 0; vI < window.gActComboboxes.length; vI++)\r\n" +
                "      {\r\n" +
                "         var vCB = $find(window.gActComboboxes[vI]);\r\n" +
                "         if (vCB)\r\n" +
                "         {\r\n" +
                "            ActComboBoxMadeVisible(vCB);\r\n" +
                "         }\r\n" +
                "      }\r\n" +
                "}\r\n" +
                "function ActComboBoxMadeVisible(pCB)\r\n" +
                "{\r\n" +
                "  if (pCB && !pCB._optionListItemHeight)\r\n" +
                "  {\r\n" +
                "     var vBtn = pCB.get_buttonControl();\r\n" +
                "     vBtn.style.width = '';\r\n" +
                "     vBtn.style.height = '';\r\n" +
                "     pCB.initializeButton();\r\n" +
                "     pCB._optionListHeight = null;\r\n" +
                "     pCB._optionListWidth = null;\r\n" +
                "     pCB._optionListItemHeight = 21;\r\n" +
                "     pCB._getOptionListWidth();\r\n" +
                "     pCB._getOptionListHeight();\r\n" +
                "  }\r\n" +
                "}\r\n";
            vClientScript.RegisterClientScriptBlock(typeof(Page), "ActComboBoxFixer", vScript, true);
        }
        pComboBox.Page.ClientScript.RegisterArrayDeclaration("gActComboboxes", "'" + pComboBox.ClientID + "'");
    }
예제 #14
0
        /// <summary>
        /// Fills the Assembly Number into the supplied Drop Down List
        /// </summary>
        /// <param name="con">SqlConnection</param>
        /// <param name="list">DropDownList</param>
        public static void FillAssemblyNo(SqlConnection con, ComboBox list)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = @"Select AssemblyID from AssemblyMaster";
                cmd.Connection = con;

                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                adp.Fill(dt);

                list.DataSource = dt;
                list.DataTextField = "AssemblyID";
                list.DataValueField = "AssemblyID";
                list.DataBind();
            }
            catch (Exception ex)
            {
                log.Error("Error filling assembly Number : " + ex.Message);
                throw ex;
            }
        }
 public ComboBoxDesignerActionList(IComponent component)
     : base(component)
 {
     _comboBox = (ComboBox)component;
 }
예제 #16
0
    protected void ddlItem_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            AjaxControlToolkit.ComboBox ddlItems = (AjaxControlToolkit.ComboBox)sender;
            GridViewRow grd     = (GridViewRow)ddlItems.Parent.Parent;
            int         currrow = grd.RowIndex;
            string      a       = ViewState["ddlItem"].ToString();
            Ds = new DataSet();
            Ds = Obj_RequisitionCafeteria.GetItemDataAccordingToID(Convert.ToInt32(a), out StrError);

            DataTable dt = new DataTable();
            dt = Ds.Tables[0];
            DataTable dt1 = new DataTable();
            dt1 = Ds.Tables[1];
            DataTable dt2 = new DataTable();
            dt2 = Ds.Tables[2];
            DataTable dt3 = new DataTable();
            dt3 = Ds.Tables[3];

            ViewState["ParticularItem"] = Ds.Tables[0];
            DataTable dtt = new DataTable();
            dtt = (DataTable)ViewState["ParticularItem"];
            if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0)
            {
            }
            else
            {
            }
            //  GetAvaliableQuantityForItem(currrow);


            #region [Bind ItemDescription and UnitConverSion]
            if (Ds.Tables[2].Rows.Count > 0)
            {
                //ViewState["ItemDesCriptionList"] = Ds.Tables[2];
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlItemDescription")).DataSource = Ds.Tables[2];
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlItemDescription")).DataTextField = "ItemDesc";
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlItemDescription")).DataValueField = "#";
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlItemDescription")).DataBind();
                //string UNIT = string.Empty;
                //for (int i = 1; i < Ds.Tables[2].Rows.Count; i++)
                //{
                //    UNIT = UNIT + "\n, " + Ds.Tables[2].Rows[i]["ItemDesc"].ToString();
                //}
                //if (Ds.Tables[2].Rows.Count > 1)
                //{
                //    obj_Comman.ShowPopUpMsg("For This Particular,\nIndent Can Be Made Using Following Description -\n" + UNIT, this.Page);
                //}
            }
            if (Ds.Tables[3].Rows.Count > 0)
            {
                //ViewState["UnitConversnList"] = Ds.Tables[3];
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlUnitConvertor")).DataSource = Ds.Tables[3];
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlUnitConvertor")).DataTextField = "UnitFactor";
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlUnitConvertor")).DataValueField = "#";
                //((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlUnitConvertor")).DataBind();
                //if (Ds.Tables[2].Rows.Count <= 1)
                //{
                //    if (Ds.Tables[3].Rows.Count > 1)
                //    {
                //        string UNIT1 = string.Empty;
                //        for (int i = 0; i < Ds.Tables[3].Rows.Count; i++)
                //        {
                //            UNIT1 = UNIT1 + "\n, " + Ds.Tables[3].Rows[i]["UnitFactor"].ToString();
                //        }
                //        obj_Comman.ShowPopUpMsg("For This Particular,\nIndent Can Be Made Using Following UOM -\n" + UNIT1, this.Page);
                //    }
                //}
            }
            #endregion

            //}
            //else
            //{
            //    // SetInitialRow_GrdRequisition();
            //    obj_Comman.ShowPopUpMsg("Item Already Present!", this.Page);
            //}
            if (Ds.Tables[2].Rows.Count > 1)
            {
                ((AjaxControlToolkit.ComboBox)grdwoodenbox.Rows[currrow].FindControl("ddlItemDescription")).Focus();
            }
            else
            {
                //  ((AjaxControlToolkit.ComboBox)grditem.Rows[currrow].FindControl("ddlUnitConvertor")).Focus();
            }
        }
        catch (Exception ex)
        {
        }
    }
    public void InitializeComponent()
    {
        if (wantSort)
        {
            comboSource.ID       = "comboSource";
            comboSource.DataFile = GetDirectory() + userDir + MAIN_USER_DATABASE;

            //  get sortstring from zstblsort_table, parse to get items for combo boxes ... put into combo boxes...

            if (SORT_COMMAND != null)
            {
                comboSource.SelectCommand = SORT_COMMAND;
            }
            else
            {
                comboSource.SelectCommand = "SELECT zstblsort.* FROM zstblsort WHERE (((zstblsort.tableName)= '" + sortedTableName + "')) ORDER BY index1;";
            }

            //HIDE SORT UNTIL I ENABLE GRIDVIEW SORT EVENT
            Label lblSort = new Label();
            lblSort.Text                = "<i class='fas fa-sort fa-fw row-icon'></i>";
            lblSort.CssClass            = "hidden icon-menu";
            lblSort.AssociatedControlID = InputPageControls.BTN_SORT;

            btnSort          = new Button();
            btnSort.ID       = InputPageControls.BTN_SORT;
            btnSort.Text     = "Sort"; //   size  ??
            btnSort.CssClass = "menu-button";

            Control sortButtonContainer = GetSortButtonContainer();
            sortButtonContainer.Controls.Add(lblSort);
            sortButtonContainer.Controls.Add(btnSort);
            sortButtonContainer.Controls.Add(comboSource);


            sortPanel    = InputPageControls.GenerateSortPanel();
            sortExtender = InputPageControls.GenerateSortExtender();

            Panel sortPanelContainer = GetSortPanelContainer();
            sortPanelContainer.Controls.Add(sortExtender);
            sortPanelContainer.Controls.Add(sortPanel);


            comboSorts    = new AjaxControlToolkit.ComboBox[InputPageControls.NUM_SORT_EXPRESSIONS];
            rdbtnSortAsc  = new RadioButton[InputPageControls.NUM_SORT_EXPRESSIONS];
            rdbtnSortDesc = new RadioButton[InputPageControls.NUM_SORT_EXPRESSIONS];
            for (int i = 0; i < InputPageControls.NUM_SORT_EXPRESSIONS; i++)
            {
                comboSorts[i]    = sortPanel.FindControl(InputPageControls.COMBO_SORT_IDS[i]) as AjaxControlToolkit.ComboBox;
                rdbtnSortAsc[i]  = sortPanel.FindControl(InputPageControls.SORT_RADIO_BTN_ASC_IDS[i]) as RadioButton;
                rdbtnSortDesc[i] = sortPanel.FindControl(InputPageControls.SORT_RADIO_BTN_DESC_IDS[i]) as RadioButton;
            }

            Button btnOkSort = sortPanel.FindControl(InputPageControls.BTN_OK_SORT) as Button;
            btnOkSort.Click        += new EventHandler(btnOkSort_Click);
            btnOkSort.OnClientClick = "HidePopup('" + InputPageControls.BEHAVIOR_SORT + "'); return true;";

            Button btnCancelSort = sortPanel.FindControl(InputPageControls.BTN_CANCEL_SORT) as Button;
            btnCancelSort.OnClientClick = "HidePopup('" + InputPageControls.BEHAVIOR_SORT + "'); return false;";

            for (int j = 0; j < InputPageControls.NUM_SORT_EXPRESSIONS; j++)
            {
                AjaxControlToolkit.ComboBox combo = comboSorts[j];
                combo.DataSource     = comboSource;
                combo.DataTextField  = "FieldName";
                combo.DataValueField = "afieldname2";
                //ComboBoxFixer.RegisterComboBox(combo);
                combo.DataBind();
                combo.Attributes.Add("onkeydown", "doFocus('" + btnOkSort.ClientID + "', event);");
                //Master.ClickOnEnter(btnOkSort.ClientID, combo);
            }
            string scriptResizeCombos = "document.getElementById('" + sortPanel.ClientID + "').style.display='block'; ";
            for (int j = 0; j < InputPageControls.NUM_SORT_EXPRESSIONS; j++)
            {
                AjaxControlToolkit.ComboBox combo = comboSorts[j];
                scriptResizeCombos += "ResetComboBox('" + combo.ClientID + "'); ";
            }
            btnSort.OnClientClick = scriptResizeCombos;
            sortPanel.Attributes.Add("style", "display: none;");
        }
        //ComboBoxFixer.RegisterModalPopupExtender(sortExtender); // combo fixes
        if (wantSort2)
        {
            comboSource2.ID       = "comboSource2";
            comboSource2.DataFile = GetDirectory() + userDir + MAIN_USER_DATABASE;
            if (SORT_COMMAND2 != null)
            {
                comboSource2.SelectCommand = SORT_COMMAND2;
            }
            else
            {
                comboSource2.SelectCommand = "SELECT zstblsort.* FROM zstblsort WHERE (((zstblsort.tableName)= '" + sortedTableName2 + "')) ORDER BY index1;";
            }

            //NEED TO WRAP IN LABEL AND ADD CSS CLASS
            btnSort2      = new Button();
            btnSort2.ID   = InputPageControls.BTN_SORT2;
            btnSort2.Text = "Sort"; //   size  ??
            //btnSort2.Width = 60;
            //btnSort2.Height = 25;
            //btnSort2.CssClass = "otherButton";

            Control sortButtonContainer2 = GetSortButtonContainer2();
            sortButtonContainer2.Controls.Add(btnSort2);
            sortButtonContainer2.Controls.Add(comboSource2);

            sortPanel2    = InputPageControls.GenerateSortPanel2();
            sortExtender2 = InputPageControls.GenerateSortExtender2();

            Panel sortPanelContainer = GetSortPanelContainer2();
            sortPanelContainer.Controls.Add(sortExtender2);
            sortPanelContainer.Controls.Add(sortPanel2);



            comboSorts2    = new AjaxControlToolkit.ComboBox[InputPageControls.NUM_SORT_EXPRESSIONS];
            rdbtnSortAsc2  = new RadioButton[InputPageControls.NUM_SORT_EXPRESSIONS];
            rdbtnSortDesc2 = new RadioButton[InputPageControls.NUM_SORT_EXPRESSIONS];
            for (int i = 0; i < InputPageControls.NUM_SORT_EXPRESSIONS; i++)
            {
                comboSorts2[i]    = sortPanel2.FindControl(InputPageControls.COMBO_SORT_IDS2[i]) as AjaxControlToolkit.ComboBox;
                rdbtnSortAsc2[i]  = sortPanel2.FindControl(InputPageControls.SORT_RADIO_BTN_ASC2_IDS[i]) as RadioButton;
                rdbtnSortDesc2[i] = sortPanel2.FindControl(InputPageControls.SORT_RADIO_BTN_DESC2_IDS[i]) as RadioButton;
            }

            Button btnOkSort2 = sortPanel.FindControl(InputPageControls.BTN_OK_SORT2) as Button;
            btnOkSort2.Click        += new EventHandler(btnOkSort2_Click);
            btnOkSort2.OnClientClick = "HidePopup('" + InputPageControls.BEHAVIOR_SORT2 + "'); return true;";

            Button btnCancelSort2 = sortPanel.FindControl(InputPageControls.BTN_CANCEL_SORT2) as Button;
            btnCancelSort2.OnClientClick = "HidePopup('" + InputPageControls.BEHAVIOR_SORT2 + "'); return false;";

            for (int j = 0; j < InputPageControls.NUM_SORT_EXPRESSIONS; j++)
            {
                AjaxControlToolkit.ComboBox combo = comboSorts2[j];
                combo.DataSource     = comboSource2;
                combo.DataTextField  = "FieldName";
                combo.DataValueField = "afieldname2";
                //ComboBoxFixer.RegisterComboBox(combo);
                combo.DataBind();
                combo.Attributes.Add("onkeydown", "doFocus('" + btnOkSort2.ClientID + "', event);");
                //Master.ClickOnEnter(btnOkSort2.ClientID, combo);
            }
            string scriptResizeCombos = "document.getElementById('" + sortPanel2.ClientID + "').style.display='block'; ";
            for (int j = 0; j < InputPageControls.NUM_SORT_EXPRESSIONS; j++)
            {
                AjaxControlToolkit.ComboBox combo = comboSorts2[j];
                scriptResizeCombos += "ResetComboBox('" + combo.ClientID + "'); ";
            }
            btnSort2.OnClientClick = scriptResizeCombos;
            sortPanel2.Attributes.Add("style", "display: none;");
        }
    }
    public static Panel PrepareSortPanel(string panelId, string[] comboSortIds, string[] radioAsc, string[] radioDesc, string groupNameBase, string btnOkSortId, string btnCancelSortId)
    {
        Panel pnlSort = new Panel();

        pnlSort.ID       = panelId;
        pnlSort.CssClass = "popPanel";
        //pnlSort.Attributes.Add("style", "display: block;");

        pnlSort.Controls.Add(new LiteralControl("<h3>Sort by " + NUM_SORT_EXPRESSIONS + " chosen fields:</h3>"));

        AjaxControlToolkit.ComboBox[] comboSort = new AjaxControlToolkit.ComboBox[NUM_SORT_EXPRESSIONS];
        for (int i = 0; i < NUM_SORT_EXPRESSIONS; i++)
        {
            pnlSort.Controls.Add(new LiteralControl("<div>"));
            Label lblSort = new Label();
            lblSort.CssClass = "lblSort";
            if (i == 0)
            {
                lblSort.Text = "Sort first by: ";
            }
            else if (i == NUM_SORT_EXPRESSIONS - 1)
            {
                lblSort.Text = "Sort finally by: ";
            }
            else
            {
                lblSort.Text = "Sort then by: ";
            }
            pnlSort.Controls.Add(lblSort);

            pnlSort.Controls.Add(new LiteralControl("<div>"));
            comboSort[i]                  = new AjaxControlToolkit.ComboBox();
            comboSort[i].ID               = comboSortIds[i];
            comboSort[i].CssClass         = "comboBoxInsideModalPopup";
            comboSort[i].AutoPostBack     = false;
            comboSort[i].DropDownStyle    = AjaxControlToolkit.ComboBoxStyle.DropDownList;
            comboSort[i].AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.SuggestAppend;
            pnlSort.Controls.Add(comboSort[i]);
            pnlSort.Controls.Add(new LiteralControl("</div>"));


            RadioButton rdbtnAsc = new RadioButton();
            rdbtnAsc.ID        = radioAsc[i];
            rdbtnAsc.Text      = "Ascending";
            rdbtnAsc.GroupName = groupNameBase + i;
            rdbtnAsc.Checked   = true;
            rdbtnAsc.CssClass  = "popLineRadioBtns";
            pnlSort.Controls.Add(rdbtnAsc);

            RadioButton rdbtnDesc = new RadioButton();
            rdbtnDesc.ID        = radioDesc[i];
            rdbtnDesc.Text      = "Descending";
            rdbtnDesc.GroupName = rdbtnAsc.GroupName;
            rdbtnDesc.CssClass  = rdbtnAsc.CssClass;
            pnlSort.Controls.Add(rdbtnDesc);
            pnlSort.Controls.Add(new LiteralControl("</div>"));
            //pnlSort.Controls.Add(new LiteralControl("<br /> <br />"));
        }

        pnlSort.Controls.Add(new LiteralControl("<br />"));

        Button btnOkSort = new Button();

        btnOkSort.ID     = btnOkSortId;
        btnOkSort.Text   = "Sort"; //   size  ??
        btnOkSort.Width  = 60;
        btnOkSort.Height = 25;
        pnlSort.Controls.Add(btnOkSort);
        Button btnCancelSort = new Button();

        btnCancelSort.ID   = btnCancelSortId;
        btnCancelSort.Text = "Cancel";
        pnlSort.Controls.Add(btnCancelSort);

        return(pnlSort);
    }
    public void InstantiateIn(System.Web.UI.Control container)
    {
        switch (templateType)
        {
        case ListItemType.Header:
            Label lbl = new Label();
            lbl.ID      = controlID;
            lbl.Text    = headerText;
            lbl.ToolTip = headerTooltip;
            container.Controls.Add(lbl);
            break;

        case ListItemType.Item:
            PlaceHolder holderI1 = new PlaceHolder();
            holderI1.ID = "holderI1";
            PlaceHolder holderI2 = new PlaceHolder();
            holderI2.ID  = "holderI2";
            holderI1.ID += controlID;
            holderI2.ID += controlID;
            if (columnType == DATA)
            {
                Label lblItem = new Label();
                lblItem.ID = controlID;
                //lblItem.Width = 100;
                //if (BTN_UPDATE !=null && bindExpression.Equals("tonum") || bindExpression.Equals("fromnum"))
                //{
                //    lblItem.Enabled = false;
                //    lblItem.Attributes["style"] += "cursor:default;";

                //}


                lblItem.DataBinding += new EventHandler(this.lblItem_DataBinding);

                container.Controls.Add(holderI1);
                container.Controls.Add(holderI2);
                holderI1.Controls.Add(lblItem);
            }
            else if (columnType == BUTTONS)
            {
                HtmlGenericControl btnButton = new HtmlGenericControl();
                btnButton.TagName = "input";
                btnButton.Attributes.Add("id", "btnInput");
                btnButton.Attributes.Add("value", "Select");
                btnButton.Attributes.Add("type", "button");
                btnButton.DataBinding += new EventHandler(btnButton_DataBinding);

                container.Controls.Add(btnButton);
                btnButton.Visible = false;

                Label lblEdit = new Label();
                lblEdit.Text                = "<i class='fas fa-edit row-icon'></i>";
                lblEdit.CssClass            = "icon-button";
                lblEdit.AssociatedControlID = BTN_EDIT;
                container.Controls.Add(lblEdit);

                Button btnEdit = new Button();
                btnEdit.CssClass    = "row-button";
                btnEdit.ID          = BTN_EDIT;
                btnEdit.Text        = "Edit";
                btnEdit.CommandName = "Edit";
                container.Controls.Add(btnEdit);

                if (!whatif)
                {
                    //if (wantCopyButton)
                    //{
                    //    Label lblCopy = new Label();
                    //    lblCopy.Text = "<i class='fa fa-clone row-icon'></i>";
                    //    lblCopy.CssClass = "icon-button";
                    //    lblCopy.AssociatedControlID = BTN_COPY;
                    //    container.Controls.Add(lblCopy);

                    //    Button btnCopy = new Button();
                    //    btnCopy.CssClass = "row-button";
                    //    btnCopy.ID = BTN_COPY;
                    //    btnCopy.Text = "Copy";
                    //    btnCopy.CommandName = "Copy";
                    //    container.Controls.Add(btnCopy);
                    //}

                    //HtmlGenericControl btnDelete = new HtmlGenericControl();
                    //btnDelete.TagName = "button";
                    //btnDelete.InnerHtml = "<i class='fa fa-cloud'></i>";
                    //btnDelete.ID = BTN_DELETE;
                    //btnDelete.CommandName = "Delete";

                    //THIS WORKS BUT NEED TO FIGURE OUT HOW TO ASSIGN SAME DYNAMIC ID FROM BTN
                    //Try assigning JS event to button?
                    //HtmlGenericControl lblDelete = new HtmlGenericControl();
                    //lblDelete.TagName = "label";
                    //lblDelete.Attributes.Add("for", controlID);
                    //lblDelete.InnerHtml = "<i class='fa fa-cloud'></i>";
                    //container.Controls.Add(lblDelete);

                    Label lblDelete = new Label();
                    lblDelete.Text                = "<i class='fas fa-trash row-icon'></i>";
                    lblDelete.CssClass            = "icon-delete";
                    lblDelete.AssociatedControlID = BTN_DELETE;
                    container.Controls.Add(lblDelete);

                    Button btnDelete = new Button();
                    btnDelete.CssClass    = "row-button";
                    btnDelete.ID          = BTN_DELETE;
                    btnDelete.Text        = analysisGrid ? "Remove from Vision" : "Delete";
                    btnDelete.CommandName = "Delete";
                    if (!analysisGrid)
                    {
                        btnDelete.OnClientClick = "return confirm('Are you sure you want to delete the selected record?');";
                    }
                    container.Controls.Add(btnDelete);
                }
            }
            else if (columnType == EMPTY_TABLE)
            {
                Button btnAddNew = new Button();
                btnAddNew.CssClass    = "row-button";
                btnAddNew.Text        = "Add New";
                btnAddNew.CommandName = "insertInEmpty";
                container.Controls.Add(btnAddNew);
            }
            else if (columnType == CHECKBOX_DATA)
            {
                CheckBox checkBox = new CheckBox();
                checkBox.ID = controlID;
                //checkBox.Enabled = false;
                checkBox.Attributes.Add("onclick", "return false;");
                checkBox.DataBinding += new EventHandler(checkboxItem_DataBinding);
                container.Controls.Add(holderI1);
                container.Controls.Add(holderI2);
                holderI2.Controls.Add(checkBox);
            }
            break;

        case ListItemType.EditItem:
            PlaceHolder holder1 = new PlaceHolder();
            holder1.ID = "holder1";
            PlaceHolder holder2 = new PlaceHolder();
            holder2.ID = "holder2";
            if (columnType == DATA)
            {
                TextBox txtItem = new TextBox();
                txtItem.ID = controlID;
                //txtItem.Attributes.Add("onchange", "setCursorToEnd(this)");
                //txtItem.Attributes.Add("width", "100%");
                //txtItem.Width = 100;
                txtItem.DataBinding += new EventHandler(this.txtItem_DataBinding);
                if (bindExpression.Equals("GrpSiz") && controlID.Equals("txtEdit4"))
                {
                    //txtItem.AutoPostBack = true;
                    txtItem.TextChanged += GrpSiz_Changed;
                }
                else if (bindExpression.Equals("tonum") || bindExpression.Equals("fromnum") || bindExpression.Equals("UPF") || bindExpression.Equals("level"))
                {
                    txtItem.Enabled              = false;
                    txtItem.Attributes["style"] += "cursor:default;";
                    txtItem.Attributes["style"] += "background-color: #d4d4d4 !important;";
                    txtItem.Attributes["style"] += "text-align:center;";
                }

                //else
                //{
                //    txtItem.Attributes.Add("onkeydown", "return (event.keyCode=!13);");
                //}
                //if (bindExpression.Equals("OpNum")) {
                //    txtItem.Width = 75;
                //} else if (bindExpression.Equals("PercentAssign")) {
                //    txtItem.Width = 90;
                //} else if (bindExpression.Equals("MainVarFrom") || bindExpression.Equals("MainVarTo") || bindExpression.Equals("MainVarStep")) {
                //    txtItem.Width = 70;
                //}

                holder1.ID += controlID;
                holder2.ID += controlID;
                container.Controls.Add(holder1);
                container.Controls.Add(holder2);
                holder1.Controls.Add(txtItem);
            }
            else if (columnType == BUTTONS)
            {
                Label lblUpdate = new Label();
                lblUpdate.Text                = "<i class='far fa-save row-icon'></i>";
                lblUpdate.CssClass            = "icon-update";
                lblUpdate.AssociatedControlID = BTN_UPDATE;
                container.Controls.Add(lblUpdate);

                Button btnUpdate = new Button();
                //btnUpdate.CssClass = "updateButton";
                btnUpdate.CssClass    = "row-button";
                btnUpdate.ID          = BTN_UPDATE;
                btnUpdate.Text        = "Update";
                btnUpdate.CommandName = "Update";
                container.Controls.Add(btnUpdate);

                Label lblCanc = new Label();
                lblCanc.Text                = "<i class='fas fa-ban row-icon'></i>";
                lblCanc.CssClass            = "icon-delete";
                lblCanc.AssociatedControlID = BTN_CANC;
                container.Controls.Add(lblCanc);

                Button btnCanc = new Button();
                //btnCanc.CssClass = "otherButton";
                btnCanc.CssClass    = "row-button";
                btnCanc.ID          = BTN_CANC;
                btnCanc.Text        = "Cancel";
                btnCanc.CommandName = "CancelUpdate";
                container.Controls.Add(btnCanc);
            }
            else if (columnType == COMBODATA)
            {
                //if (bindExpression.Equals("compName"))
                //{
                //    Label myLabel = new Label();
                //    myLabel.ID = controlID;
                //    myLabel.DataBinding += new EventHandler(this.lblItem_DataBinding);
                //    holder2.Controls.Add(myLabel);
                //}
                //else

                AjaxControlToolkit.ComboBox combo = new AjaxControlToolkit.ComboBox();
                combo.ID            = controlID;
                combo.CaseSensitive = false;
                if (bindExpression.Equals("EquipTypeName"))
                {
                    combo.AutoPostBack = true;
                    combo.TextChanged += EquipType_Changed;
                }
                else
                {
                    combo.AutoPostBack = false;
                }
                if (bindExpression.Equals("OpNam") && controlID.Equals("comboEdit3"))
                {
                    combo.DropDownStyle = AjaxControlToolkit.ComboBoxStyle.DropDown;
                }
                else
                {
                    combo.DropDownStyle = AjaxControlToolkit.ComboBoxStyle.DropDownList;
                }
                combo.AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.SuggestAppend;
                combo.RenderMode       = AjaxControlToolkit.ComboBoxRenderMode.Block;
                combo.CssClass         = "ajaxCombo";
                if (newer)
                {
                    combo.DataValueField = dropList[0];
                    if (dropList.Count > 1)
                    {
                        combo.DataTextField = dropList[1];
                    }
                }
                else if (dropdownList != null)
                {
                    if (dropdownList.Count > 0)
                    {
                        combo.DataValueField = dropdownList[0].Value;
                        combo.DataTextField  = dropdownList[1].Text;
                        for (int i = 1; i < dropdownList.Count; i++)
                        {
                            combo.Items.Add(dropdownList[i]);
                        }
                    }
                }
                else
                {
                    combo.Items.Clear();
                    foreach (string item in dropList)
                    {
                        combo.Items.Add(item);
                    }
                }
                combo.DataBinding += new EventHandler(combo_DataBinding);
                holder2.Controls.Add(combo);


                holder1.ID += controlID;
                holder2.ID += controlID;
                container.Controls.Add(holder1);
                container.Controls.Add(holder2);
            }
            else if (columnType == CHECKBOX_DATA)
            {
                CheckBox checkBox = new CheckBox();
                checkBox.ID           = controlID;
                checkBox.Enabled      = true;
                checkBox.DataBinding += new EventHandler(checkboxItem_DataBinding);
                holder1.ID           += controlID;
                holder2.ID           += controlID;
                container.Controls.Add(holder1);
                container.Controls.Add(holder2);
                holder2.Controls.Add(checkBox);
            }
            //else if (columnType == NONEDITABLE_DATA)
            //{
            //    holder1.ID += controlID;
            //    holder2.ID += controlID;
            //    Label lblItem = new Label();
            //    lblItem.ID = controlID;

            //    lblItem.DataBinding += new EventHandler(this.lblItem_DataBinding);

            //    lblItem.Attributes["style"] += "cursor:default";
            //    lblItem.Enabled = false;

            //    //lblItem.Width = 100;

            //    //if (!bindExpression.Equals("tonum") && !bindExpression.Equals("fromnum")) {
            //    //    lblItem.DataBinding += new EventHandler(this.lblItem_DataBinding);
            //    //    lblItem.Enabled = false;
            //    //}

            //    container.Controls.Add(holder1);
            //    container.Controls.Add(holder2);
            //    holder1.Controls.Add(lblItem);
            //}
            break;

        case ListItemType.Footer:
            if (container is TableCell && columnType != BUTTONS)
            {
                (container as TableCell).HorizontalAlign = HorizontalAlign.Center;
            }
            PlaceHolder holderA = new PlaceHolder();
            holderA.ID = "holderA";
            PlaceHolder holderB = new PlaceHolder();
            holderB.ID = "holderB";
            if (columnType == DATA)
            {
                TextBox txtInsert = new TextBox();
                txtInsert.ID = controlID;
                txtInsert.Attributes.Add("width", "96%");
                if (bindExpression.Equals("GrpSiz") && controlID.Equals("txtEdit4"))
                {
                    txtInsert.AutoPostBack = true;
                    txtInsert.TextChanged += GrpSiz_Changed;
                }
                else
                {
                    //txtInsert.Attributes.Add("onkeydown", "return (event.keyCode=!13);");
                }
                if (bindExpression.Equals("OpNum"))
                {
                    //txtInsert.Width = 75;
                }
                else if (bindExpression.Equals("PercentAssign"))
                {
                    //txtInsert.Width = 90;
                }
                //if (bindExpression.Equals("tonum") || bindExpression.Equals("fromnum") || bindExpression.Equals("UPA"))
                if (bindExpression.Equals("tonum") || bindExpression.Equals("fromnum") || bindExpression.Equals("UPF") || bindExpression.Equals("level"))
                {
                    txtInsert.Enabled              = false;
                    txtInsert.Attributes["style"] += "cursor:default;";
                    txtInsert.Attributes["style"] += "background-color: #d4d4d4 !important;";
                    txtInsert.Attributes["value"]  = null;
                }


                txtInsert.TabIndex = columnNum;
                //txtInsert.EnableViewState = false;
                holderA.ID += controlID;
                holderB.ID += controlID;
                container.Controls.Add(holderA);
                container.Controls.Add(holderB);
                holderA.Controls.Add(txtInsert);
            }
            else if (columnType == BUTTONS)
            {
                Label lblAdd = new Label();
                lblAdd.Text                = "<i class='fas fa-plus icon-add'></i>";
                lblAdd.CssClass            = "row-add";
                lblAdd.ToolTip             = "add new row";
                lblAdd.AssociatedControlID = BTN_INSERT;
                container.Controls.Add(lblAdd);

                Button btnInsert = new Button();
                btnInsert.CssClass          = "row-button";
                btnInsert.ID                = BTN_INSERT;
                btnInsert.Text              = "Add";
                btnInsert.UseSubmitBehavior = true;


                btnInsert.CommandName = "Insert";
                container.Controls.Add(btnInsert);
            }
            else if (columnType == COMBODATA)
            {
                AjaxControlToolkit.ComboBox combo = new AjaxControlToolkit.ComboBox();
                combo.ID               = controlID;
                combo.DropDownStyle    = AjaxControlToolkit.ComboBoxStyle.DropDown;
                combo.AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.SuggestAppend;
                combo.RenderMode       = AjaxControlToolkit.ComboBoxRenderMode.Block;
                combo.CssClass         = "ajaxCombo";
                //combo.DataBinding += new EventHandler(this.combo_DataBinding);
                if (bindExpression.Equals("EquipTypeName"))
                {
                    combo.AutoPostBack          = true;
                    combo.SelectedIndexChanged += EquipType_Changed;
                }
                else if (bindExpression.Equals("ProdDesc") && controlID.Equals("comboEdit1"))
                {
                    combo.AutoPostBack          = true;
                    combo.DropDownStyle         = AjaxControlToolkit.ComboBoxStyle.DropDownList;
                    combo.SelectedIndexChanged += SelectedProduct_Changed;
                }
                if (newer)
                {
                    combo.DataValueField = dropList[0];
                    if (dropList.Count > 1)
                    {
                        combo.DataTextField = dropList[1];
                    }
                }
                else if (dropdownList != null)
                {
                    if (dropdownList.Count > 0)
                    {
                        combo.DataValueField = dropdownList[0].Value;
                        combo.DataTextField  = dropdownList[1].Text;
                        for (int i = 1; i < dropdownList.Count; i++)
                        {
                            combo.Items.Add(dropdownList[i]);
                        }
                    }
                }
                else
                {
                    foreach (string item in dropList)
                    {
                        combo.Items.Add(item);
                    }
                    if (bindExpression.Equals("ProdDesc") && controlID.Equals("comboEdit1"))
                    {
                        combo.Items.Add("");
                    }
                }
                holderA.ID += controlID;
                holderB.ID += controlID;
                container.Controls.Add(holderA);
                container.Controls.Add(holderB);
                holderB.Controls.Add(combo);
            }
            else if (columnType == CHECKBOX_DATA)
            {
                CheckBox checkBox = new CheckBox();
                checkBox.ID      = controlID;
                checkBox.Enabled = true;
                holderA.ID      += controlID;
                holderB.ID      += controlID;
                container.Controls.Add(holderA);
                container.Controls.Add(holderB);
                holderB.Controls.Add(checkBox);
            }
            else if (columnType == NONEDITABLE_DATA)
            {
                holderA.ID += controlID;
                holderB.ID += controlID;
                Label lblItem = new Label();
                lblItem.ID = controlID;

                //lblItem.Attributes["style"] += "cursor:default";

                //lblItem.Width = 100;

                //if (!bindExpression.Equals("tonum") && !bindExpression.Equals("fromnum")) {
                //    lblItem.DataBinding += new EventHandler(this.lblItem_DataBinding);
                //    lblItem.Enabled = false;
                //}

                container.Controls.Add(holderA);
                container.Controls.Add(holderB);
                holderA.Controls.Add(lblItem);
            }
            break;
        }
    }
예제 #20
0
    //protected void gridRouting_RowEditing(object sender, GridViewEditEventArgs e)
    //{

    //}
    //protected void gridRouting_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    //{

    //}
    //protected void gridRouting_RowUpdating(object sender, GridViewUpdateEventArgs e)
    //{

    //}

    protected override void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            AjaxControlToolkit.ComboBox ddl = (AjaxControlToolkit.ComboBox)e.Row.Cells[1].Controls[1].Controls[0];

            FillAllowableComponentsDdl(ddl);
            Button btnToClick = e.Row.Cells[0].FindControl(GridViewTemplate.BTN_INSERT) as Button;

            if (btnToClick != null)
            {
                for (int columnIndex = 1; columnIndex <
                     e.Row.Cells.Count; columnIndex++)
                {
                    try
                    {
                        Control control = e.Row.Cells[columnIndex].FindControl(TEXT_BOX_IDS[columnIndex]);
                        if (control is TextBox)
                        {
                            (control as TextBox).Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                        }
                        else if (control is AjaxControlToolkit.ComboBox)
                        {
                            TextBox textBox = (control as AjaxControlToolkit.ComboBox).FindControl(control.ID + "_TextBox") as TextBox;
                            if (textBox != null)
                            {
                                textBox.Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                            }
                        }
                    }
                    catch (Exception) { }
                }
            }
        }
        //NEED TO DISABLE IF LEVEL !=1
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Button btnToClick  = e.Row.Cells[0].FindControl(GridViewTemplate.BTN_EDIT) as Button;
            Button btnToDelete = e.Row.Cells[0].FindControl(GridViewTemplate.BTN_DELETE) as Button;
            string tooltip     = "Double-click to edit component";
            //IF LEVEL IS >1 DISABLE EDITING AND HIDE BTNS
            Label curLevel  = (Label)e.Row.Cells[4].Controls[0].Controls[0];
            Label curParent = (Label)e.Row.Cells[5].Controls[0].Controls[0];

            if (!curLevel.Text.Equals("") & !curParent.Text.Equals(""))
            {
                if (Double.Parse(curLevel.Text) >= 1 & curParent.Text.Equals("True"))
                {
                    e.Row.Cells[1].CssClass += "parent";
                }
                if (Double.Parse(curLevel.Text) > 1)
                {
                    btnToClick.Enabled  = false;
                    btnToDelete.Enabled = false;

                    btnToDelete.Parent.Controls[1].Visible = false;
                    btnToClick.Parent.Controls[3].Visible  = false;
                }
                else
                {
                    if (((e.Row.RowState & DataControlRowState.Edit) > 0))
                    {
                        btnToClick = e.Row.Cells[0].FindControl(GridViewTemplate.BTN_UPDATE) as Button;
                        tooltip    = "Double-click to update component";
                    }
                    if (btnToClick != null)
                    {
                        string btnJavascript = ClientScript.GetPostBackClientHyperlink(
                            btnToClick, "");
                        for (int columnIndex = 1; columnIndex <
                             e.Row.Cells.Count; columnIndex++)
                        {
                            // Add the column index as the event argument parameter
                            string js = btnJavascript.Insert(btnJavascript.Length - 2,
                                                             columnIndex.ToString());
                            // Add this javascript to the onclick Attribute of the cell
                            e.Row.Cells[columnIndex].Attributes["ondblclick"] = js;
                            // Add a cursor style to the cells
                            e.Row.Cells[columnIndex].Attributes["style"] +=
                                "cursor:pointer;";
                            e.Row.Cells[columnIndex].ToolTip = tooltip;
                            //NEED TO HANDLE COMBOBOX
                            if (((e.Row.RowState & DataControlRowState.Edit) > 0))
                            {
                                try
                                {
                                    Control control = e.Row.Cells[columnIndex].FindControl(TEXT_BOX_IDS[columnIndex]);
                                    if (control is TextBox)
                                    {
                                        (control as TextBox).Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                                    }
                                    else if (control is AjaxControlToolkit.ComboBox)
                                    {
                                        TextBox textBox = (control as AjaxControlToolkit.ComboBox).FindControl(control.ID + "_TextBox") as TextBox;
                                        if (textBox != null)
                                        {
                                            textBox.Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                                        }
                                    }
                                }
                                catch (Exception) { }
                            }
                        }
                    }
                }
            }
            else
            {
            }
        }
    }
예제 #21
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        int id = Convert.ToInt32(Session["ticketid"]);
        int id1;
        id1 = Convert.ToInt32(Session["clientid"]);

        Hashtable dataforvalue = new Hashtable();
        bll compview = new bll();
        if (id != 0)
        {
            dataforvalue = compview.selcomp(id);

            commaDelimited = dataforvalue["fullstring"].ToString();

            string[] year = commaDelimited.Split(new char[] { ',' });
            foreach (string month in year)
            {
                d[k] = month;
                k++;
            }

            int a = id1;
            bll noof = new bll();
            int w, z, tn, cn, tc = 0, cc = 0;
            Hashtable datano = new Hashtable();
            datano = noof.noofrows(a);
            w = Convert.ToInt32(datano["noofrows"]);
            tn = Convert.ToInt32(datano["nooftxt"]);
            cn = Convert.ToInt32(datano["noofcb"]);
            dynamicTextBoxes = new TextBox[tn];
            dynamiccombobox = new AjaxControlToolkit.ComboBox[cn];
            Table tbl = new Table();
            for (z = 0; z < w; z++)
            {
                bll cuscontrol = new bll();
                Hashtable data = new Hashtable();
                data = cuscontrol.ccomp(a, z);

                TableRow tr = new TableRow();
                TableCell td0 = new TableCell();
                tr.CssClass = "table_tr";
                TableCell td1 = new TableCell();
                int field = Convert.ToInt32(data["id"]);

                if (data["control"].ToString() == "Combobox")
                {
                    Response.Write(System.Environment.NewLine);
                    lbl = new System.Web.UI.WebControls.Label();
                    lbl.ID = (2 * z).ToString();

                    lbl.Text = data["label"].ToString();
                    lbl.CssClass = "ajxtxt";

                    td0.Controls.Add(lbl);
                    cb = new AjaxControlToolkit.ComboBox();
                    cb.ID = (2 * z + 1).ToString();
                    cb.Enabled = false;
                    cb.CssClass = "ajxtxt";
                    cb.ForeColor = Color.Black;
                    dynamiccombobox[cc] = cb;
                    cc++;
                    td1.Controls.Add(cb);

                    if (data["value"].ToString() == "get")
                    {
                        string q = data["dbname"].ToString();
                        bll reff = new bll();

                        Type t = reff.GetType();

                        Type[] paramTypes = new Type[1];
                        paramTypes[0] = Type.GetType("System.Int32");

                        MethodInfo CosineInfo = t.GetMethod(q, paramTypes);

                        Object[] parameters = new Object[1];
                        parameters[0] = a;
                        Object returnVal = CosineInfo.Invoke(reff, parameters);

                        string commaDelimited1 = returnVal.ToString();
                        string[] year1 = commaDelimited1.Split(new char[] { ',' });
                        foreach (string month1 in year1)
                        {
                            cb.Items.Add(month1);
                        }
                        cb.SelectedItem.Text = d[2 * z + 1];

                    }
                    else
                    {
                        string returnVal = data["value"].ToString();

                        string commaDelimited2 = returnVal.ToString();
                        string[] year2 = commaDelimited2.Split(new char[] { ',' });
                        foreach (string month2 in year2)
                        {
                            cb.Items.Add(month2);

                        }
                        cb.SelectedItem.Text = d[2 * z + 1];
                    }
                    tr.Cells.Add(td0);
                    tr.Cells.Add(td1);
                    tbl.Rows.Add(tr);
                }

                else
                {
                    int y = 10;
                    lbl = new System.Web.UI.WebControls.Label();
                    lbl.ID = (2 * z).ToString();
                    lbl.Text = data["label"].ToString();

                    lbl.CssClass = "ajxtxt";

                    td0.Controls.Add(lbl);
                    TextBox txt = new TextBox();
                    txt.ID = (2 * z + 1).ToString();
                    // txt.Text = data["value"].ToString();
                    txt.Enabled = false;
                    txt.CssClass = "ajxtxt";
                    txt.Text = d[2 * z + 1];
                    td1.Controls.Add(txt);
                    dynamicTextBoxes[tc] = txt;
                    tc++;
                }
                tr.Cells.Add(td0);
                tr.Cells.Add(td1);
                tbl.Rows.Add(tr);
            }
            PlaceHolder1.Controls.Add(tbl);

        }
    }
예제 #22
0
    public void ClickOnEnter(string btnClientId, AjaxControlToolkit.ComboBox outerControl)
    {
        string script = "doClick('" + btnClientId + "',event)";

        outerControl.Attributes.Add("onKeyPress", script);
    }