public ActionResult AgencyAdd()
        {
            var model = new T_Agency();
            var bll   = new T_AgencyBll();

            if (Request.QueryString["AgencyId"] != null)
            {
                model = bll.GetModel(int.Parse(Request.QueryString["AgencyId"].ToString()));
            }
            else
            {
                model.IsShow = 1;
            }
            return(View(model));
        }
        public Dictionary <string, object> IntoAgency()
        {
            T_AgencyBll bll      = new T_AgencyBll();
            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"); //调用自定义方法

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

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

                    model.AgencyName     = dr[i][0].ToString();
                    model.CreateUserId   = ManageProvider.Provider.Current().UserId;
                    model.CreateUserName = ManageProvider.Provider.Current().Account;
                    model.CreateTime     = DateTime.Now;
                    model.IsDelete       = 0;
                    model.IsShow         = 1;
                    model.SortCode       = 0;
                    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 }
            });
        }
        public Dictionary <string, object> Add(T_Agency model)
        {
            model.CreateUserId   = ManageProvider.Provider.Current().UserId;
            model.CreateUserName = ManageProvider.Provider.Current().Account;
            model.CreateTime     = DateTime.Now;

            if (model.AgencyId > 0)
            {
                var model1 = bll.GetModel(model.AgencyId);
                model1.AgencyName = model.AgencyName;
                model1.SortCode   = model.SortCode;
                model1.IsShow     = model.IsShow;


                if (bll.Update(model1) > 0)
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", "1" }
                    });
                }
                else
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", "0" }
                    });
                }
            }
            else
            {
                if (bll.Add(model) > 0)
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", "1" }
                    });
                }
                else
                {
                    return(new Dictionary <string, object>
                    {
                        { "code", "0" }
                    });
                }
            }
        }
 public int Update(T_Agency model)
 {
     return(T_AgencyDal.GetInstance().Update(model));
 }
 public int Add(T_Agency model)
 {
     return(T_AgencyDal.GetInstance().Add(model));
 }