예제 #1
0
        public Dictionary <string, object> IntoClubActivityInfo()
        {
            C_ClubActivityInfoBll bll = new C_ClubActivityInfoBll();
            string  url      = HttpContext.Current.Request.Form["url"].ToString();
            string  filename = HttpContext.Current.Request.Form["filename"].ToString();
            DataSet ds       = ExportFile.ExcelSqlConnection(HttpContext.Current.Server.MapPath(url), "Info");     //调用自定义方法

            log.Debug(ds.Tables[0].Rows.Count);
            DataRow[] dr           = ds.Tables[0].Select();
            int       successcount = 0;
            int       failcount    = 0;

            for (int i = 0; i < dr.Length; i++)
            {
                try
                {
                    C_ClubActivityInfo model = new C_ClubActivityInfo();

                    model.ClubName           = dr[i][0].ToString();
                    model.ClubActivityTypeId = int.Parse(dr[i][1].ToString());
                    model.ActivityDate       = DateTime.Parse(dr[i][2].ToString());
                    model.ActivityCost       = int.Parse(dr[i][3].ToString());
                    model.CreateUserId       = ManageProvider.Provider.Current().UserId;
                    model.CreateUserName     = ManageProvider.Provider.Current().Account;
                    model.CreateTime         = DateTime.Now;
                    model.IsDelete           = 0;
                    model.IsShow             = 1;
                    if (bll.Add(model) > 0)
                    {
                        successcount++;
                    }
                    else
                    {
                        failcount++;
                    }
                }
                catch (Exception)
                {
                    failcount++;
                }
            }
            return(new Dictionary <string, object>
            {
                { "code", "1" },
                { "successcount", successcount },
                { "failcount", failcount },
                { "filename", filename },
                { "count", dr.Length }
            });
        }
예제 #2
0
        public Dictionary <string, object> Add(C_ClubActivityInfo model)
        {
            C_ClubActivityInfoBll bll = new C_ClubActivityInfoBll();


            if (model.ClubActivityInfoId > 0)
            {
                var oldmodel = bll.GetModel(model.ClubActivityInfoId);
                model.CreateUserId   = oldmodel.CreateUserId;
                model.CreateUserName = oldmodel.CreateUserName;
                model.CreateTime     = oldmodel.CreateTime;
                if (bll.Update(model) > 0)
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", 1 }
                    });
                }
                else
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", 0 }
                    });
                }
            }
            else
            {
                model.CreateUserId   = ManageProvider.Provider.Current().UserId;
                model.CreateUserName = ManageProvider.Provider.Current().Account;
                model.CreateTime     = DateTime.Now;
                if (bll.Add(model) > 0)
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", 1 }
                    });
                }
                else
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", 0 }
                    });
                }
            }
        }