/// <summary> /// 根据下载的TXT文档过滤后创建成语txt /// </summary> private void createWordTxt() { using (StreamReader sr = new StreamReader(Application.StartupPath + "\\成语大全(31648个成语解释).Txt", System.Text.Encoding.Default)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { //如果读出一行不是空字符串 if (line.Trim() != "") { var arr = Regex.Split(line, "拼音"); //0功能>1URL>2请求方法>3请求body var word = arr[0].Trim(); if (word.Length == 4) { CSHelper.saveTextFile(word, "成语列表", "txt", true); } } } } }
private void button1_Click(object sender, EventArgs e) { string template = @" delete from premission where id={0}; INSERT INTO premission(id, auto_created, CODE, NAME, premission_type, parent_id) SELECT {0}, 1, '{1}', '{2}', 1, {5} FROM dummy WHERE NOT EXISTS (SELECT 1 FROM premission WHERE id = {0}); delete from t_menu where id={0}; INSERT INTO t_menu(id, auto_created, CODE, menu_name, icon_class, parent_id, state, url, premission_id, `group`, sort) SELECT {0}, 1, '{1}', '{2}', 'icon-list-ul', {5}, {6}, '{3}', {0}, '', {4} FROM dummy WHERE NOT EXISTS (SELECT 1 FROM t_menu WHERE id = {0}); INSERT INTO t_role_menu(id, VERSION, role_id, menu_id) SELECT {0} + id, 0, id, {0} FROM t_role WHERE tenant_type = 'club' AND NOT EXISTS(SELECT 1 FROM t_role_menu WHERE id = {0} + t_role.id);"; int i = 1; List <PMenu> root = new List <PMenu>(); PMenu p1 = new PMenu() { id = -436477463, code = "report-sales", name = "销售收入报表", parent_id = 0, url = null, sort = 90000, state = 0 }; p1.subMenu = new List <Menu>(); Menu m1 = new Menu() { id = -4364774630 - i, code = "report-sales-ticketSale", name = "门票销售情况统计表", parent_id = p1.id, url = "#!/ticketSale/", sort = p1.sort + i, state = 1 }; i++; Menu m2 = new Menu() { id = -4364774630 - i, code = "report-sales-posbillOneLook", name = "账单一览表", parent_id = p1.id, url = "#!/posbillOneLook/", sort = p1.sort + i, state = 1 }; i++; Menu m3 = new Menu() { id = -4364774630 - i, code = "report-sales-returnPosbill", name = "账单调整日志表", parent_id = p1.id, url = "#!/returnPosbill/", sort = p1.sort + i, state = 1 }; i++; Menu m4 = new Menu() { id = -4364774630 - i, code = "report-sales-operaterIncomeAcount", name = "各收银员收款汇总报表", parent_id = p1.id, url = "#!/operaterIncomeAcount/", sort = p1.sort + i, state = 1 }; i++; Menu m5 = new Menu() { id = -4364774630 - i, code = "report-sales-productSaleDetail", name = "商品销售明细表", parent_id = p1.id, url = "#!/productSaleDetail/", sort = p1.sort + i, state = 1 }; i++; p1.subMenu.Add(m1); p1.subMenu.Add(m2); p1.subMenu.Add(m3); p1.subMenu.Add(m4); p1.subMenu.Add(m5); i += 1000; PMenu p2 = new PMenu() { id = -436477463 - i, code = "report-mem", name = "会员管理报表", parent_id = 0, url = null, sort = 95000, state = 0 }; p2.subMenu = new List <Menu>(); Menu n1 = new Menu() { id = -4364774630 - i, code = "report-mem-newMember", name = "新增会员统计报表", parent_id = p2.id, url = "#!/newMember/", sort = p2.sort + i, state = 1 }; i++; Menu n2 = new Menu() { id = -4364774630 - i, code = "report-mem-memCardBalance", name = "会员余额情况统计表", parent_id = p2.id, url = "#!/memCardBalance/", sort = p2.sort + i, state = 1 }; i++; p2.subMenu.Add(n1); p2.subMenu.Add(n2); i += 1000; PMenu p3 = new PMenu() { id = -436477463 - i, code = "report-mem_RC", name = "会员充值与消费报表", parent_id = 0, url = null, sort = 96000, state = 0, }; p3.subMenu = new List <Menu>(); Menu o1 = new Menu() { id = -4364774630 - i, code = "report-mem-memConsumptionDetail", name = "会员消费情况统计表", parent_id = p3.id, url = "#!/memConsumptionDetail/", sort = p3.sort + i, state = 1 }; i++; Menu o2 = new Menu() { id = -4364774630 - i, code = "report-mem-memCardRechargeLog", name = "会员储值情况统计表", parent_id = p3.id, url = "#!/memCardRechargeLog/", sort = p3.sort + i, state = 1 }; i++; p3.subMenu.Add(o1); p3.subMenu.Add(o2); i += 1000; PMenu p4 = new PMenu() { id = -436477463 - i, code = "report-warehouse", name = "库存管理报表", parent_id = 0, url = null, sort = 97000, state = 0 }; i += 1000; PMenu p5 = new PMenu() { id = -436477463 - i, code = "report-reserve", name = "场地预订报表", parent_id = 0, url = null, sort = 98000, state = 0 }; p5.subMenu = new List <Menu>(); Menu q1 = new Menu() { id = -4364774630 - i, code = "report-gymReserveReport", name = "场地预订报表", parent_id = p5.id, url = "#!/gymReserveReport/", sort = p5.sort + i, state = 1 }; i++; Menu q2 = new Menu() { id = -4364774630 - i, code = "report-gymReserveCancleReport", name = "已取消预订报表", parent_id = p5.id, url = "#!/gymReserveCancleReport/", sort = p5.sort + i, state = 1 }; i++; p5.subMenu.Add(q1); p5.subMenu.Add(q2); Menu m6 = new Menu() { id = -4364774630 - i, code = "report-sales-payTypeReport", name = "付款方式汇总表", parent_id = p1.id, url = "#!/payTypeReport/", sort = p1.sort + i, state = 1 }; i++; p1.subMenu.Add(m6); Menu n3 = new Menu() { id = -4364774630 - i, code = "report-mem-memkindCountReport", name = "会籍统计表", parent_id = p2.id, url = "#!/memkindCountReport/", sort = p2.sort + i, state = 1 }; i++; Menu n4 = new Menu() { id = -4364774630 - i, code = "report-mem-memBirthdayReport", name = "会员生日表", parent_id = p2.id, url = "#!/memBirthdayReport/", sort = p2.sort + i, state = 1 }; i++; p2.subMenu.Add(n3); p2.subMenu.Add(n4); Menu o3 = new Menu() { id = -4364774630 - i, code = "report-mem-memCardRechargeTimesReport", name = "卡充次情况统计表", parent_id = p3.id, url = "#!/memCardRechargeTimesReport/", sort = p3.sort + i, state = 1 }; i++; Menu o4 = new Menu() { id = -4364774630 - i, code = "report-mem-memCardDeductTimesReport", name = "次卡扣次统计报表", parent_id = p3.id, url = "#!/memCardDeductTimesReport/", sort = p3.sort + i, state = 1 }; i++; Menu o5 = new Menu() { id = -4364774630 - i, code = "report-mem-memCardTimesReport", name = "卡剩余次数情况统计表", parent_id = p3.id, url = "#!/memCardTimesReport/", sort = p3.sort + i, state = 1 }; i++; p3.subMenu.Add(o3); p3.subMenu.Add(o4); p3.subMenu.Add(o5); i++; Menu m7 = new Menu() { id = -4364774630 - i, code = "report-sales-incomeDetails", name = "收入明细报表(带小计)", parent_id = p1.id, url = "#!/incomeDetails/", sort = p1.sort + i, state = 1 }; i++; p1.subMenu.Add(m7); //销售收入报表 root.Add(p1); //会员管理报表 root.Add(p2); //会员充值与消费报表 root.Add(p3); //库存管理报表 root.Add(p4); //场地预订报表 root.Add(p5); foreach (PMenu item in root) { var str = string.Format(template, item.id, item.code, item.name, item.url, item.sort, item.parent_id, item.state); CSHelper.saveTextFile(str, "menu", "sql", true); if (item.subMenu == null) { continue; } foreach (Menu subItem in item.subMenu) { var str1 = string.Format(template, subItem.id, subItem.code, subItem.name, subItem.url, subItem.sort, subItem.parent_id, subItem.state); CSHelper.saveTextFile(str1, "menu", "sql", true); } } }
private void CreateCSV() { StringBuilder sb = new StringBuilder(); SqlConnection conn = new SqlConnection(CSHelper.sqlconn); const int group = 1000; int total = 0; bool containsTitle = true; try { conn.Open(); string sql = txtSql.Text.Trim(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (containsTitle) { for (int i = 0; i < dr.FieldCount; i++) { if (i == dr.FieldCount - 1) { sb.AppendFormat("{0}", dr.GetName(i).ToString()); containsTitle = false; sb.Append("\n"); } else { sb.AppendFormat("{0},", dr.GetName(i).ToString()); } } } for (int i = 0; i < dr.FieldCount; i++) { if (i == dr.FieldCount - 1) { sb.AppendFormat("{0}", dr.GetValue(i).ToString()); } else { sb.AppendFormat("{0},", dr.GetValue(i).ToString()); } } sb.Append("\n"); total++; UpdateLableText(lblTotal, "生成记录统计:" + total); if (total % group == 0) { if (total == group) { CSHelper.saveTextFile(sb.ToString(), "导出", "csv"); } else { CSHelper.saveTextFile(sb.ToString(), "导出", "csv", true); } sb.Length = 0; } } CSHelper.saveTextFile(sb.ToString(), "导出", "csv", true); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\r" + ex.StackTrace); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } } }