/// <summary> /// 上传BOM /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { #region 勾选客户 ExtractInventoryTool_Client selectedPrint = (ExtractInventoryTool_Client)comboBox1.SelectedItem; if (selectedPrint == null) { MessageBox.Show("请选中一条客户进行导入BOM", "Warning"); return; } string regexRule = selectedPrint.RegexRule; #endregion #region 导入Excel OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "Excel(*.xlsx)|*.xlsx|Excel(*.xls)|*.xls"; openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); openFile.Multiselect = false; if (openFile.ShowDialog() == DialogResult.Cancel) { return; } textBox1.Text = openFile.FileName; LoadingHelper.ShowLoadingScreen(); Task.Run(() => ImportBOMExcel(openFile.FileName, selectedPrint)); //ImportBOMExcel(openFile.FileName, selectedPrint); #endregion }
public void SaveMaterialExcelCallback(bool isSucceed, string errorMessage) { LoadingHelper.CloseForm(); if (!string.IsNullOrEmpty(errorMessage)) { if (!isSucceed) { MessageBox.Show(errorMessage, "Error"); this.DialogResult = DialogResult.None; this.Close(); return; } DialogResult isDelete = MessageBox.Show(errorMessage, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (isDelete != DialogResult.Yes) { this.DialogResult = DialogResult.None; this.Close(); return; } LoadingHelper.ShowLoadingScreen(); Task.Run(() => SaveMaterialExcel(_excelData, true)); return; } _excelData = null;//初始化导入数据 MessageBox.Show("导入成功!", "Success"); DataGridViewSelectedRowCollection clientRowCollection = dataGridView1.SelectedRows; QueryMaterialByClientID(clientRowCollection[0].Cells[0].Value.ToString()); }
public void SaveBOMExcelCallback(bool isSucceed, string errorMessage) { LoadingHelper.CloseForm(); if (!string.IsNullOrEmpty(errorMessage)) { if (!isSucceed) { MessageBox.Show(errorMessage, "Error"); this.DialogResult = DialogResult.None; this.Close(); return; } DialogResult isDelete = MessageBox.Show(errorMessage, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (isDelete != DialogResult.Yes) { this.DialogResult = DialogResult.None; this.Close(); return; } LoadingHelper.ShowLoadingScreen(); Task.Run(() => SaveBOMExcel(_excelData, true)); return; } _excelData = null; MessageBox.Show("导入成功!", "Success"); this.DialogResult = DialogResult.OK; this.Close(); return; }
/// <summary> /// 导入物料 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button5_Click(object sender, EventArgs e) { #region 勾选客户 DataGridViewSelectedRowCollection rowCollection = dataGridView1.SelectedRows; DataGridViewRow row = null; if (rowCollection.Count != 1) { MessageBox.Show("请选中一条客户进行添加物料备案", "Warning"); return; } row = rowCollection[0]; int clientOid = 0; clientOid = int.TryParse(row.Cells[0].Value.ToString().Trim(), out clientOid) ? clientOid : 0; string clientUniqueCode = row.Cells[2].Value.ToString().Trim(); #endregion #region 导入Excel OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "Excel(*.xlsx)|*.xlsx|Excel(*.xls)|*.xls"; openFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); openFile.Multiselect = false; if (openFile.ShowDialog() == DialogResult.Cancel) { return; } LoadingHelper.ShowLoadingScreen(); Task.Run(() => ImportMaterialExcel(openFile.FileName, clientOid, clientUniqueCode)); #endregion }
public void ExtractToExcel(List <ExtractInventoryTool_PickUpDemandDetails> demandList) { if (demandList == null || demandList.Count == 0) { return; } string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string sourceFile = path + "取货计划.xlsx"; if (!File.Exists(sourceFile)) { MessageBox.Show("取货计划模板不存在", "Error"); } FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件保存路径"; if (dialog.ShowDialog() != DialogResult.OK) { return; } string foldPath = dialog.SelectedPath; StringBuilder newExcelName = new StringBuilder(); newExcelName .Append("取货计划") .Append(DateTime.Now.ToString("yyyy-MMdd-HHmmss")) .Append(".xlsx"); //File.Copy(sourceFile, Path.Combine(foldPath, newExcelName.ToString()), true); LoadingHelper.ShowLoadingScreen("正在导出.."); new NPOIHelper().WriteToPickUpDemandExcel(sourceFile, Path.Combine(foldPath, newExcelName.ToString()), demandList); LoadingHelper.CloseForm(); MessageBox.Show("导出成功!", "Success"); return; }
public string OCR_Trans() { LoadingHelper.ShowLoadingScreen();//显示 var OCRresult = ""; string token = "24.5142d6d4850be2c098165f677b8fe68b.2592000.1603087490.282335-22701901"; //string host = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=" + token; string host = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic?access_token=" + token; Encoding encoding = Encoding.Default; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host); request.Method = "post"; request.Timeout = 4000; request.KeepAlive = true; var rect = new Rectangle(_rect.X, _rect.Y, _rect.Width + 1, _rect.Height + 1); using (var img = new Bitmap(rect.Width, rect.Height)) { using (var g = Graphics.FromImage(img)) { g.DrawImage(this.BackgroundImage, new Rectangle(0, 0, rect.Width, rect.Height), rect, GraphicsUnit.Pixel); try { // 图片的base64编码 string base64 = ImageToBase64(img); String str = "image=" + HttpUtility.UrlEncode(base64); byte[] buffer = encoding.GetBytes(str); request.ContentLength = buffer.Length; request.GetRequestStream().Write(buffer, 0, buffer.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default); string result = reader.ReadToEnd(); var ocr_result = JsonHelper.ConvertJson(result); for (int i = 0; i < ocr_result["words_result"].Count(); i++) { OCRresult = OCRresult + ocr_result["words_result"][i]["words"].ToString() + "\r\n"; } OCRresult = TranslateAPISingle.Translate(OCRresult); new OCR_Form(img, OCRresult).Show(); } catch { Console.WriteLine("网络异常"); } finally { LoadingHelper.CloseForm();//关闭 } } } return(OCRresult); }
public string OCR_Latx() { string LaTeXRresult = ""; try { LoadingHelper.ShowLoadingScreen();//显示 var rect = new Rectangle(_rect.X, _rect.Y, _rect.Width + 1, _rect.Height + 1); using (var img = new Bitmap(rect.Width, rect.Height)) { using (var g = Graphics.FromImage(img)) { g.DrawImage(this.BackgroundImage, new Rectangle(0, 0, rect.Width, rect.Height), rect, GraphicsUnit.Pixel); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Timeout", "6000"); headers.Add("ContentType", "application/json"); headers.Add("UserAgent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"); headers.Add("Method", "POST"); string LaTeX_MMS_url = "https://www.latexlive.com:5001/api/mathpix/posttomathpix?"; var postData = "{\"src\":\"data:image/png;base64," + ImageToBase64(img) + "\"}"; Request Response = new Request(LaTeX_MMS_url, headers, postData); var text = Response.GetText(); var json_LaTeX_MMS = JsonHelper.ConvertJson(text); LaTeXRresult = json_LaTeX_MMS["latex_styled"]?.ToString(); //var Text = json_LaTeX_MMS["text"]?.ToString(); if (LaTeXRresult != "" && !String.IsNullOrEmpty(LaTeXRresult)) { Clipboard.SetText(LaTeXRresult); new OCR_Form(img, "公式已经复制到剪切板,使用CTRL+V黏贴至MathType中使用:\r\n-------------\r\n" + LaTeXRresult).Show(); } else { new OCR_Form(img, "选中区域无法检测到公式,请重新框定公式。").Show(); } } } } catch (Exception e) { Console.WriteLine(e); } LoadingHelper.CloseForm();//关闭 return(LaTeXRresult); }
//个人基本建档记录历史表 关联传参调查询的方法 private void querypBasicInfo() { time1 = this.dateTimePicker1.Text.ToString() + " 00:00:00"; //开始时间 time2 = this.dateTimePicker2.Text.ToString() + " 23:59:59"; //结束时间 this.dataGridView1.DataSource = null; LoadingHelper.myCaption = "正在查询..."; LoadingHelper.myLabel = "正在查询数据..."; LoadingHelper.ShowLoadingScreen(); Thread.Sleep(50); try { DataTable dt = pBasicInfo.queryPersonalBasicInfo(pCa, time1, time2, xcuncode); //这里处理下对应的记录 DataTable dtfinished = CreateDataTable(); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dtfinished.NewRow(); dr[0] = dt.Rows[i][0].ToString(); dr[1] = dt.Rows[i][1].ToString(); dr[2] = dt.Rows[i][2].ToString(); dr[3] = dt.Rows[i][3].ToString(); #region 处理特殊标签 String _teshubiaoqian = ""; String _tmp = dt.Rows[i]["age"].ToString(); if (_tmp == "") { _tmp = "0"; } if (int.Parse(_tmp) >= 65) { _teshubiaoqian = "老"; } else { if (int.Parse(_tmp) <= 6) { _teshubiaoqian = "儿童"; } } _tmp = dt.Rows[i]["is_gravida"].ToString(); if (_tmp == "") { _tmp = "0"; } if (int.Parse(_tmp) != 0) { _teshubiaoqian = _teshubiaoqian + " 孕"; } _tmp = dt.Rows[i]["is_hypertension"].ToString(); if (_tmp == "") { _tmp = "0"; } if (int.Parse(_tmp) != 0) { _teshubiaoqian = _teshubiaoqian + " 高"; } _tmp = dt.Rows[i]["is_diabetes"].ToString(); if (_tmp == "") { _tmp = "0"; } if (int.Parse(_tmp) != 0) { _teshubiaoqian = _teshubiaoqian + " 糖"; } _tmp = dt.Rows[i]["is_psychosis"].ToString(); if (_tmp == "") { _tmp = "0"; } if (int.Parse(_tmp) != 0) { _teshubiaoqian = _teshubiaoqian + " 精"; } _tmp = dt.Rows[i]["is_tuberculosis"].ToString(); if (_tmp == "") { _tmp = "0"; } if (int.Parse(_tmp) != 0) { _teshubiaoqian = _teshubiaoqian + " 结"; } _tmp = dt.Rows[i]["is_poor"].ToString(); if (_tmp == "") { _tmp = "0"; } if (int.Parse(_tmp) != 0) { _teshubiaoqian = _teshubiaoqian + " 贫"; } #endregion dr[4] = _teshubiaoqian.Trim(); dr[5] = dt.Rows[i][4].ToString(); dr[6] = dt.Rows[i][5].ToString(); dr[7] = dt.Rows[i][6].ToString(); dtfinished.Rows.Add(dr); } this.dataGridView1.DataSource = dtfinished; dataGridView1.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("微软雅黑", 12, System.Drawing.FontStyle.Regular); this.dataGridView1.Columns[0].Visible = false; this.dataGridView1.Columns[1].HeaderCell.Value = "姓名"; this.dataGridView1.Columns[2].HeaderCell.Value = "档案编号"; this.dataGridView1.Columns[3].HeaderCell.Value = "身份证号"; this.dataGridView1.Columns[4].HeaderCell.Value = "重点人群标签"; this.dataGridView1.Columns[5].HeaderCell.Value = "创建人"; this.dataGridView1.Columns[6].HeaderCell.Value = "创建时间"; this.dataGridView1.Columns[7].HeaderCell.Value = "责任医生"; this.dataGridView1.ReadOnly = true; this.dataGridView1.RowsDefaultCellStyle.ForeColor = Color.Black; this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < this.dataGridView1.Columns.Count; i++) { this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } LoadingHelper.CloseForm(); } catch (Exception ex) { LoadingHelper.CloseForm(); MessageBox.Show("出错,请联系请联系管理员!" + ex.Message + "/r/n" + ex.StackTrace); } }