Exemplo n.º 1
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("不是有效的数据文件!");
            }
        }
Exemplo n.º 2
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);
                    }
                }
            }
        }
 private GpoSendBLL(string connectionName)
 {
     dao = GpoSendDao.GetInstance(connectionName);
 }
        /// <summary>
        /// 获取导入的发货列表
        /// </summary>
        /// <returns></returns>
        private DataTable GetImportTable()
        {
            string sql = FileOperation.GetNodeObject(EmedFunc.GetLocalPersonCfgPath() + @"\GpoOrderSend.xml", "Config/Sqls/Sql").InnerText;

            return(GpoSendDao.GetInstance().GetErpSend(sql));
        }
 private GpoSendBLL()
 {
     dao = GpoSendDao.GetInstance();
 }