/// <summary> /// 浏览按钮的操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBrowse_Click(object sender, EventArgs e) { dtTemp.Columns.Clear(); string strCurrentDB = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\HisPurchase.xml", "Config/SourceDB"), "DBType"); if (string.IsNullOrEmpty(strCurrentDB)) { ComUtil.MsgBox("没有进行字段匹配,无法导入!"); return; } //选择待导入的文件 string strFileName = string.Empty; if (strCurrentDB.CompareTo("EXCEL") == 0) { openFileDialog1.Filter = "Excel文档(*.xls)|*.xls"; } //openFileDialog1.Filter = "DBF文档(*.dbf)|*.dbf|Excel文档(*.xls)|*.xls"; openFileDialog1.FilterIndex = 1; openFileDialog1.Title = "打开文件"; openFileDialog1.InitialDirectory = System.Windows.Forms.Application.StartupPath; openFileDialog1.RestoreDirectory = true; openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); try { strFileName = openFileDialog1.FileName; if (!string.IsNullOrEmpty(strFileName)) { this.txtImportFilePath.Text = strFileName; ClientConfiguration.HisPath = strFileName; if (strCurrentDB.CompareTo("EXCEL") == 0) { ClientConfiguration.ConnectionString = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + strFileName + ";Extended Properties=Excel 8.0"; } ClientConfiguration.Save(); string sql = FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\HisPurchase.xml", "Config/Sqls/Sql").InnerText; dtRequestSend = RequestSendDal.GetInstance().GetRequestSend(sql); dtRequestSend.Columns.Add("type"); //采购单明细id dtRequestSend.Columns.Add("state"); dtRequestSend.Columns.Add("emedProductId"); dtRequestSend.Columns.Add("emedSpecId"); dtRequestSend.Columns.Add("emedModelId"); dtRequestSend.Columns.Add("emedSenderId"); dtRequestSend.Columns.Add("emedSenderName"); dtRequestSend.Columns.Add("emedSenderEasy"); dtRequestSend.Columns.Add("selfpackage"); dtRequestSend.Columns.Add("factoryeasy"); dtRequestSend.Columns["Price"].DataType = Type.GetType("System.Double"); this.bindingSource1.DataSource = null; this.bindingSource1.DataSource = dtRequestSend; //获取耗材和医院匹配数据 SetErpSendMapData(); this.button1.Enabled = true; this.btnImport.Enabled = true; } } catch (Exception m) { this.bindingSource1.DataSource = null; ComUtil.MsgBox("不是有效的数据文件!"); } }
private void btnView_Click(object sender, EventArgs e) { string strCurrentDB = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\HisProductMapList.xml", "Config/SourceDB"), "DBType"); if (string.IsNullOrEmpty(strCurrentDB)) { ComUtil.MsgBox("没有进行字段匹配,无法导入!"); return; } //选择待导入的文件 string str = ""; if (strCurrentDB.CompareTo("EXCEL") == 0) { openFileDialog1.Filter = "Excel文档(*.xls)|*.xls"; } if (strCurrentDB.CompareTo("ACCESS") == 0) { openFileDialog1.Filter = "MDB文档(*.mdb)|*.mdb"; } openFileDialog1.FilterIndex = 1; openFileDialog1.Title = "打开文件"; openFileDialog1.InitialDirectory = EmedFunc.GetLocalPersonCfgPath(); openFileDialog1.RestoreDirectory = true; openFileDialog1.FileName = ""; openFileDialog1.ShowDialog(); try { str = openFileDialog1.FileName; if (!string.IsNullOrEmpty(str)) { this.txtImportFilePath.Text = str; ClientConfiguration.HisPath = str; string sql = string.Empty; if (strCurrentDB.CompareTo("EXCEL") == 0) { ClientConfiguration.ConnectionString = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + str + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'"; sql = FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\HisProductMapList.xml", "Config/Sqls/Sql").InnerText; } if (strCurrentDB.CompareTo("ACCESS") == 0) { string password = SecretUtil.DeSecret(FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/HisProductMapList.xml", "Config/DestDB"), "Password")); ClientConfiguration.ConnectionString = " Provider = Microsoft.Jet.OLEDB.4.0 ;Jet OLEDB:Database Password="******"; Data Source = " + str + ";"; sql = FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\HisProductMapList.xml", "Config/ASqls/Sql").InnerText; } ClientConfiguration.Save(); DataTable dt = RequestSendDal.GetInstance().GetRequestSend(sql); dt.DefaultView.RowFilter = " PRODUCT_CODE is not null"; this.bindingSource1.DataSource = null; this.bindingSource1.DataSource = dt; } } catch (Exception ex) { this.bindingSource1.DataSource = null; ComUtil.MsgBox("不是有效的数据文件!"); } }
/// <summary> /// 获取耗材和医院匹配数据 /// </summary> private void SetErpSendMapData() { foreach (DataRow dgvr in dtRequestSend.Rows) { if (dgvr["ProductCode"] == null || dgvr["ProductCode"].ToString() == "") { continue; } string porductCode = ""; string buyerCode = ""; IList <ImputPurchaseModel> result = new List <ImputPurchaseModel>(); //int num = 0; if (dgvr["ProductCode"].GetType() == typeof(double)) { porductCode = int.Parse(dgvr["ProductCode"].ToString()).ToString(); } else { porductCode = dgvr["ProductCode"].ToString(); } //判断供应商匹配 if (dgvr["SenderCode"].GetType() == typeof(double)) { buyerCode = int.Parse(dgvr["SenderCode"].ToString()).ToString(); } else { buyerCode = dgvr["SenderCode"].ToString(); } string emedProductId = ""; string emedSpecId = ""; string emedModelId = ""; string emedPrice = ""; string emedcommonname = ""; string emedproductname = ""; string selfpackage = ""; string factoryname = ""; string factoryeasy = ""; string emedHis = ""; string emedsendername = ""; string emedsendereasy = ""; string emedbrand = ""; DataTable dtproduct = RequestSendDal.GetInstance().GetProductMapData(porductCode, base.CurrentUserOrgId); if (dtproduct.Rows.Count > 0) { emedProductId = dtproduct.Rows[0]["PROJECT_PROD_ID"] == null ? "" : dtproduct.Rows[0]["PROJECT_PROD_ID"].ToString(); emedSpecId = dtproduct.Rows[0]["SPEC_ID"] == null ? "" : dtproduct.Rows[0]["SPEC_ID"].ToString(); emedModelId = dtproduct.Rows[0]["MODE_ID"] == null ? "" : dtproduct.Rows[0]["MODE_ID"].ToString(); emedPrice = dtproduct.Rows[0]["PRICE"] == null ? "0" : dtproduct.Rows[0]["PRICE"].ToString(); emedcommonname = dtproduct.Rows[0]["COMMON_NAME"] == null ? "" : dtproduct.Rows[0]["COMMON_NAME"].ToString(); emedproductname = dtproduct.Rows[0]["PRODUCT_NAME"] == null ? "" : dtproduct.Rows[0]["PRODUCT_NAME"].ToString(); selfpackage = dtproduct.Rows[0]["SELF_PACKAGE"] == null ? "1" : dtproduct.Rows[0]["SELF_PACKAGE"].ToString(); factoryname = dtproduct.Rows[0]["MANU_NAME"] == null ? "" : dtproduct.Rows[0]["MANU_NAME"].ToString(); factoryeasy = dtproduct.Rows[0]["MANU_NAME_ABBR"] == null ? "" : dtproduct.Rows[0]["MANU_NAME_ABBR"].ToString(); emedbrand = dtproduct.Rows[0]["BRAND"] == null ? "" : dtproduct.Rows[0]["BRAND"].ToString(); } DataTable dtsender = RequestSendDal.GetInstance("ClientDB").GetIPMapData(base.CurrentUserOrgId, buyerCode); if (dtsender.Rows.Count > 0) { emedHis = dtsender.Rows[0]["ORG_ID"] == null ? "" : dtsender.Rows[0]["ORG_ID"].ToString(); emedsendername = dtsender.Rows[0]["FULL_NAME"] == null ? "" : dtsender.Rows[0]["FULL_NAME"].ToString(); emedsendereasy = dtsender.Rows[0]["EASY_NAME"] == null ? "" : dtsender.Rows[0]["EASY_NAME"].ToString(); } if (string.IsNullOrEmpty(emedProductId)) { if (string.IsNullOrEmpty(emedHis)) { dgvr["type"] = "1"; dgvr["state"] = "产品和配送企业未匹配"; } else { dgvr["type"] = "2"; dgvr["state"] = "产品未匹配"; } } else { if (string.IsNullOrEmpty(emedHis)) { dgvr["type"] = "3"; dgvr["state"] = "配送企业未匹配"; } else { dgvr["type"] = "0"; dgvr["state"] = "匹配成功"; dgvr["emedProductId"] = emedProductId; dgvr["emedSpecId"] = emedSpecId; dgvr["emedModelId"] = emedModelId; dgvr["emedSenderId"] = emedHis; dgvr["emedSenderName"] = emedsendername; dgvr["emedSenderEasy"] = emedsendereasy; dgvr["Price"] = double.Parse(emedPrice); dgvr["InstruName"] = emedcommonname; dgvr["ProductName"] = emedproductname; dgvr["FactoryName"] = factoryname; dgvr["factoryeasy"] = factoryeasy; dgvr["selfpackage"] = selfpackage; dgvr["Brand"] = emedbrand; } } if (!"0".Equals(dgvr["type"].ToString())) { button1.Enabled = true; } } }