Esempio n. 1
0
 protected void dsCurComment_Selecting(object sender, Microsoft.AspNet.EntityDataSource.EntityDataSourceSelectingEventArgs e)
 {
     if (Assignment != null)
     {
         e.DataSource.Where = String.Format("it.WFAssignId = {0}", Assignment.WFAssignId);
     }
 }
Esempio n. 2
0
        protected void dsLoc_Selecting(object sender, Microsoft.AspNet.EntityDataSource.EntityDataSourceSelectingEventArgs e)
        {
            eCAR3Entities pContext = new eCAR3Entities();

            // We need constants for these!
            List <String> pLocs = LocTreeCache.GetCreateLocsForUser(User.UserId, 0x0002);

            if (pLocs == null)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            int i = 0;

            // This works to get all of them
            foreach (string pLoc in pLocs)
            {
                if (i > 0)
                {
                    sb.Append(",");
                }

                sb.Append("'" + pLoc + "'");
                i++;
            }

            e.DataSource.Where = string.Format("it.RowKey in {{{0}}}", sb.ToString());
        }
Esempio n. 3
0
        protected void GridDetailDataSource_Selecting(object sender, Microsoft.AspNet.EntityDataSource.EntityDataSourceSelectingEventArgs e)
        {
            GridDataItem parentItem     = ((GridNestedViewItem)e.DataSource.NamingContainer).ParentItem;
            int          hierarchyIndex = parentItem != null ? parentItem.ItemIndex : -1;

            if (hierarchyIndex == -1)
            {
                e.Cancel = true;
                return;
            }

            MetaTable masterMetaTable = GridDataSource.GetTable();
            MetaTable detailMetaTable = e.DataSource.GetTable();

            StringBuilder sb = new StringBuilder();

            sb.Append(Helpers.PersianSearchDataSourceHelpers.GetValidUniCodeQuery(e.DataSource.Where));
            if (masterMetaTable.ForeignKeyColumnsNames != string.Empty)
            {
                //Many to One relation
                foreach (MetaColumn column in detailMetaTable.PrimaryKeyColumns)
                {
                    foreach (string name in masterMetaTable.ForeignKeyColumnsNames.Split(','))
                    {
                        string        columnName     = ((MetaForeignKeyColumn)masterMetaTable.GetColumn(name)).ForeignKeyNames.Where(n => n == name + "." + column.Name).FirstOrDefault();
                        GridTableView ownerTableView = ((GridNestedViewItem)e.DataSource.NamingContainer).OwnerTableView;
                        if (!ownerTableView.DataKeyNames.Contains(columnName))
                        {
                            continue;
                        }
                        if (sb.Length > 0)
                        {
                            sb.Append(" AND ");
                        }
                        sb.AppendFormat("it.{0} = '{1}'", column.Name, ownerTableView.DataKeyValues[hierarchyIndex][columnName]);
                        //break;
                    }
                }
            }
            //else
            //{
            //One to Many relation
            foreach (MetaColumn col in detailMetaTable.Columns)
            {
                if (col is MetaForeignKeyColumn)
                {
                    MetaForeignKeyColumn column = (MetaForeignKeyColumn)col;
                    if (column.ParentTable.Name == masterMetaTable.Name)
                    {
                        int primarykeyindex = 0;                        // in relations witch has mor than one foreign key column
                        foreach (string name in column.ForeignKeyNames) //maybe
                        {
                            GridTableView ownerTableView = ((GridNestedViewItem)e.DataSource.NamingContainer).OwnerTableView;
                            string        columnName     = name;//.Split('.')[1];
                            //if (!ownerTableView.DataKeyNames.Contains(columnName))    //maybe spel of foreignkey in child table does not equla to primary key in parrent table
                            //    continue;
                            switch (masterMetaTable.PrimaryKeyColumns[primarykeyindex].ColumnType.Name)
                            {
                            case "Int16":
                            case "Int32":
                            case "Int64":
                                if (sb.Length > 0)
                                {
                                    sb.Append(" AND ");
                                }
                                sb.AppendFormat("it.{0} = {1}", name, ownerTableView.DataKeyValues[hierarchyIndex][masterMetaTable.PrimaryKeyColumns[primarykeyindex].Name]);          //its depond on our chance witch is the orders of foeign key and parimary in master table should be equal
                                break;

                            default:
                                if (sb.Length > 0)
                                {
                                    sb.Append(" AND ");
                                }
                                sb.AppendFormat("it.{0} = '{1}'", name, ownerTableView.DataKeyValues[hierarchyIndex][masterMetaTable.PrimaryKeyColumns[primarykeyindex].Name]);          //its depond on our chance witch is the orders of foeign key and parimary in master table should be equal
                                break;
                            }
                            primarykeyindex++;
                            //break;
                        }

                        break;
                    }
                }
            }
            //}

            e.DataSource.Where = sb.ToString();
        }
Esempio n. 4
0
 protected void GridDataSource_Selecting(object sender, Microsoft.AspNet.EntityDataSource.EntityDataSourceSelectingEventArgs e)
 {
     e.DataSource.Where = Helpers.PersianSearchDataSourceHelpers.GetValidUniCodeQuery(e.DataSource.Where);
 }
Esempio n. 5
0
 protected void paymankarDatasource_Selecting(object sender, Microsoft.AspNet.EntityDataSource.EntityDataSourceSelectingEventArgs e)
 {
 }