Exemplo n.º 1
0
        void InitUserConfig()
        {
            #region 列名
            FileStream   fs = null;
            StreamReader sr = null;
            try
            {
                string ReakCfgPath = FunCommon.GetDir() + "/Config/GridViewColumnHeaders.cfg";

                fs = new FileStream(ReakCfgPath, FileMode.Open);
                sr = new StreamReader(fs, Encoding.Default);
                GlobalData.GridViewColumnHeaderTable = sr.ReadToEnd();
                GlobalData.GridViewColumnHeaderTable = GlobalData.GridViewColumnHeaderTable.Replace("\r\n", "");
                sr.Close();
                fs.Close();
            }
            catch
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }
Exemplo n.º 2
0
        public static string CreateJson(string columns, object[] values)
        {
            try
            {
                string   JsonStr = "{";
                string[] c       = FunCommon.CutToArry(columns, ',');
                for (int i = 0; i < c.Length; i++)
                {
                    if (i < values.Length)
                    {
                        JsonStr += "\"" + c[i] + "\":\"" + values[i].ToString() + "\",";
                    }
                    else
                    {
                        JsonStr += "\"" + c[i] + "\":\"" + "" + "\",";
                    }
                }

                if (JsonStr.Length > 1)
                {
                    JsonStr = JsonStr.Remove(JsonStr.Length - 1);
                }

                JsonStr += "}";

                return(JsonStr);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        void ReadCfg(string CfgPath)
        {
            FileStream   fs = null;
            StreamReader sr = null;

            try
            {
                string ReakCfgPath = FunCommon.GetDir() + "/Config/SearchBoxCtrler/" + CfgPath + ".cfg";

                fs = new FileStream(ReakCfgPath, FileMode.Open);
                sr = new  StreamReader(fs, Encoding.Default);
                string Realte = sr.ReadLine();

                SearchColumns = FunCommon.CutToArry(Realte, ',');

                sr.Close();
                fs.Close();
            }
            catch
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }
Exemplo n.º 4
0
 public static void SetColumnHeader(ref DataTable source)
 {
     for (int i = 0; i < source.Columns.Count; i++)
     {
         string OldColumnName = source.Columns[i].ColumnName;
         string NewColumnName = FunCommon.GetJsonValue(GlobalData.GridViewColumnHeaderTable, OldColumnName);
         if (!String.IsNullOrEmpty(NewColumnName))
         {
             source.Columns[i].ColumnName = NewColumnName;
         }
     }
 }
Exemplo n.º 5
0
        public static void Update(string Table, int ID, string Column, object[] Values)
        {
            string SqlStr = "update " + Table + " set ";

            string[] columns = FunCommon.CutToArry(Column, ',');
            for (int i = 0; i < columns.Length; i++)
            {
                SqlStr += columns[i] + " = '" + Values[i] + "',";
            }
            SqlStr  = SqlStr.Remove(SqlStr.Length - 1);
            SqlStr += " Where ID = '" + ID + "'";

            Exec(SqlStr);
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request       = System.Web.HttpContext.Current.Request;
            string      OrderCode     = request["OrderCode"];
            string      CarType       = request["CarType"];
            string      Worker        = request["Worker"];
            string      TransportType = request["TransportType"];

            int    SortFlag  = Convert.ToInt32(request["SortFlag"]);
            int    PageSize  = Convert.ToInt32(request["rows"]);
            int    PageIndex = Convert.ToInt32(request["page"]);
            string method    = request["method"];

            sort         = request["sort"];
            order        = request["order"];
            string where = "";
            if (!string.IsNullOrEmpty(OrderCode))
            {
                where += " and  订单编码 like '%" + OrderCode + "%' ";
            }

            if (!string.IsNullOrEmpty(CarType))
            {
                where += " and 车型ID = '" + CarType + "' ";
            }

            if (!string.IsNullOrEmpty(Worker))
            {
                where += " and ( op_name = '" + Worker + "' or Expr1 = '" + Worker + "' or Expr2 = '" + Worker + "'or Expr3 = '" + Worker + "' or Expr4 = '" + Worker + "')";
            }

            if (!string.IsNullOrEmpty(TransportType))
            {
                where += " and 订单类型 = '" + TransportType + "' ";
            }

            if (string.IsNullOrWhiteSpace(method))
            {
                sort  = request["sort"];
                order = request["order"];
                int       totalcount = 0;
                int       StartIndex = PageSize * (PageIndex - 1) + 1;
                int       EndIndex   = StartIndex + PageSize - 1;
                DataTable resTable   = null;
                resTable = TransportHistory_BLL.getTable(PageSize, PageIndex, StartIndex, EndIndex, sort, order, where, out totalcount);

                string JsonStr = FunCommon.DataTableToJson2(totalcount, resTable);
                context.Response.ContentType = "text/plain";

                context.Response.Write(JsonStr);
                context.Response.End();
            }
            else
            {
                //导出excel

                int       totalcount = 0;
                DataTable resTable2  = TransportHistory_BLL.getTableExcel(sort, order, where, out totalcount);
                string    JsonStr    = "[]";
                try
                {
                    //ExcelHelper.ExportDTtoExcel(resTable2, "HeaderText", HttpContext.Current.Request.MapPath("~/App_Data/发运历史报表.xlsx"));
                    string fileName = HttpContext.Current.Request.MapPath("~/App_Data/发运历史报表.xlsx");
                    string err      = "";
                    AsposeExcelTools.DataTableToExcel2(resTable2, fileName, out err);
                    string ss = "true";
                    if (err.Length < 1)
                    {
                        ss = "true";
                    }
                    else
                    {
                        ss = "false";
                    }


                    JsonStr = ss;
                }
                catch
                {
                    JsonStr = "false";
                }
                context.Response.ContentType = "jsons";

                context.Response.Write(JsonStr);
                context.Response.End();
            }
        }