Ejemplo n.º 1
0
 public string mytest()
 {
     try
     {
         string s = string.Empty;
         //FileStream fs = new FileStream(Server.MapPath("~/Uploadxls/test.txt"), FileMode.OpenOrCreate);
         //StreamWriter sw = new StreamWriter(fs);
         ////开始写入
         //sw.Write("Hello World!!!!");
         ////清空缓冲区
         //sw.Flush();
         ////关闭流
         //sw.Close();
         //fs.Close();
         DataTable dt = new DataTable();
         pbxdatasourceDataContext con = new pbxdatasourceDataContext();
         var q = con.custom.Where(a => a.Id > 0);
         dt = LinqToDataTable.LINQToDataTable(q);
         s  = Excell11(dt);
         return(s);
     }
     catch (Exception ex)
     {
         return(ex.ToString());
     }
 }
Ejemplo n.º 2
0
        public string GetDistrict()
        {
            string    s          = string.Empty;
            int       Parent_id  = Convert.ToInt32(Request.Form["RegionId"].ToString());
            DataTable dt         = new DataTable();
            string    RegionName = Request.Form["RegionName"].ToString();

            model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
            var q = context.AreaTable.Where(a => a.Parent_id == Parent_id);

            dt = LinqToDataTable.LINQToDataTable(q);
            s += "<option value=''>请选择</option>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (RegionName == dt.Rows[i]["Region_name"].ToString())
                {
                    s += "<option value='" + dt.Rows[i]["Region_id"] + "' selected='selected' >" + dt.Rows[i]["Region_name"] + "</option>";
                }
                else
                {
                    s += "<option value='" + dt.Rows[i]["Region_id"] + "'>" + dt.Rows[i]["Region_name"] + "</option>";
                }
            }
            return(s);
        }
        /// <summary>
        /// 获取国家下拉列表
        /// </summary>
        /// <param name="countryName"></param>
        /// <param name="Country"></param>
        /// <returns></returns>
        public string GetCountrylist(string countryName, string Country)
        {
            string    s  = string.Empty;
            DataTable dt = new DataTable();

            model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
            s += "<option value=''>请选择</option>";
            if (countryName != "")
            {
                //var q = from c in context.customsCountry where c.countryName.Contains(countryName) || c.countryNo.Contains(countryName) select c;
                var q = from c in context.customsCountry where c.countryName.Contains(countryName) || c.countryNo.Contains(countryName) || context.fun_getPY(c.countryName).Contains(countryName) select c;
                dt = LinqToDataTable.LINQToDataTable(q.OrderBy(a => a.countryNo));
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    s += "<option value='" + dt.Rows[i]["countryNo"] + "'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>";
                }
            }
            else
            {
                dt = DbHelperSQL.Query(@"select * from customsCountry order by countryNo").Tables[0];
                if (Country == "")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        s += "<option value='" + dt.Rows[i]["countryNo"] + "'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>";
                    }
                }
                else
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (Country.Contains(dt.Rows[i]["countryNo"].ToString()))
                        {
                            s += "<option value='" + dt.Rows[i]["countryNo"] + "' selected='selected'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>";
                        }
                        else
                        {
                            s += "<option value='" + dt.Rows[i]["countryNo"] + "'>" + dt.Rows[i]["countryName"] + "-" + dt.Rows[i]["countryNo"] + "</option>";
                        }
                    }
                }
            }


            return(s);
        }