Exemple #1
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;
            }
        }
        /// <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 #3
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());
        }
Exemple #4
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();
     }
 }
        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 #7
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 #8
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 #9
0
    // 客户名  总金额
    public void ExportToExcelFun(System.Data.DataTable dt, String name, double sum)
    {
        MysqlManager mysqlManager = new MysqlManager();
        String       phone        = mysqlManager.getPhone(name);

        if (dt == null)
        {
            return;
        }
        Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
        if (xlApp == null)
        {
            MessageBox.Show("无法创建Excel对象,可能您的电脑未安装Excel");
            return;
        }

        System.Windows.Forms.SaveFileDialog saveDia = new SaveFileDialog();
        saveDia.Filter   = "Excel|*.xlsx";
        saveDia.Title    = "导出为Excel文件";
        saveDia.FileName = DateTime.Now.ToString("yyyyMMddhhss") + name;
        if (saveDia.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
            !string.Empty.Equals(saveDia.FileName))
        {
            Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks;
            //Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
            Microsoft.Office.Interop.Excel.Workbook  workbook  = workbooks.Add(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Template.xlsx");
            Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];    //取得sheet1
            Microsoft.Office.Interop.Excel.Range     range     = null;

            long   totalCount = dt.Rows.Count;
            long   rowRead    = 0;
            float  percent    = 0;
            string fileName   = saveDia.FileName;

            ////写入标题
            //for (int i = 0; i < dt.Columns.Count; i++)
            //{
            //    worksheet.Cells[2, i + 1] = dt.Columns[i].ColumnName;
            //    range = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[2, i + 1];
            //    //range.Interior.ColorIndex = 15;//背景颜色
            //    range.Font.Bold = true;//粗体
            //    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;//居中
            //                                                                                       //加边框
            //    range.BorderAround(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, null);

            //    //range.ColumnWidth = 4.63;//设置列宽
            //    //range.EntireColumn.AutoFit();//自动调整列宽
            //    //r1.EntireRow.AutoFit();//自动调整行高
            //}

            //写入内容
            // 客户名称
            worksheet.Cells[2, 2] = name;
            // 电话
            worksheet.Cells[3, 2] = phone;
            // 单号
            Encoding gb2312 = Encoding.GetEncoding("GB2312");
            string   s      = Pinyin.ConvertEncoding(name, Encoding.UTF8, gb2312);
            worksheet.Cells[2, 8] = s + "-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;

            // 开票日期
            worksheet.Cells[3, 8] = DateTime.Now.ToString();

            int r = 0;
            for (r = 0; r < dt.DefaultView.Count; r++)
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    worksheet.Cells[r + 6, 1]     = r + 1;
                    worksheet.Cells[r + 6, i + 2] = dt.DefaultView[r][i];
                    //range = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[r + 6, i + 1];
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                    //range.Font.Size = 12;//字体大小
                    //                    //加边框
                    //range.BorderAround(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, null);
                    //range.EntireColumn.AutoFit();//自动调整列宽
                }

                rowRead++;
                percent = ((float)(100 * rowRead)) / totalCount;
                System.Windows.Forms.Application.DoEvents();
            }

            range                     = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[r + 6, 7];
            range.Font.Size           = 15;
            range.Font.Bold           = true;
            worksheet.Cells[r + 6, 7] = "总计: ";



            range                     = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[r + 6, 8];
            range.Font.Size           = 15;
            range.Font.Bold           = true;
            worksheet.Cells[r + 6, 8] = sum + " (元)";

            range                     = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[r + 8, 8];
            range.Font.Size           = 17;
            range.Font.Bold           = true;
            worksheet.Cells[r + 8, 8] = "经手人: ";



            range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
            if (dt.Columns.Count > 1)
            {
                range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideVertical].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
            }

            try
            {
                workbook.Saved = true;
                workbook.SaveCopyAs(fileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("导出文件时出错,文件可能正被打开!\n" + ex.Message);
                return;
            }

            workbooks.Close();
            if (xlApp != null)
            {
                xlApp.Workbooks.Close();
                xlApp.Quit();
                int generation = System.GC.GetGeneration(xlApp);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);
                xlApp = null;
                System.GC.Collect(generation);
            }

            GC.Collect();    //强行销毁
            #region 强行杀死最近打开的Excel进程

            System.Diagnostics.Process[] excelProc = System.Diagnostics.Process.GetProcessesByName("EXCEL");
            System.DateTime startTime = new DateTime();
            int             m, killId = 0;
            for (m = 0; m < excelProc.Length; m++)
            {
                if (startTime < excelProc[m].StartTime)
                {
                    startTime = excelProc[m].StartTime;
                    killId    = m;
                }
            }
            if (excelProc[killId].HasExited == false)
            {
                excelProc[killId].Kill();
            }

            #endregion
            MessageBox.Show("导出成功!");
        }
    }
Exemple #10
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 #11
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 #12
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 #13
0
 //拼音简写转换,通过NPinyin开源库实现
 public string PinyinAbbreviationConvert(string originalStr)
 {
     return(Pinyin.ConvertEncoding(originalStr, Encoding.GetEncoding("GBK"), Encoding.GetEncoding("GBK")));
 }
Exemple #14
0
        // 客户名  总金额
        public void ExportToWordFun(System.Data.DataTable dataTable, String name, double sum)
        {
            System.Windows.Forms.SaveFileDialog saveDia = new SaveFileDialog();
            saveDia.Filter   = "Word|*.docx";
            saveDia.Title    = "导出为Word文件";
            saveDia.FileName = DateTime.Now.ToString("yyyyMMddhhss") + name;
            if (saveDia.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
                !string.Empty.Equals(saveDia.FileName))
            {
                MysqlManager mysqlManager = new MysqlManager();
                String       phone        = mysqlManager.getPhone(name);
                if (phone == null)
                {
                    phone = "00000000000";
                }

                //创建Word文档
                Document document = new Document();
                //添加section
                Section section = document.AddSection();

                section.PageSetup.PageSize = new System.Drawing.SizeF(600, 420);
                //section.PageSetup.PageSize = PageSize.A4;
                section.PageSetup.Orientation = PageOrientation.Landscape;

                Paragraph para1 = section.AddParagraph();
                para1.AppendText("硕麒拉链码庄送货单");
                para1.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
                para1.AppendBreak(BreakType.LineBreak);
                ParagraphStyle style1 = new ParagraphStyle(document);
                style1.Name = "titleStyle";
                style1.CharacterFormat.Bold             = true;
                style1.CharacterFormat.TextColor        = Color.Black;
                style1.CharacterFormat.FontName         = "黑体";
                style1.CharacterFormat.FontSize         = 18f;
                style1.CharacterFormat.CharacterSpacing = document.Styles.Add(style1);
                para1.ApplyStyle("titleStyle");


                //   添加表格  表格样式
                Table table = section.AddTable(true);
                //指定表格的行数和列数()
                table.ResetCells(9 + dataTable.Rows.Count, 9);


                //固定项 样式
                CharacterFormat charactertitle = new CharacterFormat(document);
                charactertitle.Bold      = true;
                charactertitle.FontSize  = 13;
                charactertitle.TextColor = Color.Black;
                charactertitle.FontName  = "黑体";

                TextRange range = table[0, 0].AddParagraph().AppendText("客户姓名");
                range.ApplyCharacterFormat(charactertitle);
                TextRange range1 = table[1, 0].AddParagraph().AppendText("客户电话");
                range1.ApplyCharacterFormat(charactertitle);
                TextRange range3 = table[0, 5].AddParagraph().AppendText("单号");
                range3.ApplyCharacterFormat(charactertitle);
                TextRange range4 = table[1, 5].AddParagraph().AppendText("开票日期");
                range4.ApplyCharacterFormat(charactertitle);

                TextRange ra1 = table[3, 0].AddParagraph().AppendText("序号");
                ra1.ApplyCharacterFormat(charactertitle);
                TextRange ra2 = table[3, 1].AddParagraph().AppendText("系统编号");
                ra2.ApplyCharacterFormat(charactertitle);
                TextRange ra3 = table[3, 2].AddParagraph().AppendText("型号");
                ra3.ApplyCharacterFormat(charactertitle);
                TextRange ra4 = table[3, 3].AddParagraph().AppendText("种类");
                ra4.ApplyCharacterFormat(charactertitle);
                TextRange ra5 = table[3, 4].AddParagraph().AppendText("颜色");
                ra5.ApplyCharacterFormat(charactertitle);
                TextRange ra6 = table[3, 5].AddParagraph().AppendText("数量");
                ra6.ApplyCharacterFormat(charactertitle);
                TextRange ra7 = table[3, 6].AddParagraph().AppendText("单价(元)");
                ra7.ApplyCharacterFormat(charactertitle);
                TextRange ra8 = table[3, 7].AddParagraph().AppendText("金额(元)");
                ra8.ApplyCharacterFormat(charactertitle);
                TextRange ra9 = table[3, 8].AddParagraph().AppendText("备注");
                ra9.ApplyCharacterFormat(charactertitle);
                // 空一行出来
                table.ApplyHorizontalMerge(2, 0, 8);

                // 尾部 第一行3列
                table.ApplyHorizontalMerge(dataTable.Rows.Count + 5, 2, 8);
                TextRange ra10 = table[dataTable.Rows.Count + 5, 0].AddParagraph().AppendText("未付款");
                ra10.ApplyCharacterFormat(charactertitle);
                TextRange ra11 = table[dataTable.Rows.Count + 5, 1].AddParagraph().AppendText("合计金额");
                ra11.ApplyCharacterFormat(charactertitle);
                //                待填入   总金额  —— 数字形式
                TextRange ra12 = table[dataTable.Rows.Count + 5, 2].AddParagraph().AppendText(sum + "(元)");
                ra12.ApplyCharacterFormat(charactertitle);

                // 尾部第二行 2列
                table.ApplyHorizontalMerge(dataTable.Rows.Count + 6, 0, 1);
                TextRange ra13 = table[dataTable.Rows.Count + 6, 0].AddParagraph().AppendText("大写金额");
                ra13.ApplyCharacterFormat(charactertitle);
                //                   待填入   写入大写金额
                ExportToWord word = new ExportToWord();
                table.ApplyHorizontalMerge(dataTable.Rows.Count + 6, 2, 8);
                TextRange ra14 = table[dataTable.Rows.Count + 6, 2].AddParagraph().AppendText(word.ConvertSum(sum.ToString()));
                //Console.WriteLine(word.ConvertSum("8888.88"));
                ra14.ApplyCharacterFormat(charactertitle);

                // 尾部第3行 1列
                table.ApplyHorizontalMerge(dataTable.Rows.Count + 7, 0, 8);
                TextRange ra15 = table[dataTable.Rows.Count + 7, 0].AddParagraph().AppendText("地址: 汉川市新河汉正大道思嘉工业园       电话 : 0712-8105088");
                ra15.ApplyCharacterFormat(charactertitle);

                // 尾部第4行 2列
                table.ApplyHorizontalMerge(dataTable.Rows.Count + 8, 0, 4);
                table.ApplyHorizontalMerge(dataTable.Rows.Count + 8, 5, 8);
                TextRange ra16 = table[dataTable.Rows.Count + 8, 0].AddParagraph().AppendText("制单: ");
                ra16.ApplyCharacterFormat(charactertitle);
                TextRange ra17 = table[dataTable.Rows.Count + 8, 5].AddParagraph().AppendText("客户签名: ");
                ra17.ApplyCharacterFormat(charactertitle);


                // 待填充部分
                // 姓名
                table.ApplyHorizontalMerge(0, 1, 4);
                TextRange r1 = table[0, 1].AddParagraph().AppendText(name);
                r1.ApplyCharacterFormat(charactertitle);
                // 单号
                table.ApplyHorizontalMerge(0, 6, 8);
                Encoding  gb2312 = Encoding.GetEncoding("GB2312");
                String    s      = Pinyin.ConvertEncoding(name, Encoding.UTF8, gb2312);
                String    s1     = Pinyin.GetInitials(s, gb2312);
                TextRange r2     = table[0, 6].AddParagraph().AppendText(s1 + "-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + mysqlManager.getGuestOrderCount(name));
                r2.ApplyCharacterFormat(charactertitle);
                // 电话
                table.ApplyHorizontalMerge(1, 1, 4);
                TextRange r3 = table[1, 1].AddParagraph().AppendText(phone);
                r3.ApplyCharacterFormat(charactertitle);
                // 开票日期
                table.ApplyHorizontalMerge(1, 6, 8);
                TextRange r4 = table[1, 6].AddParagraph().AppendText(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute);
                r4.ApplyCharacterFormat(charactertitle);
                // 添加的数据完毕
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    table[i + 4, 0].AddParagraph().AppendText((i + 1) + "");
                    DataRow rows = dataTable.Rows[i];
                    int     temp = 1;
                    for (int j = 0; j < 9; j++)
                    {
                        if (j != 1)
                        {
                            table[i + 4, temp].AddParagraph().AppendText(rows[j].ToString());
                            temp++;
                        }
                    }
                }
                // 单元格样式
                table[0, 0].CellFormat.FitText = true;
                table[5 + dataTable.Rows.Count, 0].CellFormat.FitText = true;  // 未付款
                // 单元格高度设定
                //for (int i = 0; i < 9 + dataTable.Rows.Count; i++) {
                //    table.Rows[i].Height = 30;
                //}

                for (int i = 3; i < 5 + dataTable.Rows.Count; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        table[i, 1].CellFormat.FitText = true;
                    }
                }
                try
                {
                    //保存文档
                    document.SaveToFile(saveDia.FileName);
                    //doc.SaveToFile(saveDia.FileName, FileFormat.Docx2013);
                    MessageBox.Show("导出成功!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("导出文件时出错,文件可能正被打开!\n" + ex.Message);
                    return;
                }
            }
        }