예제 #1
0
        private void loadData(string table)
        {
            string strWhere = string.Empty;

            if (!string.IsNullOrEmpty(Request["CODE_S"]))
            {
                strWhere = strWhere + " and t1.Code like '%" + Request["CODE_S"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request["CNNAME_S"]))
            {
                strWhere = strWhere + " and t1.name like '%" + Request["CNNAME_S"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request["ENABLED_S"]))
            {
                strWhere = strWhere + " and t1.enabled='" + Request["ENABLED_S"] + "'";
            }
            switch (table)
            {
            case "base_insplicense":
            case "base_inspinvoice":
            case "base_booksdata":
            case "sys_declarationcar":
                strWhere = string.Empty;
                strWhere = GetSearch(table);
                break;
            }
            Sql.Base_blend_web bw = new Sql.Base_blend_web();
            DataTable          dt = bw.LoaData(table, strWhere, "", "", ref totalProperty, Convert.ToInt32(Request["start"]),
                                               Convert.ToInt32(Request["limit"]));
            string json = JsonConvert.SerializeObject(dt, iso);

            Response.Write("{rows:" + json + ",total:" + totalProperty + "}");
            Response.End();
        }
예제 #2
0
        public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action,
                                                                 JObject json_formdata, string table)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            Sql.Base_blend_web bc = new Sql.Base_blend_web();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                for (int j = 0; j < dtExcel.Columns.Count; j++)
                {
                    stringList.Add(dtExcel.Rows[i][j].ToString());
                }
                ////代码                           //名字
                //string code = stringList[0]; string name = stringList[1];
                ////是否启用                                         //备注
                //string enabled = stringList[2] == "是" ? "1" : "0"; string remark = stringList[3];

                ////启用日期
                //string startdate = json_formdata.Value<string>("STARTDATE");
                ////停用日期
                //string enddate = json_formdata.Value<string>("ENDDATE");

                //string formdata = "{\"CODE\":\"" + code + "\",\"NAME\":\"" + name + "\",\"ENABLED\":\"" + enabled + "\",\"REMARK\":\"" + remark + "\",\"STARTDATE\":\"" + startdate + "\",\"ENDDATE\":\"" + enddate + "\"}";
                string  formdata = sw.importValue(json_formdata, table, stringList);
                JObject json     = (JObject)JsonConvert.DeserializeObject(formdata);
                if (bc.check_repeat(table, json) > 0 || string.IsNullOrEmpty(json.Value <string>("CODE")))
                {
                    errorlines.Add(i + 2);
                }
                else
                {
                    bc.insertTable(table, json);
                    count = count + 1;
                }
                stringList.Clear();
            }
            successinsert.Add(count);
            returndic.Add(1, successinsert);
            returndic.Add(2, errorlines);
            return(returndic);
        }
예제 #3
0
        public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action,
                                                                 JObject json_formdata, string table)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            Sql.Base_blend_web bc = new Sql.Base_blend_web();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                for (int j = 0; j < dtExcel.Columns.Count; j++)
                {
                    stringList.Add(dtExcel.Rows[i][j].ToString());
                }
                string  formdata = sw.importValue(json_formdata, table, stringList);
                JObject json     = (JObject)JsonConvert.DeserializeObject(formdata);
                if (bc.check_repeat(table, json) > 0 || string.IsNullOrEmpty(json.Value <string>("CODE")))
                {
                    errorlines.Add(i + 2);
                }
                else
                {
                    bc.insertTable(table, json);
                    count = count + 1;
                }
                stringList.Clear();
            }
            successinsert.Add(count);
            returndic.Add(1, successinsert);
            returndic.Add(2, errorlines);
            return(returndic);
        }
예제 #4
0
        private void save_category(string formdata, string action)
        {
            JObject json = (JObject)JsonConvert.DeserializeObject(formdata);

            Sql.Base_blend_web bc       = new Sql.Base_blend_web();
            string             response = "";
            string             table    = "";

            switch (action)
            {
            case "save_category":
                table = "category";
                break;

            case "save_chapter":
                table = "base_declhschapter";
                break;

            case "save_smallclass":
                table = "base_declhsclass";
                break;
            }


            if (bc.check_repeat(table, json) > 0)
            {
                response = "{\"success\":\"4\"}";
            }
            else
            {
                int i = bc.insertTable(table, json);
                if (i > 0)
                {
                    response = "{\"success\":\"5\"}";
                }
            }

            Response.Write(response);
            Response.End();
        }
예제 #5
0
        public void loaddatacategory()
        {
            string strWhere = string.Empty;

            if (!string.IsNullOrEmpty(Request["CODE_S_category"]))
            {
                strWhere = strWhere + " and t1.code like '%" + Request["CODE_S_category"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request["CNNAME_S_category"]))
            {
                strWhere = strWhere + " and t1.name like '%" + Request["CNNAME_S_category"] + "%'";
            }
            string table = "category";

            Sql.Base_blend_web bw = new Sql.Base_blend_web();
            DataTable          dt = bw.LoaData(table, strWhere, "", "", ref totalProperty, Convert.ToInt32(Request["start"]),
                                               Convert.ToInt32(Request["limit"]));
            string json = JsonConvert.SerializeObject(dt, iso);

            Response.Write("{rows:" + json + ",total:" + totalProperty + "}");
            Response.End();
        }
예제 #6
0
        private void export(string table)
        {
            string strWhere        = string.Empty;
            string combo_ENABLED_S = Request["combo_ENABLED_S"];

            if (combo_ENABLED_S == "null")
            {
                combo_ENABLED_S = String.Empty;
            }
            if (!string.IsNullOrEmpty(Request["CODE_S"]))
            {
                strWhere = strWhere + " and t1.Code like '%" + Request["CODE_S"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request["CNNAME_S"]))
            {
                strWhere = strWhere + " and t1.name like '%" + Request["CNNAME_S"] + "%'";
            }
            if (!string.IsNullOrEmpty(combo_ENABLED_S))
            {
                strWhere = strWhere + " and t1.enabled='" + combo_ENABLED_S + "'";
            }
            switch (table)
            {
            case "base_insplicense":
            case "base_inspinvoice":
            case "base_booksdata":
                strWhere = string.Empty;
                strWhere = Getexport(table);
                break;
            }
            if (table == "base_booksdata")
            {
                strWhere = strWhere + " order by t1.trade asc";
            }
            else
            {
                strWhere = strWhere + " order by t1.code asc";
            }

            Sql.Base_blend_web           bc = new Sql.Base_blend_web();
            Switch_helper_Base_blend_web sc = new Switch_helper_Base_blend_web();
            DataTable    dt   = bc.ExportTable(table, strWhere);
            HSSFWorkbook book = sc.createExcel(dt, table);

            try
            {
                // 输出Excel
                string filename = sc.get_excelname(table) + ".xls";
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Server.UrlEncode(filename)));
                Response.Clear();

                MemoryStream ms = new MemoryStream();
                book.Write(ms);
                Response.BinaryWrite(ms.GetBuffer());
                Response.End();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #7
0
        private void save(string table, string formdata)
        {
            JObject json = (JObject)JsonConvert.DeserializeObject(formdata);

            Sql.Base_blend_web bc = new Sql.Base_blend_web();
            //返回界面值
            string response = "";

            if (string.IsNullOrEmpty(json.Value <string>("ID")))
            {
                if (json.Value <string>("ENABLED") == "1")
                {
                    if (bc.check_repeat(table, json) > 0)
                    {
                        response = "{\"success\":\"4\"}";
                    }
                    else
                    {
                        int i = bc.insertTable(table, json);
                        if (i > 0)
                        {
                            response = "{\"success\":\"5\"}";
                        }
                    }
                }
                else
                {
                    int i = bc.insertTable(table, json);
                    if (i > 0)
                    {
                        response = "{\"success\":\"5\"}";
                    }
                }
            }
            else
            {
                if (json.Value <string>("ENABLED") == "1")
                {
                    if (bc.update_check_repeat(table, json) > 0)
                    {
                        response = "{\"success\":\"4\"}";
                    }
                    else
                    {
                        //获取修改之前的datatable
                        DataTable dt = bc.getBeforeChangeData(table, json);

                        int i = bc.updataTable(table, json);
                        if (i > 0)
                        {
                            //插入修改信息到表内
                            int j = bc.insertAlterRecordTable(dt, table, json);
                            if (j > 0)
                            {
                                response = "{\"success\":\"5\"}";
                            }
                        }
                    }
                }
                else
                {
                    //获取修改之前的datatable
                    DataTable dt = bc.getBeforeChangeData(table, json);

                    int i = bc.updataTable(table, json);
                    if (i > 0)
                    {
                        //插入修改信息到表内
                        int j = bc.insertAlterRecordTable(dt, table, json);
                        if (j > 0)
                        {
                            response = "{\"success\":\"5\"}";
                        }
                    }
                }
            }
            Response.Write(response);
            Response.End();
        }