예제 #1
0
        protected void grdRoles_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            GridViewDataColumn dc   = grdRoles.Columns["RoleName"] as GridViewDataColumn;
            string             user = grdRoles.GetRowValues(grdRoles.EditingRowVisibleIndex, "UserName").ToString();
            ASPxCheckBoxList   cbl  = grdRoles.FindEditRowCellTemplateControl(dc, "chlRoles") as ASPxCheckBoxList;

            foreach (ListEditItem le in cbl.Items)
            {
                if (le.Selected)
                {
                    if (!Roles.IsUserInRole(user, le.Text))
                    {
                        Roles.AddUserToRole(user, le.Text);
                    }
                }
                else
                {
                    if (Roles.IsUserInRole(user, le.Text))
                    {
                        Roles.RemoveUserFromRole(user, le.Text);
                    }
                }
            }
            e.Cancel = true;
            grdRoles.CancelEdit();
        }
예제 #2
0
        public static void ValidateLength(string fieldname, int length, object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
        {
            ASPxGridView grid = (ASPxGridView)sender;

            if (fieldname == "ArrivalActual")
            {
                GridViewDataColumn col1           = grid.Columns["ArrivalActual"] as GridViewDataColumn;
                ASPxCheckBoxList   chkListArrival = grid.FindEditRowCellTemplateControl(col1, "ASPxCheckBoxListArrival") as ASPxCheckBoxList;
                if (chkListArrival.SelectedItem == null)
                {
                    e.RowError = "Fill all the fields";
                }
            }

            if (fieldname == "DepartureActual")
            {
                GridViewDataColumn col1             = grid.Columns["DepartureActual"] as GridViewDataColumn;
                ASPxCheckBoxList   chkListDeparture = grid.FindEditRowCellTemplateControl(col1, "ASPxCheckBoxListDeparture") as ASPxCheckBoxList;
                if (chkListDeparture.SelectedItem == null)
                {
                    e.RowError = "Fill all the fields";
                }
            }
            if (e.NewValues[fieldname] == null)
            {
                AddError(e.Errors, grid.Columns[fieldname],
                         fieldname + " cannot be null.");
            }
            if (e.NewValues[fieldname] != null &&
                e.NewValues[fieldname].ToString().Length < length)
            {
                AddError(e.Errors, grid.Columns[fieldname],
                         fieldname + " must be at least " + length + " characters long.");
            }
        }
예제 #3
0
        protected override WebControl CreateViewModeControlCore()
        {
            ASPxCheckBoxList control = new ASPxCheckBoxList();

            control.ClientEnabled = false;
            return(control);
        }
예제 #4
0
 protected override void ReadValueCore()
 {
     base.ReadValueCore();
     if (PropertyValue is XPBaseCollection)
     {
         ASPxCheckBoxList control = ViewEditMode == DevExpress.ExpressApp.Editors.ViewEditMode.Edit ? Editor : InplaceViewModeEditor;
         if (control == null)
         {
             return;
         }
         control.SelectedIndexChanged -= new EventHandler(Control_SelectedIndexChanged);
         checkedItems = (XPBaseCollection)PropertyValue;
         XPCollection dataSource = new XPCollection(checkedItems.Session, MemberInfo.ListElementType);
         IModelClass  classInfo  = application.Model.BOModel.GetClass(MemberInfo.ListElementTypeInfo.Type);
         if (checkedItems.Sorting.Count > 0)
         {
             dataSource.Sorting = checkedItems.Sorting;
         }
         else if (!String.IsNullOrEmpty(classInfo.DefaultProperty))
         {
             dataSource.Sorting.Add(new SortProperty(classInfo.DefaultProperty, DevExpress.Xpo.DB.SortingDirection.Ascending));
         }
         control.DataSource = dataSource;
         control.TextField  = classInfo.DefaultProperty;
         control.ValueField = classInfo.KeyProperty;
         control.ValueType  = classInfo.TypeInfo.KeyMember.MemberType;
         control.DataBind();
         control.UnselectAll();
         foreach (object obj in checkedItems)
         {
             control.Items.FindByValue(objectSpace.GetKeyValue(obj)).Selected = true;
         }
         control.SelectedIndexChanged += new EventHandler(Control_SelectedIndexChanged);
     }
 }
예제 #5
0
 protected void gvxOpperation_RowInserted(object sender, DevExpress.Web.Data.ASPxDataInsertedEventArgs e)
 {
     // insert materials
     try
     {
         int opperationID                       = int.Parse(ViewState ["OpperatioinID"].ToString());
         ASPxDropDownEdit          dd           = (ASPxDropDownEdit)gvxOpperation.FindEditFormTemplateControl("ddMaterails");
         ASPxCheckBoxList          list         = (ASPxCheckBoxList)dd.FindControl("chlMaterails");
         List <OpperationMaterial> opperMatList = new List <OpperationMaterial>();
         foreach (ListEditItem item in list.Items)
         {
             if (item.Selected)
             {
                 opperMatList.Add(new OpperationMaterial()
                 {
                     OpperationID = opperationID, ItemID = int.Parse(item.Value.ToString())
                 });
             }
         }
         OpperationMaterialsRepository oppRepository = new OpperationMaterialsRepository();
         bool result = oppRepository.AddMaterialForOpperations(opperMatList);
     }
     catch (Exception)
     {
     }
 }
    protected void cblSuppliers_DataBound(object sender, EventArgs e)
    {
        ASPxCheckBoxList cbl = sender as ASPxCheckBoxList;
        GridViewEditItemTemplateContainer container = cbl.NamingContainer as GridViewEditItemTemplateContainer;

        object ean13Value = DataBinder.Eval(container.DataItem, "EAN13");
        string ean13      = (ean13Value == null) ? String.Empty : ean13Value.ToString();

        string[] idString   = ean13.Split(',');
        int[]    supplierID = new int[idString.Length];

        for (int i = 0; i < idString.Length; i++)
        {
            if (!int.TryParse(idString[i], out supplierID[i]))
            {
                return;
            }
        }

        foreach (ListEditItem Item in cbl.Items)
        {
            if (supplierID.Contains <int>((int)Item.Value))
            {
                Item.Selected = true;
            }
        }
    }
        protected void UserProfileDataSource_Inserting(object sender, SqlDataSourceCommandEventArgs e)
        {
            int              visibleindex = MainGridView.FocusedRowIndex;
            ASPxGridView     sousgrid     = MainGridView.FindDetailRowTemplateControl(visibleindex, "ThemeGridSite") as ASPxGridView;
            ASPxCheckBoxList listTiers    = sousgrid.FindEditFormTemplateControl("chkListTiers") as ASPxCheckBoxList;
            string           ListTiers    = "";

            foreach (string val in listTiers.SelectedValues)
            {
                ListTiers += val + ";";
            }

            ASPxCheckBoxList listJour = sousgrid.FindEditFormTemplateControl("chkListJourn") as ASPxCheckBoxList;
            string           ListJour = "";

            foreach (string val in listJour.SelectedValues)
            {
                ListJour += val + ";";
            }

            ASPxCheckBoxList listaffichmontant = sousgrid.FindEditFormTemplateControl("ASPxCheckAfficherMontant") as ASPxCheckBoxList;
            string           affichmontant     = "0";

            foreach (string val in listaffichmontant.SelectedValues)
            {
                affichmontant = val;
            }

            ASPxCheckBoxList listaccederdate = sousgrid.FindEditFormTemplateControl("ASPxCheckAccederDate") as ASPxCheckBoxList;
            string           accederdate     = "0";

            foreach (string val in listaccederdate.SelectedValues)
            {
                accederdate = val;
            }

            //ASPxCheckBoxList listDoc = sousgrid.FindEditFormTemplateControl("chkListDoc") as ASPxCheckBoxList;
            //string ListDoc = "";
            //foreach (string val in listDoc.SelectedValues)
            //{
            //    ListDoc += val + ";";
            //}

            e.Command.Parameters[2].Value = ListJour;
            e.Command.Parameters[3].Value = ListTiers;

            e.Command.Parameters[5].Value = affichmontant;
            e.Command.Parameters[6].Value = accederdate;
            //e.Command.Parameters[4].Value = ListDoc;
        }
예제 #8
0
        protected void chlRoles_Load(object sender, EventArgs e)
        {
            ASPxCheckBoxList cbl = sender as ASPxCheckBoxList;

            if (grdRoles.IsEditing)
            {
                //get all Roles
                cbl.DataSource = Roles.GetAllRoles().Where(r => !r.Equals("Master") && !r.Equals("Amerinode"));
                cbl.DataBind();
                //get User
                string user = grdRoles.GetRowValues(grdRoles.EditingRowVisibleIndex, "UserName").ToString();
                //mark the Roles the User belongs to
                foreach (ListEditItem le in cbl.Items)
                {
                    le.Selected = Roles.IsUserInRole(user, le.Text);
                }
            }
        }
예제 #9
0
        void Control_SelectedIndexChanged(object sender, EventArgs e)
        {
            ASPxCheckBoxList control = (ASPxCheckBoxList)sender;

            foreach (ListEditItem item in control.Items)
            {
                object obj = objectSpace.GetObjectByKey(MemberInfo.ListElementTypeInfo.Type, item.Value);
                if (item.Selected)
                {
                    checkedItems.BaseAdd(obj);
                }
                else
                {
                    checkedItems.BaseRemove(obj);
                }
            }
            OnControlValueChanged();
            objectSpace.SetModified(CurrentObject);
        }
예제 #10
0
 protected void gvxOpperation_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
 {
     try
     {
         int opperationID      = int.Parse(ViewState["OpperatioinID"].ToString());
         ASPxDropDownEdit dd   = (ASPxDropDownEdit)gvxOpperation.FindEditFormTemplateControl("ddMaterails");
         ASPxCheckBoxList list = (ASPxCheckBoxList)dd.FindControl("chlMaterails");
         dsOpperationMaterails.SelectParameters[0].DefaultValue = opperationID.ToString();
         DataView  SelectedItemView = (DataView)dsOpperationMaterails.Select(new DataSourceSelectArguments());
         DataTable SelectedItems    = SelectedItemView.ToTable();
         foreach (DataRow item in SelectedItems.Rows)
         {
             list.Items.FindByValue(item[0].ToString()).Selected = true;
         }
     }
     catch (Exception)
     {
     }
 }
    protected void gridViewData_RowUpdating(object sender, ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView     grid = sender as ASPxGridView;
        ASPxCheckBoxList cbl  = grid.FindEditRowCellTemplateControl(grid.Columns["EAN13"] as GridViewDataColumn, "cblSuppliers") as ASPxCheckBoxList;

        string ean13 = String.Empty;

        if (cbl.SelectedItems.Count > 0)
        {
            foreach (int supplierID in cbl.SelectedValues)
            {
                ean13 += supplierID.ToString() + ',';
            }
            ean13 = ean13.Trim(',');
        }
        e.NewValues["EAN13"] = ean13;

        e.Cancel = true; //COMMENT THIS LINE TO ALLOW UPDATING
    }
예제 #12
0
        protected void gvxOpperation_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
        {
            try
            {
                int opperationID      = int.Parse(e.Keys[0].ToString());
                ASPxDropDownEdit dd   = (ASPxDropDownEdit)gvxOpperation.FindEditFormTemplateControl("ddMaterails");
                ASPxCheckBoxList list = (ASPxCheckBoxList)dd.FindControl("chlMaterails");
                dsOpperationMaterails.SelectParameters[0].DefaultValue = opperationID.ToString();
                dsOpperationMaterails.DeleteParameters[0].DefaultValue = opperationID.ToString();
                dsOpperationMaterails.InsertParameters[0].DefaultValue = opperationID.ToString();
                DataView  SelectedItemView = (DataView)dsOpperationMaterails.Select(new DataSourceSelectArguments());
                DataTable SelectedItems    = SelectedItemView.ToTable();
                foreach (DataRow item in SelectedItems.Rows)
                {
                    if (!list.Items.FindByValue(item[0].ToString()).Selected)
                    {
                        dsOpperationMaterails.DeleteParameters[1].DefaultValue = item[0].ToString();
                        dsOpperationMaterails.Delete();
                        list.Items.Remove(list.Items.FindByValue(item[0].ToString()));
                    }
                    else
                    {
                        list.Items.Remove(list.Items.FindByValue(item[0].ToString()));
                    }
                }

                foreach (ListEditItem item in list.Items)
                {
                    if (item.Selected)
                    {
                        dsOpperationMaterails.InsertParameters[1].DefaultValue = item.Value.ToString();
                        dsOpperationMaterails.Insert();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
    private void Set_functionlist(ASPxCheckBoxList ck, string list)
    {
        LogCallMethod(true);
         string[] listfunction = list.Split(',');
         ck.DataBind();
         for (int i = 0; i < listfunction.Length; i++)
         {
             foreach (ListEditItem var in ck.Items)
             {
                 if (var.Value.ToString() == listfunction[i])
                     var.Selected = true;
             }

         }
         LogCallMethod(false);
    }
예제 #14
0
    public static void BindData(ASPxCheckBoxList cbl, DevExpress.Xpo.Session s, string objectname, string filter = "", params object[] parameter)
    {
        try
        {
            DynamicDataTableClassInfo classInfo = dynamicClasses[objectname];

            if (classInfo != null)
            {
                XPServerCollectionSource ds = new XPServerCollectionSource(s, dynamicClasses[objectname], CriteriaOperator.Parse(filter, parameter));
                cbl.DataSource = ds;
            }
            else
                throw new Exception(string.Format("Đối tượng {0} không tìm thấy trong database. Nếu không có dữ liệu hiển thị thì XPOProfiles để xem điều kiện lọc đúng chưa", objectname));
        }
        catch (Exception ex)
        {
            SiAuto.Main.LogColored(Color.Red, "Loi BindData:" + ex.ToString());
            throw ex;
        }
    }