Beispiel #1
0
        private void InitSourceDBInfo(string inDBType)
        {
            try
            {
                switch (inDBType)
                {
                case "SQLSERVER":
                    this.cmbDBType.SelectedIndex = 0;
                    this.txtServer.Text          = Config.Intance().EleSource.GetAttribute("ServerName");
                    this.txtDataBase.Text        = Config.Intance().EleSource.GetAttribute("DataBase");
                    this.txtUser.Text            = Config.Intance().EleSource.GetAttribute("User");
                    this.txtPassword.Text        = SecretUtil.DeSecret(Config.Intance().EleSource.GetAttribute("Password"));
                    return;

                case "ACCESS":
                    this.cmbDBType.SelectedIndex = 1;
                    this.txtDataBase.Text        = "template.mdb";
                    this.txtPassword.Text        = SecretUtil.DeSecret(Config.Intance().EleSource.GetAttribute("Password"));
                    return;

                case "FOXPRO":
                    this.cmbDBType.SelectedIndex = 2;
                    this.txtDataBase.Text        = Application.StartupPath;
                    return;

                case "ORACLE":
                    this.cmbDBType.SelectedIndex = 3;
                    this.txtServer.Text          = Config.Intance().EleSource.GetAttribute("ServerName");
                    this.txtUser.Text            = Config.Intance().EleSource.GetAttribute("User");
                    this.txtPassword.Text        = SecretUtil.DeSecret(Config.Intance().EleSource.GetAttribute("Password"));
                    break;

                case "TXT":
                    this.cmbDBType.SelectedIndex = 5;
                    this.txtDataBase.Text        = Application.StartupPath;
                    break;

                case "EXCEL":
                    this.cmbDBType.SelectedIndex = 4;
                    this.txtDataBase.Text        = Config.Intance().CurrentExcelTemplet;
                    break;
                }
            }
            catch (Exception exception1)
            {
                ErrorLog.SaveLog("给源数据配置赋值", exception1);
            }
        }
Beispiel #2
0
        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 = GpoSendDao.GetInstance().GetErpSend(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("不是有效的数据文件!");
            }
        }
        private void btnView_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    this.openFileDialog.Filter = "Excel文件(*.xls)|*.xls|dbf文件(*.dbf)|*.dbf|文本文件(*.txt)|*.txt|所有文件 (*.*)|*.*";
            //    if (this.openFileDialog.ShowDialog() == DialogResult.OK)
            //    {
            //        if (this.openFileDialog.FileName == "")
            //        {
            //            EmedMessageBox.ShowWarning("请选择采购计划文件路径。");
            //        }
            //        else
            //        {
            //            this.txtFile.Text = this.openFileDialog.FileName;
            //            openFileDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath;
            //            openFileDialog.RestoreDirectory = true;
            //            Cursor.Current = Cursors.AppStarting;
            //            string dbfile = this.openFileDialog.FileNames[0];
            //            this.ExcelToDS(dbfile);

            //        }
            //    }
            //}
            //catch (Exception exception1)
            //{
            //    return;
            //}
            //finally
            //{
            //    Cursor.Current = Cursors.Default;
            //    GC.Collect();
            //}


            string strCurrentDB = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\HisHosptailMapList.xml", "Config/SourceDB"), "DBType");

            if (string.IsNullOrEmpty(strCurrentDB))
            {
                ComUtil.MsgBox("没有进行字段匹配,无法导入!");
                return;
            }
            //选择待导入的文件
            string str = "";

            if (strCurrentDB.CompareTo("EXCEL") == 0)
            {
                openFileDialog.Filter = "Excel文档(*.xls)|*.xls";
            }
            if (strCurrentDB.CompareTo("ACCESS") == 0)
            {
                openFileDialog.Filter = "MDB文档(*.mdb)|*.mdb";
            }
            //openFileDialog1.Filter = "DBF文档(*.dbf)|*.dbf|Excel文档(*.xls)|*.xls";
            openFileDialog.FilterIndex      = 1;
            openFileDialog.Title            = "打开文件";
            openFileDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FileName         = "";
            openFileDialog.ShowDialog();
            try
            {
                str = openFileDialog.FileName;
                if (!string.IsNullOrEmpty(str))
                {
                    this.txtFile.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() + @"\HisHosptailMapList.xml", "Config/Sqls/Sql").InnerText;
                    }
                    if (strCurrentDB.CompareTo("ACCESS") == 0)
                    {
                        string password = SecretUtil.DeSecret(FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/HisHosptailMapList.xml", "Config/DestDB"), "Password"));
                        ClientConfiguration.ConnectionString = " Provider = Microsoft.Jet.OLEDB.4.0 ;Jet OLEDB:Database Password="******"; Data Source = " + str + ";";
                        sql = FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\HisHosptailMapList.xml", "Config/ASqls/Sql").InnerText;
                    }

                    //ClientConfiguration.ConnectionString = ClientConfiguration.ConnectionString.Replace(ClientConfiguration.HisPath, str);
                    ClientConfiguration.Save();


                    DataTable dt = HosptailIDCompareDAO.GetInstance().GetEnterPrise(sql);
                    this.bindingSource.DataSource = null;
                    this.bindingSource.DataSource = dt;
                    this.lb_DgvCaptionText.Text   = "HIS买方编码:共 " + dt.DefaultView.Count + " 条记录";
                    //setErpSendMapData();
                }
            }
            catch (Exception)
            {
                this.bindingSource.DataSource = null;
                ComUtil.MsgBox("不是有效的数据文件!");
            }
        }
Beispiel #4
0
        /// <summary>
        /// 订单导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExpOrder_Click(object sender, EventArgs e)
        {
            int    iCount   = 0;
            string sOrderID = string.Empty;          //订单ID
            string sOrgID   = base.CurrentUserOrgId; //卖方机构ID

            if (this.dgvSalerOrderList.CurrentRow == null)
            {
                MessageBox.Show("请选择订单!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (this.dgvSalerOrderList.CurrentRow.Cells["order_id"].Value != null)
            {
                sOrderID = this.dgvSalerOrderList.CurrentRow.Cells["order_id"].Value.ToString();
            }
            //JudgeCropDataList(sOrderID, sOrgID);
            //判断是否有未匹配的数据

            //"导出采购订单"判断业务流程("进销存"企业对接功能),shangfu 2007-8-24
            //如果为1就是进销存对接接口

            string clientPlat = UserConfigXml.GetConfigInfo("ClientPlat", "type");

            if (IfHasNotMapData(sOrderID, sOrgID) && !clientPlat.Equals("1"))
            {
                MessageBox.Show("存在未匹配数据,导出失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //DataTable mapdt = ProxyFactory.ErpSendRemote.GetOrderExpData(orderid);

                DataTable mapdt = GpoSendBLL.GetInstance().GetOrderExpData(sOrderID, base.CurrentUserOrgId, clientPlat);
                DataTable dt    = new DataTable();

                //"导出采购订单"判断业务流程("进销存"企业对接功能),shangfu 2007-8-29
                if ("1".Equals(clientPlat))
                {
                    if (mapdt == null || mapdt.Rows.Count == 0)
                    {
                        return;
                    }
                    dt = mapdt.DefaultView.ToTable().Copy();


                    if (dt.Rows.Count == 0)
                    {
                        MessageBox.Show("导出失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                else
                {
                    if (mapdt == null || mapdt.Rows.Count == 0)
                    {
                        return;
                    }
                    mapdt.DefaultView.RowFilter = " productid is not null";
                    dt = mapdt.DefaultView.ToTable().Copy();
                    mapdt.DefaultView.RowFilter = " productid is null";
                }

                iCount = mapdt.DefaultView.Count;
                IList result = new ArrayList();

                foreach (DataColumn dc in dt.Columns)
                {
                    string newColName = getMapColName(dc.ColumnName.ToUpper());
                    if (!string.IsNullOrEmpty(newColName))
                    {
                        dc.ColumnName = newColName;
                    }
                    else
                    {
                        result.Add(dc.ColumnName);
                    }
                }
                for (int i = 0; i < result.Count; i++)
                {
                    dt.Columns.Remove(result[i].ToString());
                }
                string str = "";

                /******************************************************************
                *
                * 修改时间:2007-3-21
                * 修改人:ningbo
                * 修改原因:
                * 新增代码:EmedFunc.GetLocalPersonCfgPath()+"GpoOrderExport.xml"
                *
                ******************************************************************/
                string strCurrentDB = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/GpoOrderExport.xml", "Config/DestDB"), "DBType");
                this.saveFileDialog1.FilterIndex = 1;
                saveFileDialog1.Title            = "保存文件为";
                saveFileDialog1.InitialDirectory = Application.StartupPath;
                saveFileDialog1.RestoreDirectory = true;
                saveFileDialog1.FileName         = "ORD" + dgvSalerOrderList.CurrentRow.Cells["ORDER_CODE"].Value.ToString();
                if (strCurrentDB.Equals("EXCEL"))
                {
                    this.saveFileDialog1.Filter = "Excel文档(*.xls)|*.xls";
                    if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
                    {
                        str = saveFileDialog1.FileName;
                        bool flg = FileOperation.ExportExcelFile(dt, str);
                        if (flg)
                        {
                            string mess = "";
                            if (iCount > 0)
                            {
                                mess = "有" + iCount.ToString() + "条数据未被导出";
                            }
                            MessageBox.Show("导出完毕!" + mess, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
                //导出订单到SQLServer
                else if (strCurrentDB.Equals("SQLSERVER"))
                {
                    bool flag = false;
                    try
                    {
                        //获得SQLServer服务数据
                        string server   = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/GpoOrderExport.xml", "Config/DestDB"), "ServerName");
                        string database = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/GpoOrderExport.xml", "Config/DestDB"), "DataBase");
                        string user     = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/GpoOrderExport.xml", "Config/DestDB"), "User");
                        string password = SecretUtil.DeSecret(FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/GpoOrderExport.xml", "Config/DestDB"), "Password"));

                        //获得表明
                        string tableName = FileOperation.GetNodeValue(FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"/GpoOrderExport.xml", "Config/DestDB/DestTable"), "TableName");

                        //导出操作
                        flag = GpoSendDao.ExportErpToMSS(tableName, GetConString(server, database, user, password), dt);
                    }
                    catch
                    {
                        flag = false;
                    }
                    if (flag)
                    {
                        string mess = "";
                        if (iCount > 0)
                        {
                            mess = "有" + iCount.ToString() + "条数据未被导出";
                        }
                        MessageBox.Show("导出完毕!" + mess, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        MessageBox.Show("导出失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }