Exemple #1
0
        protected string GetChinesePY(string chineseString)
        {
            Encoding gb2312 = Encoding.GetEncoding("GB2312");
            string   strPY  = Pinyin.GetInitials(chineseString, gb2312);

            return(strPY);
        }
        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"));
            }
        }
Exemple #3
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;
            }
        }
Exemple #4
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());
        }
Exemple #5
0
        /// <summary>
        /// 汉字转简码
        /// </summary>
        /// <param name="hz"></param>
        /// <returns></returns>
        public static string GetPYJM(string hz, Encoding code)
        {
            //Encoding gb2312 = Encoding.GetEncoding("GB2312");
            string jm = Pinyin.GetInitials(hz, code);

            return(jm);
        }
        /// <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());
        }
Exemple #7
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;
            }
        }
Exemple #8
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}行";
            //    });
            //});
        }
Exemple #9
0
        /// <summary>
        /// 获取汉语拼音码
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static string GetPinym(string strVal)
        {
            if (string.IsNullOrEmpty(strVal)) return "";

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

            return Pinyin.GetInitials(strVal, gb2312);
        }
Exemple #10
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()));
        }
Exemple #11
0
 private void txt_name_EditValueChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txt_name.Text.Trim()))
     {
         Encoding gb2312 = Encoding.GetEncoding("GB2312");
         txt_character.Text =
             Pinyin.GetInitials(Pinyin.ConvertEncoding(txt_name.Text.Trim(), Encoding.UTF8, gb2312), gb2312)?
             .ToLower();
     }
 }
Exemple #12
0
        /// <summary>
        /// 汉字集合转拼音简码
        /// </summary>
        /// <param name="hz"></param>
        /// <returns></returns>
        public static List <string> GetPYJM(List <string> hz, Encoding code)
        {
            List <string> pys = new List <string>();

            foreach (var item in hz)
            {
                string py = Pinyin.GetInitials(item, code);
                pys.Add(py);
            }
            return(pys);
        }
Exemple #13
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());
     }
 }
        public ActionResult AddOrderChannellink(ThirdPartyOrderChannelModel channelModel, List <ThirdPartyOrderChannellinkModel> linkList)
        {
            Encoding gb2312          = Encoding.GetEncoding("GB2312");
            string   s               = Pinyin.ConvertEncoding(channelModel.OrderChannel, Encoding.UTF8, gb2312);
            string   orderChannelEng = Pinyin.GetInitials(s, gb2312).Replace("_", "");

            foreach (var item in linkList)
            {
                item.CreateBy     = User.Identity.Name;
                item.LastUpdateBy = User.Identity.Name;
                if (!item.AdditionalRequirement.Contains("无"))
                {
                    if (item.AdditionalRequirement.Contains("IsAggregatePage"))
                    {
                        item.IsAggregatePage = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsAuthorizedLogin"))
                    {
                        item.IsAuthorizedLogin = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsPartnerReceivSilver"))
                    {
                        item.IsPartnerReceivSilver = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsOrderBack"))
                    {
                        item.IsOrderBack = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsViewOrders"))
                    {
                        item.IsViewOrders = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsViewCoupons"))
                    {
                        item.IsViewCoupons = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsContactUserService"))
                    {
                        item.IsContactUserService = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsBackTop"))
                    {
                        item.IsBackTop = true;
                    }
                }
                else
                {
                    continue;
                }
            }
            bool isSuccess = ChannellinkManager.AddOrderChannellink(channelModel, orderChannelEng, linkList);

            return(Json(new { data = isSuccess }));
        }
        private static string GetSpellCode(string str)
        {
            Encoding gb2312 = Encoding.GetEncoding("gb2312");
            string   strA   = Pinyin.ConvertEncoding(str, Encoding.UTF8, gb2312);
            //首字母
            string strB = Pinyin.GetInitials(strA, gb2312).Substring(0, 1);

            //拼音
            //string strC = Pinyin.GetPinyin(str);
            return(strB.ToUpper());
        }
Exemple #16
0
        /// <summary>
        /// 获取首字母
        /// </summary>
        /// <param name="document">汉字列表</param>
        /// <param name="everyCharUpper">首字母是否大写</param>
        /// <returns></returns>
        public static string TextConvertFirstChar(this string document, bool everyCharUpper = false)
        {
            Encoding enc     = Encoding.UTF8;
            string   pinying = Pinyin.GetInitials(document, enc);//大写的首字母

            //首字母进行处理
            if (!everyCharUpper)
            {
                return(pinying.ToLower());
            }
            return(pinying);
        }
Exemple #17
0
        public static string GetPYString(string text)
        {
            string   textStr = "";
            Encoding gb2312  = Encoding.GetEncoding("GB2312");

            if (text.Contains("埼"))
            {
                text = text.Replace("埼", "Q");
            }
            //textStr= Pinyin.GetInitials(textStr, gb2312);
            //return textStr;
            return(Pinyin.GetInitials(text, gb2312));
        }
Exemple #18
0
        /// <summary>
        /// 获取汉语拼音码
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static string GetPinym(string strVal)
        {
            if (string.IsNullOrEmpty(strVal))
            {
                return("");
            }

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

            //string s = Pinyin.ConvertEncoding(strVal, Encoding.UTF8, gb2312);
            //Pinyin.GetInitials(s, gb2312);
            return(Pinyin.GetInitials(strVal, gb2312));
        }
Exemple #19
0
        /// <summary>
        /// 客户名称简写
        /// </summary>
        public void CustomerNameToShorthand()
        {
            try
            {
                string cc   = CustomerDescribe();
                string Tsql = "select id,accountName from account where dbcVarchar2 is null or dbcVarchar2 = '' ;";
                //string resultjson = xoqlGet(Tsql);
                string resultjson = sqlGet(Tsql);
                if (resultjson.Contains("count"))
                {
                    JObject jo    = (JObject)JsonConvert.DeserializeObject(resultjson);
                    int     count = Convert.ToInt32(jo["count"].ToString());
                    if (count > 0)
                    {
                        for (int a = 0; a < count; a++)
                        {
                            string id          = jo["records"][a]["id"].ToString();
                            string accountName = jo["records"][a]["accountName"].ToString();

                            Encoding gb2312    = Encoding.GetEncoding("GB2312");
                            string   s         = Pinyin.ConvertEncoding(accountName, Encoding.UTF8, gb2312);
                            string   shortName = Pinyin.GetInitials(s, gb2312);

                            //input格式        /
                            string input = "{"
                                           + $"\"id\": {id}"
                                           + $",\"dbcVarchar2\": \"{shortName}\""
                                           + "}";

                            bool fa = CustomerUpdate(input);
                            if (fa)
                            {
                                LogHelper.Info($"{accountName}的简写:{shortName}生成成功!");
                            }
                            else
                            {
                                LogHelper.Info($"{accountName}的简写:{shortName}生成失败!");
                            }
                        }
                    }

                    LogHelper.Info($"无需要生成简写的客户信息!");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.ToString());
            }
        }
Exemple #20
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));
            }

            Console.ReadKey();
        }
Exemple #21
0
        /// <summary>
        /// 中文转拼音
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public List <string> GetPYData(string data)
        {
            List <string> list = new List <string>();

            if (!string.IsNullOrEmpty(data))
            {
                string [] arry = data.Split(';');

                foreach (var item in arry)
                {
                    string str = Pinyin.GetInitials(item).ToUpper();
                    list.Add(str);
                }
            }
            return(list);
        }
Exemple #22
0
        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List <Users> findUsers(string key)
        {
            var list = SimpleDb.AsQueryable().Where(u => u.userName.Contains(key)).ToList();

            if (list.Count != 0)
            {
                return(list);
            }
            // 如果不是字符串包含 则按拼音首字母或者全拼来进行搜索
            var totalList = SimpleDb.AsQueryable().ToList();

            list.AddRange(totalList.Where(user =>
                                          Pinyin.GetInitials(user.userName).ToLower().StartsWith(key) ||
                                          Pinyin.GetPinyin(user.userName).Replace(" ", "").StartsWith(key)));

            return(list);
        }
Exemple #23
0
        /// <summary>
        /// 获取表头的中英对照
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="ic"></param>
        /// <returns></returns>
        public static DataTable getDtCNPy(DataTable dt, int ic)
        {
            DataTable dtCNpy = new DataTable();

            dtCNpy.Columns.Add("cnC");
            dtCNpy.Columns.Add("cnE");
            int iflag = 0;

            for (int i = 0; i < ic; i++)
            {
                string strcnC = dt.Columns[i].ColumnName;
                string strcnE = Pinyin.GetInitials(strcnC);
                if (dtCNpy.Select("cnE = '" + strcnE + "'").Length > 0)
                {
                    strcnE += iflag.ToString();
                    iflag++;
                }
                dtCNpy.Rows.Add(strcnC, strcnE);
            }
            return(dtCNpy);
        }
        //增加
        public ActionResult AddSure(string id, string name, int sex, DateTime bir, DateTime joindate, string tel, string email, int isout, string password, string depart, string posi, string CompanyID, string Role)
        {
            try
            {
                //解密
                CompanyID = Base64MIMA.JIE(CompanyID);
                //加密
                ViewBag.CompanyId = Base64MIMA.JIA(CompanyID);
            }
            catch (Exception)
            {
                //跳转错误页面
                return(Redirect("/ErrorPage/Index"));
            }
            string    isinsql = string.Format("select EmpID from dbo.Employee where EmpID='{0}' and CompanyID='{1}'", id, CompanyID);
            DataTable isin    = sql.GetDataTableCommand(isinsql);

            if (isin?.Rows.Count > 0)
            {
                return(Content("have"));
            }
            else
            {
                string py     = Pinyin.GetInitials(name);
                string pinyin = Pinyin.GetPinyin(name).Replace(" ", "");


                string addsql = string.Format("INSERT INTO dbo.Employee(EmpID, Name ,Sex ,Birth ,JoinDate ,EmpTel ,EmpEmail ,IsOut ,SpellJX,SpellQP,EmpPassword ,DepartID,PositionID,CompanyID,RoleID)VALUES ('{10}','{0}',{1},'{2}','{3}','{4}','{5}',{6},'{11}','{12}','{7}',{8},{9},'{13}','{14}')", name, sex, bir, joindate, tel, email, isout, password, depart, posi, id, py, pinyin, CompanyID, Role);
                string add    = sql.EditDataCommand(addsql);
                if (add == "0")
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }
        }
Exemple #25
0
        protected void BtnSure_Click(object sender, EventArgs e)
        {
            if (inputStart.Value.ToString() == "")
            {
                //提示
                Response.Write("<script>alert('【表名前缀】不能为空')</script>");
            }
            else if (inputName.Value.ToString() == "")
            {
                //提示
                Response.Write("<script>alert('【表名】不能为空')</script>");
            }
            else if (txtarea.InnerHtml == "")
            {
                //提示
                Response.Write("<script>alert('【中文字段部分】不能为空')</script>");
            }
            else
            {
                string str = "";
                if (AutoCodeCk.Checked == true)//自动编号
                {
                    string s = bc.GoToRemoveChar(txtarea.InnerHtml);
                    //转成拼音首字母
                    str  = bc.GoToSpace(Pinyin.GetInitials(s)).ToUpper();
                    str += "\r\n";
                    str += txtarea.InnerHtml + "_${RunTime.CurYear}${RunTime.CurMonth}${RunTime.CurDay}{$AutoNum$}";
                }
                else//数据表
                {
                    str = GetTable();
                }

                showText.InnerHtml = str;
            }
        }
Exemple #26
0
        public void Test_Initials(string hanzi, string pinyin)
        {
            string converted = Pinyin.GetInitials(hanzi);

            Assert.IsTrue(converted == pinyin);
        }
Exemple #27
0
        /// <summary>
        /// 客户名称简写全部 需要分页
        /// </summary>
        public void CustomerNameToShorthandFenye()
        {
            try
            {
                string cc   = CustomerDescribe();
                string Tsql = "select id,accountName from account limit 0,300;";
                //string resultjson = xoqlGet(Tsql);
                string resultjson = sqlGet(Tsql);
                if (resultjson.Contains("count"))
                {
                    JObject jo    = (JObject)JsonConvert.DeserializeObject(resultjson);
                    double  count = Convert.ToDouble(jo["count"].ToString());
                    if (count > 0)
                    {
                        double totalsize = Convert.ToDouble(jo["totalSize"].ToString());
                        double yeshu     = Math.Ceiling(totalsize / count);

                        for (int b = 0; b < yeshu; b++)
                        {
                            Tsql       = $"select id,accountName from account limit {b*300},300;";
                            resultjson = sqlGet(Tsql);


                            if (resultjson.Contains("count"))
                            {
                                jo    = (JObject)JsonConvert.DeserializeObject(resultjson);
                                count = Convert.ToDouble(jo["count"].ToString());
                                if (count > 0)
                                {
                                    for (int a = 0; a < count; a++)
                                    {
                                        string id          = jo["records"][a]["id"].ToString();
                                        string accountName = jo["records"][a]["accountName"].ToString();

                                        Encoding gb2312    = Encoding.GetEncoding("GB2312");
                                        string   s         = Pinyin.ConvertEncoding(accountName, Encoding.UTF8, gb2312);
                                        string   shortName = Pinyin.GetInitials(s, gb2312);

                                        //input格式        /
                                        string input = "{"
                                                       + $"\"id\": {id}"
                                                       + $",\"dbcVarchar2\": \"{shortName}\""
                                                       + "}";

                                        bool fa = CustomerUpdate(input);
                                        if (fa)
                                        {
                                            LogHelper.Info($"{accountName}的简写:{shortName}生成成功!");
                                        }
                                        else
                                        {
                                            LogHelper.Info($"{accountName}的简写:{shortName}生成失败!");
                                        }
                                    }
                                }
                            }
                        }

                        LogHelper.Info($"无需要生成简写的客户信息!");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.ToString());
            }
        }
Exemple #28
0
        public CustomJsonResult Add(string operater, string merchId, RopPrdProductAdd rop)
        {
            CustomJsonResult result = new CustomJsonResult();


            if (string.IsNullOrEmpty(rop.Name))
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "商品名称不能为空"));
            }

            if (rop.KindIds == null || rop.KindIds.Count == 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "至少选择一个商品模块"));
            }

            if (rop.SubjectIds == null || rop.SubjectIds.Count == 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "至少选择一个商品栏目"));
            }

            if (rop.DispalyImgUrls == null || rop.DispalyImgUrls.Count == 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "至少上传一张商品图片"));
            }

            using (TransactionScope ts = new TransactionScope())
            {
                var prdProduct = new PrdProduct();
                prdProduct.Id             = GuidUtil.New();
                prdProduct.MerchId        = merchId;
                prdProduct.Name           = rop.Name;
                prdProduct.BarCode        = rop.BarCode;
                prdProduct.PinYinName     = Pinyin.ConvertEncoding(prdProduct.Name, Encoding.UTF8, Encoding.GetEncoding("GB2312"));
                prdProduct.PinYinIndex    = Pinyin.GetInitials(prdProduct.PinYinName, Encoding.GetEncoding("GB2312"));
                prdProduct.DispalyImgUrls = rop.DispalyImgUrls.ToJsonString();
                prdProduct.MainImgUrl     = ImgSet.GetMain(prdProduct.DispalyImgUrls);
                prdProduct.DetailsDes     = rop.DetailsDes;
                prdProduct.BriefDes       = rop.BriefDes;
                prdProduct.Creator        = operater;
                prdProduct.CreateTime     = DateTime.Now;

                foreach (var sku in rop.Skus)
                {
                    var prdProductSku = new PrdProductSku();
                    prdProductSku.Id           = GuidUtil.New();
                    prdProductSku.MerchId      = prdProduct.MerchId;
                    prdProductSku.PrdProductId = prdProduct.Id;
                    prdProductSku.Name         = prdProduct.Name;
                    prdProductSku.SpecDes      = sku.SpecDes;
                    prdProductSku.SalePrice    = sku.SalePrice;
                    prdProductSku.Creator      = operater;
                    prdProductSku.CreateTime   = DateTime.Now;
                    CurrentDb.PrdProductSku.Add(prdProductSku);
                }

                if (rop.KindIds != null)
                {
                    prdProduct.PrdKindIds = string.Join(",", rop.KindIds.ToArray());

                    foreach (var kindId in rop.KindIds)
                    {
                        var productSkuKind = new PrdProductKind();
                        productSkuKind.Id           = GuidUtil.New();
                        productSkuKind.PrdKindId    = kindId;
                        productSkuKind.PrdProductId = prdProduct.Id;
                        productSkuKind.Creator      = operater;
                        productSkuKind.CreateTime   = DateTime.Now;
                        CurrentDb.PrdProductKind.Add(productSkuKind);
                    }
                }

                if (rop.SubjectIds != null)
                {
                    prdProduct.PrdSubjectIds = string.Join(",", rop.SubjectIds.ToArray());

                    foreach (var subjectId in rop.SubjectIds)
                    {
                        var productSkuSubject = new PrdProductSubject();
                        productSkuSubject.Id           = GuidUtil.New();
                        productSkuSubject.PrdSubjectId = subjectId;
                        productSkuSubject.PrdProductId = prdProduct.Id;
                        productSkuSubject.Creator      = operater;
                        productSkuSubject.CreateTime   = DateTime.Now;
                        CurrentDb.PrdProductSubject.Add(productSkuSubject);
                    }
                }

                CurrentDb.PrdProduct.Add(prdProduct);
                CurrentDb.SaveChanges();
                ts.Complete();

                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "保存成功");
            }

            return(result);
        }
Exemple #29
0
        public CustomJsonResult Edit(string operater, string merchId, RopPrdProductEdit rop)
        {
            CustomJsonResult result = new CustomJsonResult();

            if (string.IsNullOrEmpty(rop.Id))
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "商品Id不能为空"));
            }

            if (string.IsNullOrEmpty(rop.Name))
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "商品名称不能为空"));
            }

            if (rop.KindIds == null || rop.KindIds.Count == 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "商品模块分类不能为空"));
            }

            if (rop.DispalyImgUrls == null || rop.DispalyImgUrls.Count == 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "商品图片不能为空"));
            }

            using (TransactionScope ts = new TransactionScope())
            {
                var prdProduct = CurrentDb.PrdProduct.Where(m => m.Id == rop.Id).FirstOrDefault();

                prdProduct.Name           = rop.Name;
                prdProduct.PinYinName     = Pinyin.ConvertEncoding(prdProduct.Name, Encoding.UTF8, Encoding.GetEncoding("GB2312"));
                prdProduct.PinYinIndex    = Pinyin.GetInitials(prdProduct.PinYinName, Encoding.GetEncoding("GB2312"));
                prdProduct.BriefDes       = rop.BriefDes;
                prdProduct.DetailsDes     = rop.DetailsDes;
                prdProduct.DispalyImgUrls = rop.DispalyImgUrls.ToJsonString();
                prdProduct.Mender         = operater;
                prdProduct.MendTime       = DateTime.Now;

                foreach (var sku in rop.Skus)
                {
                    var prdProductSku = CurrentDb.PrdProductSku.Where(m => m.Id == sku.Id).FirstOrDefault();
                    if (prdProductSku != null)
                    {
                        prdProductSku.SpecDes   = sku.SpecDes;
                        prdProductSku.SalePrice = sku.SalePrice;
                        prdProductSku.Mender    = operater;
                        prdProductSku.MendTime  = DateTime.Now;
                    }
                }

                var prdProductKinds = CurrentDb.PrdProductKind.Where(m => m.PrdProductId == prdProduct.Id).ToList();

                foreach (var prdProductKind in prdProductKinds)
                {
                    CurrentDb.PrdProductKind.Remove(prdProductKind);
                }

                if (rop.KindIds != null)
                {
                    foreach (var kindId in rop.KindIds)
                    {
                        var prdProductKind = new PrdProductKind();
                        prdProductKind.Id           = GuidUtil.New();
                        prdProductKind.PrdKindId    = kindId;
                        prdProductKind.PrdProductId = prdProduct.Id;
                        prdProductKind.Creator      = operater;
                        prdProductKind.CreateTime   = DateTime.Now;
                        CurrentDb.PrdProductKind.Add(prdProductKind);
                    }
                }

                var prdProductSubjects = CurrentDb.PrdProductSubject.Where(m => m.PrdProductId == prdProduct.Id).ToList();

                foreach (var prdProductSubject in prdProductSubjects)
                {
                    CurrentDb.PrdProductSubject.Remove(prdProductSubject);
                }


                if (rop.SubjectIds != null)
                {
                    foreach (var subjectId in rop.SubjectIds)
                    {
                        var prdProductSubject = new PrdProductSubject();
                        prdProductSubject.Id           = GuidUtil.New();
                        prdProductSubject.PrdSubjectId = subjectId;
                        prdProductSubject.PrdProductId = prdProduct.Id;
                        prdProductSubject.Creator      = operater;
                        prdProductSubject.CreateTime   = DateTime.Now;
                        CurrentDb.PrdProductSubject.Add(prdProductSubject);
                    }
                }

                CurrentDb.SaveChanges();
                ts.Complete();

                result = new CustomJsonResult(ResultType.Success, ResultCode.Success, "保存成功");
            }

            return(result);
        }
Exemple #30
0
        // GET: Wo
        public ActionResult Index(string userId, string counts, string companyId)

        {
            log.AppenLog("我看看22");
            try
            {
                string userID      = "";
                string CompanyId   = "";
                string user_ticket = "";//成员票据,通过这个得到登陆进来的人的详情信息
                #region 得到userid和公司id
                //当是从别的页面回来时
                if (!string.IsNullOrWhiteSpace(userId))
                {
                    userID = Base64MIMA.JIE(userId);
                }
                if (!string.IsNullOrWhiteSpace(companyId))
                {
                    CompanyId = Base64MIMA.JIE(companyId);
                }
                if (userID == "")
                {
                    //通过code得到userid
                    string code1 = Request["code"];
                    if (code1 != "")
                    {
                        Tuple <bool, UserInfo> tu2 = BonusHelper.AccessTokenHelper.GetWechatUserInfo2(code1);//第三方应用
                        if (tu2.Item1 || Session["aaa"] != null)
                        {
                            if (Session["aaa"] == null)
                            {
                                log.AppenLog("if");
                                userID         = tu2.Item2.UserId;//得到userid
                                Session["aaa"] = userID;
                                // c.Value = tu2.Item2;
                            }
                            else
                            {
                                log.AppenLog("else");
                                userID = Session["aaa"].ToString();
                                //userid = c.Value;
                            }
                        }

                        try
                        {
                            userID      = userID.Replace('"', ' ');
                            userID      = userID.Trim();
                            CompanyId   = tu2.Item2.CorpId;
                            user_ticket = tu2.Item2.user_ticket;
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    else
                    {
                        //code为空,跳到错误页面
                        return(Redirect("/ErrorPage/Index"));
                    }
                }

                #endregion

                userID    = "lzc";
                CompanyId = "wx512ad5972960e003";
                //加密公司id和userid
                log.AppenLog("登陆进来userid:" + userId);
                ViewBag.CompanyID = Base64MIMA.JIA(CompanyId);
                ViewBag.userID    = Base64MIMA.JIA(userID);
                //工号
                ViewBag.SuserId = userID;
                #region 判断公司是否在有效期
                //在:看登陆进来的人是否是某个公司的负责人,如果是的话就把他的联系方式等填到相关公司表里,不是直接进入后台
                //不在:提示已经过了有效期,需要联系我们来审核
                string    sqlstr            = string.Format($"exec Proc_Wo 'IsValidComoany','{CompanyId}'");
                DataTable dt_IsValidComoany = sql.GetDataTableCommand(sqlstr);
                if (dt_IsValidComoany?.Rows.Count > 0)
                {
                    //通过user_ticket得到详细信息
                    string strResult = AccessTokenHelper.GetUserDetail2(user_ticket);
                    log.AppenLog("页面成员信息:" + strResult);
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(UserDetials));
                    MemoryStream ms  = new MemoryStream(Encoding.UTF8.GetBytes(strResult));
                    UserDetials  obj = (UserDetials)ser.ReadObject(ms);
                    //判断是否是某个公司的负责人
                    string    sqlstr2 = string.Format($"select * from Company where CompanyPrincipal='{userID}'");
                    DataTable dt2     = sql.GetDataTableCommand(sqlstr2);
                    if (dt2?.Rows.Count > 0)
                    {
                        //是某个公司负责人==>将他的信息放到公司列表里面去
                        string CompanyPhone = "";
                        string CompanyEmail = "";
                        string upCom        = "";
                        for (int i = 0; i < dt2?.Rows.Count; i++)
                        {
                            if (dt2.Rows[i]["CompanyPhone"].ToString() == "" || dt2.Rows[i]["CompanyEmail"].ToString() == "")
                            {
                                CompanyPhone = obj.mobile;
                                CompanyEmail = obj.email;
                                upCom       += string.Format($" update Company set CompanyPhone='{CompanyPhone}' where CompanyID={dt2.Rows[i]["CompanyID"].ToString()}");
                            }
                        }

                        if (upCom != "")
                        {
                            sql.EditDataCommand(upCom);
                        }
                    }
                    //更新对应人的信息
                    try
                    {
                        string py     = Pinyin.GetInitials(obj.name);                //简拼
                        string pinyin = Pinyin.GetPinyin(obj.name).Replace(" ", ""); //全拼
                        string upEmp  = string.Format($"exec Proc_Wo 'UpdateTouXiang','{obj.corpid}','{obj.userid}','{obj.avatar}','{obj.mobile}','{obj.email}','{pinyin}','{py}',{obj.gender}");
                        log.AppenLog("更新人员信息:" + upEmp);
                        string info_upEmp = sql.EditDataCommand(upEmp);
                        if (info_upEmp != "0")
                        {
                            return(Content("<script>alert('获取个人信息失败');history.go(-1);</script>"));
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    //return Content("<script>alert('您的使用期限已过,请联系我们!8888888');history.go(-1);</script>");
                    return(Redirect("/Wo/EndIndex"));
                }
                #endregion

                #region 个人信息与个人奖金
                string  infosql = string.Format($"exec proc_Main 'SelectEmpDetialWo','{userID}','','{CompanyId}'");
                DataSet info    = sql.GetDataSetCommand(infosql);
                if (info?.Tables.Count > 0)
                {
                    //个人信息
                    if (info?.Tables[0].Rows.Count > 0)
                    {
                        //是否位超级管理员
                        if (info.Tables[0].Rows[0]["RoleID"].ToString() == "8EA2CC5C-308D-4538-A9D8-FCAD7CA6FEB0")
                        {
                            ViewBag.chaoji = 1;
                        }
                        else
                        {
                            ViewBag.chaoji = 0;
                        }

                        ViewBag.info = info.Tables[0];
                    }
                    else
                    {
                        ViewBag.info   = null;
                        ViewBag.chaoji = 0;
                    }
                    //个人奖金
                    if (info?.Tables[1].Rows.Count > 0)
                    {
                        ViewBag.SumMoney = info.Tables[1].Rows[0][0];
                    }
                    else
                    {
                        ViewBag.SumMoney = "0.00";
                    }
                }
                else
                {
                    ViewBag.info   = null;
                    ViewBag.chaoji = 0;
                }

                #endregion

                #region 部门奖金
                string    isDepartPri = string.Format($"exec proc_Main 'SelectDepJIangjin','{userID}','','{CompanyId}'");
                DataTable dss         = sql.GetDataTableCommand(isDepartPri);
                if (dss?.Rows.Count > 0)
                {
                    ViewBag.depSumMoney = dss;
                }
                else
                {
                    ViewBag.depSumMoney = null;
                }
                //string isDepartPri = string.Format("SELECT DepartID FROM dbo.Depart WHERE DepartPrincipal='{0}'", userID);
                //                string isDepartPri = string.Format("SELECT DepartID FROM dbo.Depart WHERE DepartPrincipal='{0}' AND CompanyID='{1}'", userID, CompanyId);
                //                DataTable dss = sql.GetDataTableCommand(isDepartPri);
                //                if (dss.Rows.Count > 0)
                //                {
                //                    //是部门负责人
                //                    //ViewBag.isDepartPri = "youarePri";
                //                    //部门奖金
                //                    string sqlDepart = string.Format(@"SELECT DepartID,DepartName,ISNULL(EarMoney,'0.00') Earmoney,EarMan FROM  dbo.Depart d  LEFT JOIN
                //(SELECT  SUM(EarMoney) EarMoney ,EarMan   FROM dbo.BonusData2 WHERE BonusType=0 AND IsGet=0 GROUP BY EarMan )
                // b ON d.DepartID=b.EarMan  WHERE   DepartPrincipal='{0}'  and CompanyID='{1}'", userID, CompanyId);
                //                    DataTable DepartName = sql.GetDataTableCommand(sqlDepart);
                //                    if (DepartName.Rows.Count > 0)
                //                    {

                //                        ViewBag.depSumMoney = DepartName;
                //                    }
                //                    else
                //                    {
                //                        ViewBag.depSumMoney = null;
                //                    }
                //                }
                //                else
                //                {
                //                    //ViewBag.isDepartPri = null;
                //                }
                #endregion

                #region 奖金项
                string isitp = string.Format(@"SELECT A.BonusItemID,A.BIName,RM,IM FROM (
SELECT RuleData.BonusItemID,BIName,SUM(RemainMoney)RM FROM dbo.RuleData 
INNER JOIN dbo.BonusItem ON BonusItem.BonusItemID = RuleData.BonusItemID
WHERE  RuleData.BonusItemID IN (SELECT BonusItemID FROM dbo.BonusImpower WHERE BIState=0 AND EmpID='{0}') AND CompanyID='{2}'
AND GETDATE()<EndDate
GROUP BY RuleData.BonusItemID,BIName) AS A
LEFT JOIN 
(SELECT b2.BonusItemID,BIName,SUM(b1.RemainMoney) IM FROM dbo.BonusImpower  b1
INNER JOIN dbo.BonusItem b2 ON b2.BonusItemID = b1.BonusItemID 
WHERE BIState=0 AND EmpID = '{1}' AND (ImpowerDate >= DATEADD(MM, DATEDIFF(MM, 0, GETDATE()), 0) and IsValid=0)
GROUP BY b2.BonusItemID, BIName) AS B ON A.BonusItemID=B.BonusItemID AND A.BIName=B.BIName", userID, userID, CompanyId);

                DataTable itp = sql.GetDataTableCommand(isitp);
                if (itp?.Rows.Count > 0)
                {
                    ViewBag.itp = itp;
                }
                else
                {
                    ViewBag.itp = null;
                }
                //自己负责的奖金项
                string    isitem = string.Format("SELECT dbo.RuleData.BonusItemID,dbo.BonusItem.BIName,SUM(RemainMoney) AllMoney FROM dbo.RuleData INNER JOIN dbo.BonusItem ON BonusItem.BonusItemID = RuleData.BonusItemID WHERE BIState=0 AND CompanyID='{1}' AND BIPrincipal = '{0}' AND CONVERT(VARCHAR(30), GETDATE(), 102) < EndDate GROUP BY dbo.RuleData.BonusItemID, dbo.BonusItem.BIName", userID, CompanyId);
                DataTable item   = sql.GetDataTableCommand(isitem);
                if (item?.Rows.Count > 0)
                {
                    for (int i = 0; i < item?.Rows.Count; i++)
                    {
                        Session["shit" + i] = sql.GetDataTableProcedure("proc_BonusData", item.Rows[i]["BonusItemID"].ToString(), "1");
                    }
                    ViewBag.item = item;
                }
                else
                {
                    ViewBag.item = null;
                }
                //查自己有没有奖金发放权限
                string    sqlsq = string.Format($@"
SELECT b2.BonusItemID, BIName, SUM(b1.RemainMoney) IM FROM dbo.BonusImpower  b1
INNER JOIN dbo.BonusItem b2 ON b2.BonusItemID = b1.BonusItemID
WHERE BIState = 0 AND EmpID = '{userID}' AND(ImpowerDate >= DATEADD(MM, DATEDIFF(MM, 0, GETDATE()), 0) and IsValid = 0)
GROUP BY b2.BonusItemID, BIName");
                DataTable dtsq  = sql.GetDataTableCommand(sqlsq);
                ViewBag.counts = dtsq.Rows.Count + item.Rows.Count;
                ViewBag.count  = Base64MIMA.JIA((dtsq.Rows.Count + item.Rows.Count).ToString());
                #endregion

                InitJsapi(Base64MIMA.JIA(CompanyId));
            }
            catch (Exception ex)
            {
                log.AppenLog("woIndex错误:" + ex.Message);
                return(Redirect("/ErrorPage/Index"));
            }
            return(View());
        }