示例#1
0
 protected void AspNetPager1_PageChanged(object sender, System.EventArgs e)
 {
     System.Collections.Generic.List <SmPurchaseplanModel>        listArray = this.purchaseplan.GetListArray(" where flowstate = 1");
     System.Collections.Generic.IEnumerable <SmPurchaseplanModel> source    = listArray.Skip((this.AspNetPager1.CurrentPageIndex - 1) * this.AspNetPager1.PageSize).Take(this.AspNetPager1.PageSize);
     this.DataBindPurchaseplan(source.ToList <SmPurchaseplanModel>());
     this.SetCheckedBoxStatus();
 }
示例#2
0
    private void DataBindPurchase()
    {
        System.Collections.Generic.List <PurchaseModel> purchses = this.GetPurchses();
        int currentPageIndex = this.AspNetPager1.CurrentPageIndex;

        this.AspNetPager1.RecordCount = purchses.Count;
        System.Collections.Generic.IEnumerable <PurchaseModel> source = purchses.Skip(this.AspNetPager1.PageSize * (currentPageIndex - 1)).Take(this.AspNetPager1.PageSize);
        GridViewUtility.DataBind <PurchaseModel>(this.gvwPurchase, source.ToList <PurchaseModel>());
    }
示例#3
0
 protected void btnRepeal_Click(object sender, System.EventArgs e)
 {
     try
     {
         System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
         if (this.hfldEmailID.Value.Contains("["))
         {
             list = JsonHelper.GetListFromJson(this.hfldEmailID.Value);
         }
         else
         {
             list.Add(this.hfldEmailID.Value);
         }
         string msg = "撤回成功";
         for (int i = 0; i < list.Count; i++)
         {
             Mail byId = this.mailService.GetById(list[i].ToString());
             if (!byId.IsReaded)
             {
                 byId.MailType  = "R";
                 byId.InputDate = System.DateTime.Now.AddSeconds((double)i);
                 this.mailService.Update(byId);
                 string strToMailId = byId.ToMailId;
                 list[i].ToString();
                 System.Collections.Generic.IEnumerable <Mail> source = this.mailService.AsEnumerable <Mail>();
                 if (!string.IsNullOrEmpty(strToMailId))
                 {
                     source =
                         from m in source
                         where m.ToMailId.Contains(strToMailId) && m.MailType == "I"
                         select m;
                 }
                 System.Collections.Generic.List <Mail> list2 = source.ToList <Mail>();
                 if (list2.Count > 0)
                 {
                     this.mailService.Delete(list2[0].MailId);
                 }
             }
             else
             {
                 msg = "已读取邮件不能撤回!";
             }
         }
         base.RegisterShow("系统提示", msg);
         this.BindGv();
     }
     catch
     {
         base.RegisterShow("系统提示", "撤回失败");
         this.BindGv();
     }
 }
        /// <summary>
        /// Make a Dictionary<string, int> Dictionary
        /// </summary>
        /// <param name="keyEnums"></param>
        /// <returns></returns>
        private Dictionary <string, int> MakeDictionary <T>(System.Collections.Generic.IEnumerable <T> keyEnums)
        {
            var keyNames = keyEnums.ToList();
            var keyCodes = keyEnums.Cast <int>().ToList();

            // Add key names and codes to dictionary ..
            for (int i = 0; i < keyNames.Count; i++)
            {
                this.keyEnum.Add(keyNames[i].ToString(), keyCodes[i]);
            }

            return(this.keyEnum);
        }
示例#5
0
        public override System.Collections.Generic.IEnumerable <TEntity> AddRange(System.Collections.Generic.IEnumerable <TEntity> entities)
        {
            if (entities == null)
            {
                throw new System.ArgumentNullException("entities");
            }
            var items = entities.ToList();

            foreach (var entity in items)
            {
                _data.Add(entity);
            }
            return(items);
        }
示例#6
0
 public void ShouldProcessAnOrder()
 {
     using (OrderRepo orderRepo = new OrderRepo(new OrderDetailRepo()))
     {
         System.Collections.Generic.IEnumerable <Order> orders1 = orderRepo.GetAll();
         Assert.Equal(1, orders1.ToList().Count);
         _repo.Purchase(0);
         using (OrderRepo orderRepo1 = new OrderRepo(new OrderDetailRepo()))
         {
             System.Collections.Generic.IEnumerable <Order> orders2 = orderRepo1.GetAll();
             Assert.Equal(2, orders2.ToList().Count);
         }
     }
 }
示例#7
0
        /// <summary>
        /// Applies the specified changes to the collection.
        /// <locDE><para />Wendet die angegebenen Änderungen auf die Collection an.</locDE>
        /// </summary>
        /// <typeparam name="T">The type of the T.<locDE><para />Generischer Datentyp T.</locDE></typeparam>
        /// <param name="items">The items.<locDE><para />Die Elemente.</locDE></param>
        /// <param name="predicate">The predicate.<locDE><para />Das Prädikat.</locDE></param>
        public static void Apply <T>(this System.Collections.Generic.IEnumerable <T> items, Action <T> predicate)
        {
            if (null == items || null == predicate)
            {
                return;
            }

            // .ToList() saves us from "collection was modified" exception
            // .ToList() bewahrt uns vor einer "Collection wurde verändert" Ausnahme.
            foreach (var item in items.ToList())
            {
                predicate(item);
            }
        }
示例#8
0
    private DataTable GetUsers(MembershipUserCollection muc)
    {
        listPager.ItemCount = muc.Count;
        int from = (listPager.CurrentIndex - 1) * listPager.PageSize;
        int to   = listPager.PageSize;

        DataTable dt = new DataTable();

        dt.Columns.Add("UserName", Type.GetType("System.String"));
        dt.Columns.Add("ProviderUserKey", Type.GetType("System.Guid"));
        dt.Columns.Add("LastActivityDate", Type.GetType("System.DateTime"));
        dt.Columns.Add("IsApproved", Type.GetType("System.Boolean"));
        dt.Columns.Add("IsLockedOut", Type.GetType("System.Boolean"));

        foreach (MembershipUser mu in muc)
        {
            DataRow dr = dt.NewRow();
            dr["UserName"]         = mu.UserName;
            dr["ProviderUserKey"]  = mu.ProviderUserKey;
            dr["LastActivityDate"] = mu.LastActivityDate;
            dr["IsApproved"]       = mu.IsApproved;
            dr["IsLockedOut"]      = mu.IsLockedOut;
            dt.Rows.Add(dr);
        }

        System.Collections.Generic.IEnumerable <DataRow> rows    = dt.AsEnumerable().Skip(from).Take(to);
        System.Collections.Generic.List <DataRow>        newRows = rows.ToList <DataRow>();

        DataTable newDt = new DataTable();

        newDt.Columns.Add("UserName", Type.GetType("System.String"));
        newDt.Columns.Add("ProviderUserKey", Type.GetType("System.Guid"));
        newDt.Columns.Add("LastActivityDate", Type.GetType("System.DateTime"));
        newDt.Columns.Add("IsApproved", Type.GetType("System.Boolean"));
        newDt.Columns.Add("IsLockedOut", Type.GetType("System.Boolean"));

        foreach (DataRow row in newRows)
        {
            DataRow dr2 = newDt.NewRow();
            dr2["UserName"]         = row["UserName"];
            dr2["ProviderUserKey"]  = row["ProviderUserKey"];
            dr2["LastActivityDate"] = row["LastActivityDate"];
            dr2["IsApproved"]       = row["IsApproved"];
            dr2["IsLockedOut"]      = row["IsLockedOut"];
            newDt.Rows.Add(dr2);
        }

        return(newDt);
    }
示例#9
0
        /// <summary>
        /// Used to get unknown nested classes that are extending from T.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        private static System.Collections.Generic.List <Type> GetUnknownTypes <T>()
        {
            System.Collections.Generic.IEnumerable <Type> types = from assemblies in System.AppDomain.CurrentDomain.GetAssemblies()
                                                                  from type in assemblies.GetTypes()
                                                                  where (type.IsClass &&
                                                                         (!type.IsGenericType) &&
                                                                         (!type.IsSpecialName) &&
                                                                         (!type.IsSealed) &&
                                                                         (!type.IsAbstract) &&
                                                                         (type.BaseType != null) &&
                                                                         (type.IsSubclassOf(typeof(T))))
                                                                  select type;

            return(types.ToList());
        }
 public TokenContainer(System.Collections.Generic.IEnumerable <TTokenBase> tokens)
 {
     Tokens = tokens.ToList();
 }
示例#11
0
    private new void Init()
    {
        if (this.reply == "1")
        {
            this.btnEdit.Visible      = true;
            this.btnEdit1.Visible     = true;
            this.btnTransmit.Visible  = true;
            this.btnTransmit1.Visible = true;
        }
        else
        {
            this.btnEdit.Visible      = false;
            this.btnEdit1.Visible     = false;
            this.btnTransmit.Visible  = false;
            this.btnTransmit1.Visible = false;
        }
        this.BindDrop();
        this.Visiable();
        Mail byId = this.mailService.GetById(this.mailId);

        if (!string.IsNullOrEmpty(byId.AnnexId))
        {
            try
            {
                string text = ConfigHelper.Get("Mail").ToString();
                System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(base.Server.MapPath(text) + "/" + byId.AnnexId.ToString());
                System.IO.FileInfo[]    files         = directoryInfo.GetFiles();
                System.IO.FileInfo[]    array         = files;
                for (int i = 0; i < array.Length; i++)
                {
                    System.IO.FileInfo fileInfo = array[i];
                    base.RegisterScript(string.Concat(new object[]
                    {
                        "uploadbind('<a  class=\"link\" target=_blank  href=\"../../Common/DownLoad.aspx?path=",
                        HttpUtility.UrlEncode(string.Concat(new string[]
                        {
                            text,
                            "/",
                            byId.AnnexId.ToString(),
                            "/",
                            fileInfo.Name
                        })),
                        "\"  >",
                        fileInfo.Name,
                        "</a>','",
                        System.Math.Round((double)fileInfo.Length / 1024.0 / 1024.0, 2, System.MidpointRounding.AwayFromZero),
                        "M');"
                    }));
                }
                goto IL_1D9;
            }
            catch
            {
                this.TRUpload.Visible = false;
                goto IL_1D9;
            }
        }
        this.TRUpload.Visible = false;
IL_1D9:
        if (byId != null)
        {
            string value = byId.MailContent.ToString();
            this.txtContent.Value = value;
            if (!string.IsNullOrEmpty(byId.MailName))
            {
                this.lblTitle.Text = byId.MailName;
            }
            else
            {
                this.lblTitle.Text = "【无主题】";
            }
            this.lblFrom.Text = byId.MailFromYhmc.v_xm;
            this.lblTo.Text   = byId.AllMailTo.TrimEnd(new char[]
            {
                ','
            });
            if (string.IsNullOrEmpty(byId.AllCopyto))
            {
                this.TRMailTo.Visible = false;
            }
            else
            {
                this.TRMailTo.Visible = true;
            }
            this.lblMailTo.Text = byId.AllCopyto.TrimEnd(new char[]
            {
                ','
            });
            this.lblDate.Text = byId.InputDate.ToString();
            if (this.reply == "1")
            {
                if (!byId.IsReaded)
                {
                    byId.IsReaded = true;
                    byId.ReadTime = new System.DateTime?(System.DateTime.Now);
                    this.mailService.Update(byId);
                }
                string strToMailId = byId.ToMailId;
                System.Collections.Generic.IEnumerable <Mail> source = this.mailService.AsEnumerable <Mail>();
                if (!string.IsNullOrEmpty(strToMailId))
                {
                    source =
                        from m in source
                        where m.ToMailId.Contains(strToMailId) && m.MailType == "O"
                        select m;
                }
                System.Collections.Generic.List <Mail> list = source.ToList <Mail>();
                if (list.Count > 0)
                {
                    list[0].IsReaded = true;
                    list[0].ReadTime = new System.DateTime?(System.DateTime.Now);
                    this.mailService.Update(list);
                }
            }
        }
    }
示例#12
0
 public static System.Collections.Generic.IList <T> ToReadOnly <T>(this System.Collections.Generic.IEnumerable <T> enumerable)
 {
     return(new System.Collections.ObjectModel.ReadOnlyCollection <T>(enumerable.ToList <T>()));
 }
示例#13
0
 public PagingDataSet(System.Collections.Generic.IEnumerable <T> entities) : base(entities.ToList <T>())
 {
 }