Ejemplo n.º 1
0
        public JsonResult CustomerModify(Ajax.Model.Customer customer, List <CustomerChargeItem> ccItems)
        {
            AjaxResult result = new AjaxResult();

            try
            {
                customer.UpdateTime = DateTime.Now;
                customer.PY         = Pinyin.GetPinyin(customer.Name);
                //对应缴费项
                foreach (CustomerChargeItem ccItem in ccItems)
                {
                    ccItem.ID         = Guid.NewGuid().ToString("N");
                    ccItem.CustomerID = customer.ID;
                }
                new CustomerRule().Modify(customer, ccItems);
                result.Success = true;
                result.Message = "客户信息修改成功。";
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        protected string GetChinesePY(string chineseString)
        {
            Encoding gb2312 = Encoding.GetEncoding("GB2312");
            string   strPY  = Pinyin.GetInitials(chineseString, gb2312);

            return(strPY);
        }
Ejemplo n.º 3
0
        public static Pinyin Convert2Tone5(Pinyin p)
        {
            var index = (int)Enum.Parse(typeof(PYName), p.ToString());
            var tone5 = Tone2tone5[index];

            return(Pinyin.PinyinTable[(int)tone5]);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 计算匹配度权重值
        /// </summary>
        /// <param name="sEngName"></param>
        /// <param name="sChnName"></param>
        /// <returns></returns>
        static int calcWeight(string sEngName, string sChnName)
        {
            //转拼音
            StringBuilder sPinyinName = new StringBuilder();

            for (int i = 0; i < sChnName.Length; i++)
            {
                if (StringHelper.IsChinese(sChnName[i]))
                {
                    sPinyinName.Append(Pinyin.GetPinyin(sChnName[i]) + ' ');
                }
                else
                {
                    sPinyinName.Append(sChnName[i]);
                }
            }

            int iRet = 0;

            //删除括号
            if (sEngName.IndexOf('(') >= 0)
            {
                sEngName = sEngName.Substring(0, sEngName.IndexOf('('));
            }
            if (sChnName.IndexOf('(') >= 0)
            {
                sChnName = sChnName.Substring(0, sChnName.IndexOf('('));
            }
            sEngName = sEngName.Trim().ToLower();
            sChnName = sPinyinName.ToString().Trim().ToLower();
            if (sEngName.Contains(sChnName) || sChnName.Contains(sEngName))
            {
                iRet += 100;
            }

            string[] sArr1 = sEngName.Split(' ');
            string[] sArr2 = sChnName.ToString().Trim().ToLower().Split(' ');
            for (int i = 0; i < sArr1.Count() && i < sArr2.Count(); i++)
            {
                string sitem  = sArr1[i];
                string sitem2 = sArr2[i];
                for (int j = 0; j < sitem.Length && j < sitem2.Length; j++)
                {
                    if (sitem[j] == sitem2[j])
                    {
                        iRet++;
                    }
                }
            }

            if (iRet <= 0)
            {
                return(0);
            }
            if (sArr1.Count() == sArr2.Count())
            {
                iRet += 100;
            }
            return(iRet);
        }
Ejemplo n.º 5
0
        private static bool Load(string path)
        {
            if (LoadDat(path))
            {
                return(true);                   // 尝试加载二进制数据文件
            }
            var sd = new StringDictionary();

            if (!sd.Load(path))
            {
                return(false);                  // 加载字符串文件到字典对象中
            }
            // 将数据放入排序字典中,以便建立Trie
            var dict = new SortedDictionary <string, Pinyin[]>(StrComparer.Default);

            foreach (var p in sd.GetEntries())
            {
                var segs = p.Value.Split(',');      // 词语的每个字的拼音使用逗号分隔
                var pys  = new Pinyin[segs.Length];
                for (int i = 0; i < pys.Length; i++)
                {
                    var index = (int)Enum.Parse(typeof(PYName), segs[i]);
                    pys[i] = Pinyin.PinyinTable[index];
                }

                dict.Add(p.Key, pys);           // 添加中文词条与其对应的拼音
            }
            _trie.Build(dict);
            SaveDat(path, _trie, dict);
            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 绑定下拉列表控件为指定的数据字典列表
        /// </summary>
        /// <param name="combo">下拉列表控件</param>
        /// <param name="dictTypeName">数据字典类型名称</param>
        /// <param name="defaultValue">控件默认值</param>
        public static void BindDictItems(this CustomGridLookUpEdit combo, string dictTypeName, string defaultValue)
        {
            string       displayName = dictTypeName;
            const string valueName   = "值内容";
            const string pinyin      = "拼音码";
            DataTable    dt          = DataTableHelper.CreateTable(string.Format("{0},{1},{2}", displayName, valueName, pinyin));

            Dictionary <string, string> dict = BLLFactory <DictData> .Instance.GetDictByDictType(dictTypeName);

            foreach (string key in dict.Keys)
            {
                DataRow row = dt.NewRow();
                row[displayName] = key;
                row[valueName]   = dict[key];
                row[pinyin]      = Pinyin.GetFirstPY(key);
                dt.Rows.Add(row);
            }

            combo.Properties.ValueMember   = valueName;
            combo.Properties.DisplayMember = displayName;
            combo.Properties.DataSource    = dt;
            combo.Properties.PopulateViewColumns();
            combo.Properties.View.Columns[valueName].Visible = false;
            combo.Properties.View.Columns[displayName].Width = 400;
            combo.Properties.View.Columns[pinyin].Width      = 200;
            combo.Properties.PopupFormMinSize = new System.Drawing.Size(600, 0);

            if (!string.IsNullOrEmpty(defaultValue))
            {
                combo.EditValue = defaultValue;
            }
        }
Ejemplo n.º 7
0
        public List <XElement> withToneXMLRuby(string input, List <XAttribute> tattributes, List <XElement> tproperties, XNamespace w, bool topcolor = false, bool bottomcolor = false, List <string> colors = null)
        //superflous bools to match withpiyinxml type
        {
            List <XElement> tree = new List <XElement>();
            List <Tuple <Chinese, List <Pinyin> > > hzpi = hanziWithPinyin(input);

            foreach (Tuple <Chinese, List <Pinyin> > c in hzpi)
            {
                if (c.Item2.Count == 0)
                {
                    tree.Add(withNone(c.Item1, tattributes, tproperties, w));
                }
                else
                {
                    for (int i = 0; i != c.Item1.Length; i++)
                    {
                        char          chinesechar = c.Item1[i];
                        HashSet <int> tones       = new HashSet <int>();
                        for (int j = 0; j != c.Item2.Count; j++)
                        {
                            Pinyin pinyin = c.Item2[j];
                            if (pinyin[i].HasValue)
                            {
                                tones.Add(pinyin[i].Value.tone);
                            }
                        }

                        tree.Add(withRubyTones(tattributes, tproperties, w, chinesechar.ToString(), tones.ToList(), topcolor, bottomcolor, colors));
                    }
                }
            }

            return(tree);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// WikiPage转换成Document
        /// </summary>
        /// <param name="question">WikiPage</param>
        /// <returns>WikiPage对应的document对象</returns>
        public static Document Convert(WikiPage wikiPage)
        {
            //文档初始权重
            Document doc = new Document();

            //不索引问题审核状态为不通过的、已取消的
            if (wikiPage.AuditStatus != AuditStatus.Fail && wikiPage.IsLogicalDelete != true)
            {
                //索引基本信息
                doc.Add(new Field(WikiIndexDocument.PageId, wikiPage.PageId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                doc.Add(new Field(WikiIndexDocument.Author, wikiPage.Author.ToLower(), Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field(WikiIndexDocument.Title, wikiPage.Title.ToLower(), Field.Store.YES, Field.Index.ANALYZED));
                if (!string.IsNullOrWhiteSpace(wikiPage.Body))
                {
                    string body = wikiPage.Body;
                    if (wikiPage.LastestVersion != null && !string.IsNullOrEmpty(wikiPage.LastestVersion.Body))
                    {
                        body = wikiPage.LastestVersion.Body;
                    }
                    doc.Add(new Field(WikiIndexDocument.Body, HtmlUtility.TrimHtml(body, 0).ToLower(), Field.Store.NO, Field.Index.ANALYZED));
                }
                doc.Add(new Field(WikiIndexDocument.PinYin, Pinyin.GetPinyin(wikiPage.Title.ToLower()), Field.Store.YES, Field.Index.NOT_ANALYZED));
                doc.Add(new Field(WikiIndexDocument.DateCreated, DateTools.DateToString(wikiPage.DateCreated, DateTools.Resolution.MILLISECOND), Field.Store.YES, Field.Index.NOT_ANALYZED));

                //索引问题标签
                foreach (var tag in wikiPage.TagNames)
                {
                    doc.Add(new Field(WikiIndexDocument.Tag, tag.ToLower(), Field.Store.YES, Field.Index.ANALYZED));
                }
                doc.Add(new Field(WikiIndexDocument.CategoryId, wikiPage.SiteCategory.CategoryId.ToString(), Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field(WikiIndexDocument.DateCreated, DateTools.DateToString(wikiPage.DateCreated, DateTools.Resolution.DAY), Field.Store.YES, Field.Index.ANALYZED));
            }

            return(doc);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 汉字转化为拼音首字母
        /// </summary>
        /// <param name="text">汉字</param>
        /// <returns>首字母</returns>
        public static string GetFirstPinyin(string text)
        {
            Encoding gb2312 = Encoding.GetEncoding("GB2312");
            string   s      = Pinyin.ConvertEncoding(text, Encoding.UTF8, gb2312);

            return(Pinyin.GetInitials(s, gb2312).Trim());
        }
    private void Button_Translate_Click(object sender, RoutedEventArgs e)
    {
        AudioUtil.ClickSound();

        try
        {
            if (TextBox_InputMessage.Text != "")
            {
                var str = (e.OriginalSource as Button).Content.ToString();

                switch (str)
                {
                case "中英互译":
                    Translation();
                    break;

                case "简转繁":
                    TextBox_InputMessage.Text = ChineseConverter.ToTraditional(TextBox_InputMessage.Text);
                    break;

                case "繁转简":
                    TextBox_InputMessage.Text = ChineseConverter.ToSimplified(TextBox_InputMessage.Text);
                    break;

                case "转拼音":
                    TextBox_InputMessage.Text = Pinyin.GetString(TextBox_InputMessage.Text, PinyinFormat.WithoutTone);
                    break;
                }
            }
        }
        catch (Exception ex)
        {
            MsgBoxUtil.Exception(ex);
        }
    }
Ejemplo n.º 11
0
        /// <summary>
        /// Ctor: init app-wide singleton.
        /// </summary>
        public SqlDict(ILoggerFactory lf, Mutation mut)
        {
            if (lf != null)
            {
                logger = lf.CreateLogger(GetType().FullName);
            }
            else
            {
                logger = new DummyLogger();
            }
            logger.LogInformation("SQL dictionary initializing...");

            if (mut == Mutation.CHD)
            {
                Assembly a        = typeof(SqlDict).GetTypeInfo().Assembly;
                string   fileName = "ZDO.CHSite.files.other.chd-trg-stops.txt";
                using (Stream s = a.GetManifestResourceStream(fileName))
                    using (StreamReader sr = new StreamReader(s))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line != "")
                            {
                                trgStopWords.Add(line);
                            }
                        }
                    }
            }

            pinyin = new Pinyin();
            index  = new Index(logger, pinyin, trgStopWords);

            logger.LogInformation("SQL dictionary initialized.");
        }
Ejemplo n.º 12
0
        public static string ToPinying(string ChineseStr, string splite = "")
        {
            string pinying = Pinyin.GetPinyin(ChineseStr);
            string Case    = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(pinying);

            return(Case.Replace(" ", ""));
        }
Ejemplo n.º 13
0
        private void button3_Click(object sender, RibbonControlEventArgs e)
        {
            var range = ExcelHelper.SelectRange;

            if (range != null)
            {
                Excel.Range f     = ExcelHelper.App.InputBox("选择放置位置", Type: 8);
                var         start = f.Address.Replace("$", "").Split(':')[0];
                var         data  = range.Cast <Excel.Range>().Select((s, i) =>
                {
                    return(Pinyin.GetInitials(s.Value));
                }).ToList();

                var rows   = range.Rows.Count;
                var cols   = range.Columns.Count;
                var result = new object[rows, cols];
                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < cols; j++)
                    {
                        result[i, j] = data[i];
                    }
                }
                //ws.Range[start].get_Resize(rows, cols).Value2 = s;
                ExcelHelper.Worksheet.Range[start].get_Resize(range.Rows.Count, range.Columns.Count).Value = result;
            }
        }
Ejemplo n.º 14
0
Archivo: Unit.cs Proyecto: lsyuan/ecms
        /// <summary>
        /// 查询付费单位列表json
        /// </summary>
        /// <param name="param"></param>
        /// <param name="unit"></param>
        /// <param name="itemCount"></param>
        /// <returns></returns>
        public List <object> GetSerachJson(EasyUIGridParamModel param, Unit unit, out int itemCount)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,NAME,CASE tu.LEVEL WHEN 1 THEN '计量' else '计时' end as level,timevalue ");
            strSql.Append("FROM T_Unit tu where 1=1 ");
            Dictionary <string, object> paramList = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(unit.Name))
            {
                strSql.Append("and (Name like @Name or PY like @PY)");
                paramList.Add("Name", string.Format("%{0}%", unit.Name));
                paramList.Add("PY", string.Format("%{0}%", Pinyin.GetPinyin(unit.Name)));
            }
            if (unit.Status != null)
            {
                strSql.Append("and Status=@Status ");
                paramList.Add("Status", unit.Status);
            }
            int pageIndex = Convert.ToInt32(param.page) - 1;
            int pageSize  = Convert.ToInt32(param.rows);

            using (DBHelper db = DBHelper.Create())
            {
                string sql = strSql.ToString();
                itemCount = db.GetCount(sql, paramList);
                return(db.GetDynaminObjectList(sql, pageIndex, pageSize, "ID", paramList));
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 修改关键字
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string EditKeyword(KeywordtData input)
        {
            input.KeywordId     = FilterParamters(input.KeywordId);
            input.KeywordTypeId = FilterParamters(input.KeywordTypeId);
            input.Name          = FilterParamters(input.Name);

            var dict = new Dictionary <string, object>
            {
                { "KeywordTypeId", input.KeywordTypeId },
                { "Name", input.Name },
                { "KeywordId", input.KeywordId }
            };
            var valid = ValidateParameters <KeywordtData>(dict);

            if (valid.Length > 0)
            {
                return(valid);
            }

            var keyword = new tb_Keyword
            {
                KeywordId     = int.Parse(input.KeywordId),
                KeywordTypeId = int.Parse(input.KeywordTypeId),
                Name          = input.Name,
                Pinyin        = Pinyin.GetPinyin(input.Name),
            };

            var keywordService = InitKeywordService();

            return(keywordService.Update(keyword));
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="menu"></param>
 /// <returns></returns>
 public JsonResult _Add(Menu_I menu)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(menu.MenuIcon))
         {
             byte[] outputb = Convert.FromBase64String(menu.MenuIcon);
             menu.MenuIcon = Encoding.Default.GetString(outputb);
         }
         menu.MenuCode = Regex.Replace(Pinyin.GetPinyin(menu.MenuName), @"\s", "");
         _MenuFacade.Value.Add(menu);
         var model = (new
         {
             id = menu.ID,
             pId = menu.PerMenuID == Define._TOPPARENTID ? "root" : menu.PerMenuID,
             name = menu.MenuName,
             title = menu.MenuDesc,
             menucode = menu.MenuCode,
             menupath = menu.MenuPath,
             order = menu.MenuOrder,
             level = menu.MenuLevel,
             menuType = menu.MenuType
         });
         return(Json(AjaxResult.Success(model, "菜单新增成功!")));
     }
     catch (Exception ex)
     {
         return(Json(AjaxResult.Error("菜单新增失败!错误原因:" + ex.Message)));
     }
 }
        /// <summary>
        /// 绑定下拉列表控件为指定的数据字典列表
        /// </summary>
        /// <param name="combo">下拉列表控件</param>
        /// <param name="itemList">数据字典列表</param>
        /// <param name="defaultValue">控件默认值</param>
        public static void BindDictItems(this CustomGridLookUpEdit combo, List <CListItem> itemList, string defaultValue)
        {
            string       displayName = "显示内容";
            const string valueName   = "值内容";
            const string pinyin      = "拼音码";
            DataTable    dt          = DataTableHelper.CreateTable(string.Format("{0},{1},{2}", displayName, valueName, pinyin));

            foreach (CListItem item in itemList)
            {
                DataRow row = dt.NewRow();
                row[displayName] = item.Text;
                row[valueName]   = item.Value;
                row[pinyin]      = Pinyin.GetFirstPY(item.Text);
                dt.Rows.Add(row);
            }

            combo.Properties.ValueMember   = valueName;
            combo.Properties.DisplayMember = displayName;
            combo.Properties.DataSource    = dt;
            combo.Properties.PopulateViewColumns();
            combo.Properties.View.Columns[valueName].Visible = false;

            if (!string.IsNullOrEmpty(defaultValue))
            {
                combo.Text = defaultValue;
            }

            if (!string.IsNullOrEmpty(defaultValue))
            {
                combo.EditValue = defaultValue;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        public JsonResult _Edit(Menu_U menu)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(menu.MenuIcon))
                {
                    byte[] outputb = Convert.FromBase64String(menu.MenuIcon);
                    menu.MenuIcon = Encoding.Default.GetString(outputb);
                }

                menu.MenuCode = Regex.Replace(Pinyin.GetPinyin(menu.MenuName), @"\s", "");

                _MenuFacade.Value.Edit(menu);
                var model = (new
                {
                    id = menu.ID,
                    name = menu.MenuName,
                    title = menu.MenuDesc,
                    menucode = menu.MenuCode,
                    menupath = menu.MenuPath,
                    order = menu.MenuOrder
                });
                return(Json(AjaxResult.Success(model, "菜单更新成功!")));
            }
            catch (Exception ex)
            {
                return(Json(AjaxResult.Error("菜单更新失败!错误原因:" + ex.Message)));
            }
        }
Ejemplo n.º 19
0
        Dictionary <Chinese, List <Pinyin> > corrections2dict(List <Tuple <string, bool, string> > corr)
        {
            Dictionary <Chinese, List <Pinyin> > output = new Dictionary <Chinese, List <Pinyin> >();

            foreach (Tuple <string, bool, string> x in corr)
            {
                Chinese chinese = x.Item1;
                Pinyin  pinyin  = CEdictpinyin2pinyin(x.Item3);
                bool    enabled = x.Item2;
                if (enabled)
                {
                    if (output.ContainsKey(chinese))
                    {
                        output[chinese].Add(pinyin);
                    }
                    else
                    {
                        output.Add(chinese, new List <Pinyin>()
                        {
                            pinyin
                        });
                    }
                }
            }

            return(output);
        }
Ejemplo n.º 20
0
        public JsonResult AddDept(string PID, string DeptName)
        {
            string   selectCode  = "select max(code) from t_dept where PID = @PID";
            DeptRule rule        = new DeptRule();
            string   code        = rule.GetDeptCode(selectCode, new string[] { "PID" }, new string[] { PID });
            string   selectPCode = "select code from t_dept where ID = @ID";
            string   PCode       = rule.GetDeptCode(selectPCode, new string[] { "ID" }, new string[] { PID });

            if (string.IsNullOrEmpty(code))
            {
                code = PCode + "0001";
            }
            else
            {
                code = code.Substring(0, code.Length - 4) + (Convert.ToInt32(code.Substring(code.Length - 4)) + 1).ToString().PadLeft(4, '0');
            }
            string id   = Guid.NewGuid().ToString().Replace("-", "");
            Dept   dept = new Dept()
            {
                ID = id, PY = Pinyin.GetPinyin(DeptName), Status = 1, Code = code, PID = PID, Name = DeptName
            };

            rule.Add(dept);
            string sql = "select id,pid,name,code,status,case status when 0 then '在用' else '停用' end as statusName from t_dept where id=@ID";

            return(Json(rule.GetDeptDynamic(sql, new string[] { "ID" }, new string[] { id }), JsonRequestBehavior.AllowGet));
        }
        public TemplateTree AddTemplate(int pid, string name)
        {
            PKS_KTEMPLATE template = new PKS_KTEMPLATE();

            template.CODE = Pinyin.GetPinyin(name);
            //template.ISDEFAULT = templateInfo.IsDefault;
            template.KTEMPLATECATEGORYID = pid;
            template.NAME        = name;
            template.CREATEDDATE = DateTime.Now;
            // template.TEMPLATE = templateInfo.Template;
            _kTemplateRepository.Add(template);
            _kTemplateRepository.Submit();
            var tempalteId    = template.Id;
            var templateTrees = from tem in _kTemplateRepository.GetQuery()
                                join cat in _kTCategoryRepository.GetQuery()
                                on tem.KTEMPLATECATEGORYID equals cat.Id
                                where cat.Id == pid && tem.Id == tempalteId
                                select new TemplateTree
            {
                Id                 = tem.Id,
                SubSystemId        = cat.SUBSYSTEMID,
                TemplateUrlId      = cat.KTEMPLATEURLID,
                InstanceClass      = cat.INSTANCECLASS,
                Code               = tem.CODE,
                Name               = tem.NAME,
                Template           = tem.TEMPLATE,
                IsDefault          = tem.ISDEFAULT,
                TemplateCategoryId = tem.KTEMPLATECATEGORYID,
                NodeId             = "tem_" + tem.Id,
                ParentNodeId       = "cat_" + cat.Id
            };

            return(templateTrees.FirstOrDefault());
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获取职员查询列表
        /// </summary>
        /// <param name="param"></param>
        /// <param name="emp"></param>
        /// <param name="itemCount"></param>
        /// <returns></returns>
        public List <object> GetSearchJson(EasyUIGridParamModel param, Employee emp, out int itemCount)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"select te.ID,te.Name,te.PY,BirthDate,Sex,DeptID,Job,'' as CardType,te.ICCardID as CardID,Address,te.OfficePhone,td.Name as DEPTNAME,WorkTime,FireTime,te.Status 
							FROM T_Employee te 
							LEFT JOIN T_Dept td ON td.ID = te.DeptID 
							where 1=1 and te.Status!=2 "                            );
            StringBuilder strSqlCount = new StringBuilder();

            strSqlCount.Append(@"select count(0) from t_employee te where 1=1 ");
            Dictionary <string, object> paramm = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(emp.Name))
            {
                strSql.Append(" and te.Name like @Name ");
                strSqlCount.Append(" and te.Name like @Name ");
                paramm.Add("Name", "%" + emp.Name + "%");
                strSql.Append(" and te.PY like @PY ");
                strSqlCount.Append(" and te.Name like @Name ");
                paramm.Add("PY", "%" + Pinyin.GetPinyin(emp.Name) + "%");
            }
            int pageIndex = Convert.ToInt32(param.page) - 1;
            int pageSize  = Convert.ToInt32(param.rows);

            using (DBHelper db = DBHelper.Create())
            {
                string sql = strSql.ToString();
                itemCount = db.GetCount(strSqlCount.ToString(), paramm);
                return(db.GetDynaminObjectList(sql, pageIndex, pageSize, "Name", paramm));
            }
        }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            var sb          = new StringBuilder();
            var levelGroups = new[] { ChineseNumber.UpperLevels, ChineseNumber.LowerLevels };
            var nums        = new int[9].Let(i => i + 1);

            foreach (var levels in levelGroups.AsKvPairs())
            {
                foreach (var level in levels.Value.AsKvPairs())
                {
                    foreach (var num in nums)
                    {
                        var snumber     = levels.Key == 0 ? ChineseNumber.GetString(num, x => x.Upper = true) : ChineseNumber.GetString(num);
                        var str         = $"{snumber}{level.Value}";
                        var pinyin      = Pinyin.GetString(str);
                        var simplified  = ChineseConverter.ToSimplified(str);
                        var traditional = ChineseConverter.ToTraditional(str);
                        var tag         = num * Math.Pow(10, level.Key);
                        sb.AppendLine($@"{" ".Repeat(12)}new ChineseWord {{ Pinyin = ""{pinyin}"", Simplified = ""{simplified}"", Traditional = ""{traditional}"", Tag = {tag} }},");
                    }
                }
            }

            var csFile = Build(sb.ToString());

            File.WriteAllText("../../../NumberWords.cs", csFile);

            Console.WriteLine("File saved: NumberWords.cs");
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 将汉字转换为拼音字符串
        /// </summary>
        /// <param name="document"></param>
        /// <param name="everyCharUpper">每一个汉字手写字母是否转换为大写</param>
        /// <returns></returns>
        public static string TextConvertChar(this string document, bool everyCharUpper = false)
        {
            Encoding enc = Encoding.UTF8;

            document = document.Trim();
            string firstChars = Pinyin.GetInitials(document, enc); //转换为大写字母
            string pinying    = Pinyin.GetPinyin(document);        //这是获取到元素的拼音

            if (!everyCharUpper)
            {//每一个单词的首字母进行大写转换
                return(pinying.Replace(" ", string.Empty));
            }
            StringBuilder sb = new StringBuilder();

            foreach (string item in pinying.Split(' '))
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }
                //首字母进行处理
                sb.Append(item.Substring(0, 1).ToUpper());
                if (item.Length > 1)
                {
                    sb.Append(item.Substring(1));
                }
            }
            return(sb.ToString());
        }
Ejemplo n.º 25
0
        public ActionResult ModifyChargeItem(ChargeItem item)
        {
            AjaxResult result = new AjaxResult();

            try
            {
                item.PY = Pinyin.GetPinyin(item.Name);
                bool flag = new ChargeItemRule().Update(item);
                if (flag)
                {
                    result.Success = true;
                    result.Message = "收费项修改成功";
                }
                else
                {
                    result.Success = false;
                    result.Message = "收费项修改失败";
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 26
0
        private string getFilename(WLOGWeekSummaryData weeksummarydata, string summaryExcelWriteUser)
        {
            #region
            string filenameformat = "{0}{1}.xls";
            string filename       = "";
            if (weeksummarydata.Tables[0].Rows.Count == 1)
            {
                DataRow dr   = weeksummarydata.Tables[0].Rows[0];
                string  date = Convert.ToDateTime(dr[WLOGWeekSummaryData.startDate]).ToString("yyyy-MM-dd");
                if (summaryExcelWriteUser != "")
                {
                    DataRow druser = weeksummarydata.Tables[0].Rows[0];
                    filename = string.Format(filenameformat,
                                             Pinyin.GetPinyin(summaryExcelWriteUser).Replace(" ", ""),
                                             date);
                }
                else
                {
                    filename = string.Format(filenameformat, "noname", date);
                }
            }
            else
            {
                filename = string.Format(filenameformat, "noname", "");
            }
            return(filename);

            #endregion
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 只留 字母,数字,汉字转拼音
        /// </summary>
        /// <param name="nameStr"></param>
        /// <returns></returns>
        public static string NameConvert(string nameStr)
        {
            var stringBuilder = new StringBuilder();

            for (var i = 0; i < nameStr.Length; ++i)
            {
                var ch = nameStr[i];
                if (IsNumber(ch))
                {
                    stringBuilder.Append(ch);
                    continue;
                }
                if (IsLetter(ch))
                {
                    stringBuilder.Append(ch);
                    continue;
                }
                if (IsChineseChar(ch))
                {
                    var pinyinStr = Pinyin.GetPinyin(nameStr[i]);
                    stringBuilder.Append(pinyinStr);
                    continue;
                }
                //其他的使用*
                stringBuilder.Append('*');
            }

            return(stringBuilder.ToString());
        }
Ejemplo n.º 28
0
        public ActionResult editSure(string name, string sex, string bir, string joindate, string posi, string tel, string email, int isout, string password, string depart, string EmpID, string Role, string CompanyID)
        {
            try
            {
                //解密
                CompanyID = Base64MIMA.JIE(CompanyID);
            }
            catch (Exception)
            {
                //跳转错误页面
                return(Redirect("/ErrorPage/Index"));
            }
            string py      = Pinyin.GetInitials(name);
            string pinyin  = Pinyin.GetPinyin(name).Replace(" ", "");
            string editsql = string.Format("update dbo.Employee set Name='{0}',Sex={1},Birth='{2}',JoinDate='{3}',EmpTel='{4}',EmpEmail='{5}',IsOut={6},EmpPassword='******',DepartID='{8}',PositionID='{9}',SpellJX='{11}',SpellQP='{12}',RoleID='{13}' where EmpID='{10}' and CompanyID='{14}'", name, sex, bir, joindate, tel, email, isout, password, depart, posi, EmpID, py, pinyin, Role, CompanyID);
            string edit    = sql.EditDataCommand(editsql);

            if (edit == "0")
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("no"));
            }
        }
Ejemplo n.º 29
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txt_name.Text.Trim()))
                {
                    XtraMessageBox.Show("请您输入药品名称!");
                    return;
                }

                var entity = new Domain.Model.Medicine()
                {
                    Id             = detailId,
                    Name           = txt_name.Text.Trim(),
                    NameCode       = Pinyin.GetInitials(Pinyin.ConvertEncoding(txt_name.Text.Trim(), Encoding.UTF8, Encoding.GetEncoding("GB2312")), Encoding.GetEncoding("GB2312"))?.ToLower(),
                    CommonName     = txt_commonName.Text.Trim(),
                    CommonNameCode = string.IsNullOrWhiteSpace(txt_commonName.Text.Trim()) ? "" : Pinyin.GetInitials(Pinyin.ConvertEncoding(txt_commonName.Text.Trim(), Encoding.UTF8, Encoding.GetEncoding("GB2312")), Encoding.GetEncoding("GB2312"))?.ToLower(),
                    JYFWId         = lue_ssjyfw.EditValue == null ? 0 : int.Parse(lue_ssjyfw.EditValue.ToString()),
                    BZGG           = txt_bzgg.Text.Trim(),
                    UnitId         = lue_unit.EditValue == null ? 0 : int.Parse(lue_unit.EditValue.ToString()),
                    TypeId         = lue_type.EditValue == null ? 0 : int.Parse(lue_type.EditValue.ToString()),
                    JGFLId         = lue_jgfl.EditValue == null ? 0 : int.Parse(lue_jgfl.EditValue.ToString()),
                    SupplierId     = lue_gys.EditValue == null ? 0 : int.Parse(lue_gys.EditValue.ToString()),
                    SCCJId         = lue_sccj.EditValue == null ? 0 : int.Parse(lue_sccj.EditValue.ToString()),
                    CPZC           = txt_cpzc.Text.Trim(),
                    PZWH           = date_pzwh.Text.Trim(),
                    IsPrescription = ckb_isPrescription.Checked,
                    Status         = 1,
                };

                using (var db = SugarDao.GetInstance())
                {
                    if (Convert.ToBoolean(db.InsertOrUpdate(entity)))
                    {
                        string msg = detailId > 0 ? $"【修改成功】 " : $"【新增成功】";

                        Log.Info(new LoggerInfo()
                        {
                            LogType      = LogType.药品信息.ToString(),
                            CreateUserId = UserInfo.Account,
                            Message      = msg + $"药品Id:{entity.Id},药品名称:{entity.Name},药品简写:{entity.NameCode},药品通用名称:{entity.CommonName}" +
                                           $",药品通用名称简写:{entity.CommonNameCode},经营范围:{lue_ssjyfw.Text},药品规格:{txt_bzgg.Text},药品单位:{lue_unit.Text}" +
                                           $",药剂分类:{lue_type.Text},监管分类:{lue_jgfl.Text},供应商:{lue_gys.Text},生产厂家:{lue_sccj.Text},产品注册证批件号:{txt_cpzc.Text.Trim()}" +
                                           $",批准文号有效期:{ date_pzwh.Text.Trim()},是否处方药:{(entity.IsPrescription ? "是" : "否")}"
                        });

                        DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        DialogResult = DialogResult.Cancel;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 30
0
        public ActionResult AddCustomer(Ajax.Model.Customer customer, List <CustomerChargeItem> ccItems)
        {
            AjaxResult result = new AjaxResult();

            customer.ID         = Guid.NewGuid().ToString("N");
            customer.CreateTime = DateTime.Now;
            customer.UpdateTime = DateTime.Now;
            customer.PY         = Pinyin.GetPinyin(customer.Name);
            customer.Status     = 0;//默认无效,需要审核
            customer.OperatorID = MyTicket.CurrentTicket.EmployeeID;
            customer.Code       = 0;
            //对应缴费项
            foreach (CustomerChargeItem ccItem in ccItems)
            {
                ccItem.ID         = WebHelper.GetNewGuidUpper();
                ccItem.CustomerID = customer.ID;
            }
            try
            {
                new CustomerRule().Add(customer, ccItems);
                result.Success = true;
                result.Message = "客户添加成功";
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }