Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
0
        private void button1_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.GetPinyin(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.º 6
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));
        }
Ejemplo n.º 7
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);
        }
        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.º 9
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.º 10
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)));
     }
 }
Ejemplo n.º 11
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.º 12
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.º 13
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.º 14
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));
        }
Ejemplo n.º 15
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.º 16
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.º 17
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.º 18
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.º 19
0
        private async void button2_Click(object sender, RibbonControlEventArgs e)
        {
            var tp = new DxTempTableViewer();
            var p  = Globals.ThisAddIn.CustomTaskPanes.Add(tp, "转换");

            tp.Dock   = DockStyle.Fill;
            p.Width   = 600;
            p.Visible = true;
            var t = Task.Run(() =>
            {
                var dt = ExcelHelper.GetDataTable();
                dt.Columns.Add("全拼");
                dt.Columns.Add("首字母");
                if (dt != null)
                {
                    var i     = 0;
                    var total = dt.Rows.Count;
                    foreach (DataRow dr in dt.Rows)
                    {
                        i++;
                        dr["全拼"]  = Pinyin.GetPinyin(dr[0].ToString());
                        dr["首字母"] = Pinyin.GetInitials(dr[0].ToString());
                        tp.Invoke((MethodInvoker) delegate
                        {
                            tp.TsMsg.Text = $"正在计算第{i}行,共{total}行";
                        });
                    }
                }
                else
                {
                    MessageBox.Show("请选择一个以上的单元格");
                }
                return(dt);
            });
            await t;

            tp.Dt         = t.Result;
            tp.TsMsg.Text = $"数据获取完毕,共计{t.Result.Rows.Count}行";


            //t.GetAwaiter().OnCompleted(() =>
            //{
            //    tp.Invoke((MethodInvoker)delegate
            //    {
            //        tp.Dt = t.Result;
            //        tp.TsMsg.Text = $"数据获取完毕,共计{t.Result.Rows.Count}行";
            //    });
            //});

            //Task.Run(() =>
            //{
            //    Task.WaitAll(t);
            //    tp.Invoke((MethodInvoker)delegate
            //    {
            //        tp.Dt = t.Result;
            //        tp.TsMsg.Text = $"数据获取完毕,共计{t.Result.Rows.Count}行";
            //    });
            //});
        }
Ejemplo n.º 20
0
        private void btnPinyinUtil_Click(object sender, EventArgs e)
        {
            string[] maxims = new string[] {
                "事常与人违,事总在人为",
                "骏马是跑出来的,强兵是打出来的",
                "驾驭命运的舵是奋斗。不抱有一丝幻想,不放弃一点机会,不停止一日努力。 ",
                "如果惧怕前面跌宕的山岩,生命就永远只能是死水一潭",
                "懦弱的人只会裹足不前,莽撞的人只能引为烧身,只有真正勇敢的人才能所向披靡"
            };

            string[] medicines = new string[] {
                "聚维酮碘溶液",
                "开塞露",
                "炉甘石洗剂",
                "苯扎氯铵贴",
                "鱼石脂软膏",
                "莫匹罗星软膏",
                "红霉素软膏",
                "氢化可的松软膏",
                "曲安奈德软膏",
                "丁苯羟酸乳膏",
                "双氯芬酸二乙胺乳膏",
                "冻疮膏",
                "克霉唑软膏",
                "特比奈芬软膏",
                "酞丁安软膏",
                "咪康唑软膏、栓剂",
                "甲硝唑栓",
                "复方莪术油栓",
                "右桥小脑角岩斜区肿瘤"
            };

            StringBuilder sb = new StringBuilder("UTF8句子拼音:");

            foreach (string s in maxims)
            {
                sb.AppendFormat("汉字:{0}\n拼音:{1}\n简码:{2} \r\n", s, Pinyin.GetPinyin(s), Pinyin.GetFirstPY(s));
            }

            Encoding gb2312 = Encoding.GetEncoding("GB2312");

            sb.AppendFormat("GB2312拼音简码:");
            foreach (string m in medicines)
            {
                string s = Pinyin.ConvertEncoding(m, Encoding.UTF8, gb2312);
                sb.AppendFormat("药品:{0}\n简码:{1}\n", s, Pinyin.GetFirstPY(s, gb2312));
            }

            string testWord = "右桥小脑角岩斜区肿瘤,聚维酮碘溶液,酞丁安软膏";
            //中文拼音(首字母大写,空格分开)
            string letters = PinYinUtil.CHSToPinyin(testWord, " ", true);

            sb.AppendLine(testWord);
            sb.AppendLine("中文拼音:" + letters);
            sb.AppendLine("首字母:" + PinYinUtil.GetFirstPY(testWord));

            MessageDxUtil.ShowTips(sb.ToString());
        }
Ejemplo n.º 21
0
        /// <summary>
        /// ����ѧУ
        /// </summary>
        /// <param name="school">Ҫ���µ�ѧУ</param>
        /// <returns></returns>
        public void Update(School school)
        {
            EventBus <School> .Instance().OnBefore(school, new CommonEventArgs(EventOperationType.Instance().Update()));

            school.PinyinName      = Pinyin.GetPinyin(school.Name);
            school.ShortPinyinName = Pinyin.GetInitials(school.Name);
            schoolRepository.Update(school);
            EventBus <School> .Instance().OnAfter(school, new CommonEventArgs(EventOperationType.Instance().Update()));
        }
Ejemplo n.º 22
0
    public static string getPinyin(string hanzi)
    {
        if (string.IsNullOrEmpty(hanzi))
        {
            return("");
        }

        return(Pinyin.GetPinyin(hanzi).Trim().Replace(" ", ""));
    }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            //string[] maxims = new string[]{
            //    "事常与人违,事总在人为",
            //    "骏马是跑出来的,强兵是打出来的",
            //    "驾驭命运的舵是奋斗。不抱有一丝幻想,不放弃一点机会,不停止一日努力。 ",
            //    "如果惧怕前面跌宕的山岩,生命就永远只能是死水一潭",
            //    "懦弱的人只会裹足不前,莽撞的人只能引为烧身,只有真正勇敢的人才能所向披靡"
            //};

            //string[] medicines = new string[] {
            //    "聚维酮碘溶液",
            //    "开塞露",
            //    "炉甘石洗剂",
            //    "苯扎氯铵贴",
            //    "鱼石脂软膏",
            //    "莫匹罗星软膏",
            //    "红霉素软膏",
            //    "氢化可的松软膏",
            //    "曲安奈德软膏",
            //    "丁苯羟酸乳膏",
            //    "双氯芬酸二乙胺乳膏",
            //    "冻疮膏",
            //    "克霉唑软膏",
            //    "特比奈芬软膏",
            //    "酞丁安软膏",
            //    "咪康唑软膏、栓剂",
            //    "甲硝唑栓",
            //    "复方莪术油栓"
            //};

            //Console.WriteLine("UTF8句子拼音:");
            //foreach (string s in maxims)
            //{
            //    Console.WriteLine("汉字:{0}\n拼音:{1}\n", s, Pinyin.GetPinyin(s));
            //}

            //Encoding gb2312 = Encoding.GetEncoding("GB2312");
            //Console.WriteLine("GB2312拼音简码:");
            //foreach (string m in medicines)
            //{
            //    string s = Pinyin.ConvertEncoding(m, Encoding.UTF8, gb2312);
            //    Console.WriteLine("药品:{0}\n简码:{1}\n", s, Pinyin.GetInitials(s, gb2312,false));
            //}
            //Console.ReadKey();


            /* 添加汉字步骤 */
            //1、网上查找汉字的拼音,添加汉字到 PyCode.codes ,得到codes数组的索引:行数-6   // 368 - 6
            //2、根据 Pinyin.GetHashIndex 得到hash数组的下标,+6是因为下标和代码编译的行数是不一样的,方便查找
            char str = '赟';

            Console.WriteLine(Pinyin.GetHashIndex(str)); // 281 + 6

            Console.WriteLine(Pinyin.GetPinyin(str));
            Console.ReadKey();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 更改用户信息,不允许更改邮箱(用户ID),所属单位
        /// </summary>
        /// <param name="ctx">数据库操作句柄</param>
        /// <param name="personDTO"></param>
        public GetPersonDTO UpdatePerson(UpdatePersonDTO personDTO, Func <Person, bool> privilege)
        {
            using (var ctx = new AspodesDB())
            {
                //取出Person
                var oldValue = ctx.Persons.FirstOrDefault(p => p.PersonId == personDTO.PersonId);
                if (null == oldValue)
                {
                    throw new NotFoundException();
                }

                //修改内容权限
                if (oldValue.Status == "S" || !privilege(oldValue))
                {
                    throw new UnauthorizationException();
                }

                var newValue = Mapper.Map <Person>(personDTO);

                //检查身份证号码是否冲突
                if (newValue.IDCard != oldValue.IDCard && ctx.Persons.Any(p => p.IDCard == newValue.IDCard))
                {
                    throw new OtherException("身份证号码冲突");
                }

                //不允许更新的内容
                newValue.PersonId    = oldValue.PersonId;
                newValue.Email       = oldValue.Email;
                newValue.InstituteId = oldValue.InstituteId;
                newValue.Status      = oldValue.Status;
                //ctx.Entry(person).Property("Email").IsModified = false;
                //ctx.Entry(person).Property("InstituteId").IsModified = false;
                //ctx.Entry(person).Property("Status").IsModified = false;

                newValue.Name = newValue.FirstName + newValue.LastName;
                if (newValue.Name != oldValue.Name && newValue.EnglishName == null)
                {
                    newValue.EnglishName = Pinyin.GetPinyin(newValue.FirstName) + ""
                                           + Pinyin.GetPinyin(newValue.LastName).Replace(" ", "");
                }

                //更新Person内容
                ctx.Entry(oldValue).CurrentValues.SetValues(newValue);

                //更新关联用户的相关信息
                var user = ctx.Users.FirstOrDefault(u => u.PersonId == oldValue.PersonId);
                if (null != user)
                {
                    user.Name   = newValue.Name;
                    user.IDCard = newValue.IDCard;
                }
                ctx.SaveChanges();
                return(Mapper.Map <GetPersonDTO>(newValue));
            }
        }
Ejemplo n.º 25
0
Archivo: PinYin.cs Proyecto: DrWuc/Flew
        /// <summary>
        /// 集合转拼音
        /// </summary>
        /// <param name="hz"></param>
        /// <returns></returns>
        public static List <string> GetPY(List <string> hz)
        {
            List <string> pys = new List <string>();

            foreach (var item in hz)
            {
                string py = Pinyin.GetPinyin(item);
                pys.Add(py);
            }
            return(pys);
        }
Ejemplo n.º 26
0
        //生成拼音数据库名
        public string getdatabasename(string chname)
        {
            string newenname = null;

            if (!string.IsNullOrEmpty(chname))
            {
                string newwebsite = Pinyin.GetPinyin(chname).Replace(" ", "");
                newenname = newwebsite + "db";
            }
            return(newenname);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 转换字符串成拼音
 /// </summary>
 /// <param name="str"></param>
 /// <param name="type">转换为全部小写 1首字母大写 2只取第一个字母</param>
 /// <returns></returns>
 public static string GetPinYin(this string str, int type = 1)
 {
     if (type == 1)
     {
         return(Pinyin.GetPinyin(str));
     }
     else
     {
         return(Pinyin.GetInitials(str).ToLower());
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 中文转英文全拼,首字符大写
        /// </summary>
        /// <param name="c">中文字符</param>
        /// <returns></returns>
        public static string GetToSpellFristUpper(string c)
        {
            string spell  = Pinyin.GetPinyin(c);
            string result = "";

            foreach (var item in spell.Split(' '))
            {
                result += item.Substring(0, 1).ToUpper() + item.Substring(1) + " ";
            }
            return(result.TrimEnd());
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 中文转英文全拼,首字符大写
        /// </summary>
        /// <param name="c">中文字符</param>
        /// <returns></returns>
        public static List <string> GetSpellFristUpper(string c)
        {
            List <string> list  = new List <string>();
            string        spell = Pinyin.GetPinyin(c);

            foreach (var item in spell.Split(' '))
            {
                list.Add(item.Substring(0, 1).ToUpper() + item.Substring(1));
            }
            return(list);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 获取商品名字拼音方法
        /// </summary>
        /// <param name="name">商品名字</param>
        /// <returns></returns>
        public static StringBuilder Spelling(string name)
        {
            StringBuilder pinyin = new StringBuilder();

            //获取商品名字拼音
            foreach (var s in name)
            {
                var chineseChar = Pinyin.GetPinyin(s);
                pinyin.Append(chineseChar);
            }
            return(pinyin);
        }