Beispiel #1
0
        protected void treelstMaterialUnits_NodeUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            //Init data
            //collectData();
            string keystr = e.Keys[treelstMaterialUnits.KeyFieldName].ToString();

            ASPxComboBox cboCodeUnit = treelstMaterialUnits.FindEditCellTemplateControl(treelstMaterialUnits.Columns["Code"]
                                                                                        as TreeListDataColumn, "cboCodeUnit") as ASPxComboBox;
            TreeListEditCellTemplateContainer templateContainer = (TreeListEditCellTemplateContainer)cboCodeUnit.NamingContainer;
            TreeListNode node = templateContainer.TreeList.FindNodeByKeyValue(templateContainer.NodeKey);

            // Delete old node and add new node
            //ViewMaterialUnitConstruction oldNode = (ViewMaterialUnitConstruction)node.DataItem;
            //List<ViewMaterialUnitConstruction> ChildrenOfOldNode = getAllChildOfNode(oldNode);
            //ViewMaterialUnitConstruction newNode = settingNewNodeUnit(oldNode.ParentMaterialMaterialUnitId,
            //   long.Parse(e.NewValues["NumRequired"].ToString()));
            //XPCollection<ViewMaterialUnitConstruction> table = MaterialUnitConstruction;
            //table.Remove(oldNode);
            //table.Add(newNode);
            ////Change children's parents
            //foreach (ViewMaterialUnitConstruction v in ChildrenOfOldNode)
            //{
            //    v.ParentMaterialMaterialUnitId = newNode.MaterialMaterialUnitHierachyId;
            //}

            ////update to database
            //materialBLO.updateMaterialUnitOnTree(oldNode, newNode, KeyValue);

            //MaterialUnitConstruction = table;
            //treelstMaterialUnits.DataSource = table;
            treelstMaterialUnits.DataBind();
            e.Cancel = true;
            treelstMaterialUnits.CancelEdit();
        }
    public void InstantiateIn(Control container)
    {
        ASPxLabel label = new ASPxLabel();

        label.ID = "label";
        TreeListEditCellTemplateContainer templateContainer = container as TreeListEditCellTemplateContainer;

        label.Text  = templateContainer.Text;
        label.Width = System.Web.UI.WebControls.Unit.Percentage(100);
        label.ClientSideEvents.Click = "function(s, e){onCellClick(" + templateContainer.NodeKey + ", '" + templateContainer.Column.FieldName + "'); }";
        container.Controls.Add(label);
    }
Beispiel #3
0
        protected void cboCodeUnit_Init(object sender, EventArgs e)
        {
            ASPxComboBox comboBox = (ASPxComboBox)sender;

            //comboBox.DataSource = this.toolBOL.getToolUnitList();
            comboBox.DataBind();

            TreeListEditCellTemplateContainer templateContainer = (TreeListEditCellTemplateContainer)comboBox.NamingContainer;

            if (templateContainer.NodeKey != null)
            {
                TreeListNode node = templateContainer.TreeList.FindNodeByKeyValue(templateContainer.NodeKey);
                //ViewToolUnitConstruction dataItem = (ViewToolUnitConstruction)node.DataItem;
                //comboBox.Value = dataItem.Code;
            }
        }
Beispiel #4
0
        protected void treelstMaterialUnits_NodeValidating(object sender, TreeListNodeValidationEventArgs e)
        {
            #region Init some objest
            ASPxTreeList treelst     = sender as ASPxTreeList;
            ASPxComboBox cboCodeUnit = treelstMaterialUnits.FindEditCellTemplateControl(treelstMaterialUnits.Columns["Code"]
                                                                                        as TreeListDataColumn, "cboCodeUnit") as ASPxComboBox;
            TreeListEditCellTemplateContainer templateContainer = (TreeListEditCellTemplateContainer)cboCodeUnit.NamingContainer;
            string selectedCode = cboCodeUnit.SelectedItem != null?cboCodeUnit.SelectedItem.Value.ToString() : null;

            TreeListNode node;
            //List<ViewMaterialUnitConstruction> table = MaterialUnitConstruction.ToList<ViewMaterialUnitConstruction>();
            //if (table == null)
            //    table = new List<ViewMaterialUnitConstruction>();
            #endregion

            #region Check Require NumberRequired
            if (selectedCode == null || selectedCode == "")
            {
                e.NodeError = String.Format("Bắt buộc chọn đơn vị tính!");
                return;
            }
            #endregion

            #region Check Require NumberRequired
            if (e.NewValues["NumRequired"] == null)
            {
                e.NodeError = String.Format("Bắt buộc nhập số lượng!");
                return;
            }
            #endregion

            #region Check Exist MaterialUnitCode ---- Mode Edit Node
            if (templateContainer.NodeKey != null)
            {
                node = templateContainer.TreeList.FindNodeByKeyValue(templateContainer.NodeKey);
                //ViewMaterialUnitConstruction dataItem = (ViewMaterialUnitConstruction)node.DataItem;
                //string oldCode = dataItem.Code;
                ////Check Exist Code before
                //if (table.Count > 0 && treelst.IsEditing && selectedCode != oldCode)
                //{

                //    if (!isValidCodeEditting(node, selectedCode))
                //    {
                //        e.NodeError = String.Format("Đơn vị tính {0} đã được chọn! Vui lòng chọn cái khác", selectedCode);
                //    }
                //}
            }
            #endregion

            #region Check Exist MaterialUnitCode ---- Mode Add Node
            else
            {
                //if (table.Count > 0 && treelst.IsEditing)
                //{
                //    node = templateContainer.TreeList.FindNodeByKeyValue(treelstMaterialUnits.NewNodeParentKey);

                //    if (node.Level == 0)
                //        return;

                //    if (!isValidCodeAdding(node, selectedCode))
                //    {
                //        e.NodeError = String.Format("Đơn vị tính {0} đã được chọn! Vui lòng chọn cái khác", selectedCode);
                //    }
                //}
            }
            #endregion
        }