public SelectExpSendItem(string procode)
 {
     InitializeComponent();
     //dt=ProxyFactory.ErpSendRemote.GetErpProductByProcode(procode, base.CurrentUserOrgId);
     dt = GpoSendBLL.GetInstance().GetErpProductByProcode(procode, base.CurrentUserOrgId);
     this.bindingSource1.DataSource = dt.DefaultView;
     lblRegText.Text = "产品编码 " + procode + " 对应了以上" + dgvErpSend.RowCount.ToString() + "条产品数据,请选择!";
 }
        private void showMenu(string procode)
        {
            //dt = ProxyFactory.ErpSendRemote.GetErpProductByProcode(procode, base.CurrentUserOrgId);
            dt = GpoSendBLL.GetInstance().GetErpProductByProcode(procode, base.CurrentUserOrgId);

            cms.ShowImageMargin = false;
            cms.Items.Clear();
            cms.DropShadowEnabled = true;
            string str = "";

            foreach (DataRow dr in dt.Rows)
            {
                str = "产品名称:" + dr["PRODUCT_NAME"].ToString().Trim() + " 剂型:" + dr["MODE_NAME"].ToString().Trim() + " 规格:" + dr["MEDICAL_SPEC"].ToString().Trim() + " 包装单位:" + dr["SPEC_UNIT"].ToString().Trim() + " 生产企业:" + dr["FACTORY_NAME"].ToString().Trim() + " 批号:" + dr["PERMIT_NO"].ToString().Trim();
                cms.Items.Add(str);
                cms.ItemClicked += new ToolStripItemClickedEventHandler(cms_ItemClicked);
            }
        }
Esempio n. 3
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);
                    }
                }
            }
        }
        /// <summary>
        /// 获取药品和医院匹配数据
        /// </summary>
        private void setErpSendMapData(out int count)
        {
            count = 0;
            foreach (DataGridViewRow dgvr in dgvErpSend.Rows)
            {
                if (dgvr.Cells["PRODUCT_CODE"].Value == null || dgvr.Cells["PRODUCT_CODE"].Value.ToString() == "")
                {
                    continue;
                }
                string porductCode = "";
                string buyerCode   = "";
                if (dgvr.Cells["PRODUCT_CODE"].ValueType == typeof(double))
                {
                    porductCode = int.Parse(dgvr.Cells["PRODUCT_CODE"].Value.ToString()).ToString();
                }
                else
                {
                    porductCode = dgvr.Cells["PRODUCT_CODE"].Value.ToString();
                }
                if (dgvr.Cells["BUYER_CODE"].ValueType == typeof(double))
                {
                    buyerCode = int.Parse(dgvr.Cells["BUYER_CODE"].Value.ToString()).ToString();
                }
                else
                {
                    buyerCode = dgvr.Cells["BUYER_CODE"].Value.ToString();
                }

                string emedProduct = GpoSendBLL.GetInstance().GetProductMapData(porductCode, base.CurrentUserOrgId, out pronum);
                string emedHis     = GpoSendBLL.GetInstance().GetCorpMapData(buyerCode, base.CurrentUserOrgId, out cropnum);

                if (int.Parse(pronum.ToString()) > 1)
                {
                    dgvr.Cells["product_code"].Style.SelectionForeColor = Color.Red;
                    dgvr.Cells["product_code"].Style.ForeColor          = Color.Red;
                    count++;
                }
                if (string.IsNullOrEmpty(emedProduct))
                {
                    if (string.IsNullOrEmpty(emedHis))
                    {
                        dgvr.Cells["type"].Value  = "1";
                        dgvr.Cells["state"].Value = "药品和买方未匹配";
                    }
                    else
                    {
                        dgvr.Cells["type"].Value  = "2";
                        dgvr.Cells["state"].Value = "药品未匹配";
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(emedHis))
                    {
                        dgvr.Cells["type"].Value  = "3";
                        dgvr.Cells["state"].Value = "买方未匹配";
                    }
                    else if (!emedHis.Equals(BuyerOrgid))
                    {
                        dgvr.Cells["type"].Value  = "4";
                        dgvr.Cells["state"].Value = "买方信息不对应";
                    }
                    else
                    {
                        dgvr.Cells["type"].Value            = "0";
                        dgvr.Cells["state"].Value           = "匹配成功";
                        dgvr.Cells["EmedProductCode"].Value = emedProduct;
                    }
                }
            }
        }
        /// <summary>
        /// 导入按钮的操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (this.bindingSource1.DataSource == null)
            {
                return;
            }

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

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

            if (clientPlat.Equals("1"))
            {
                RetOrderItem(out iCount);
            }
            else
            {
                DataTable dtNotMapProd       = GetImportTable();
                DataTable dtNotMapEnterprise = new DataTable();
                dtNotMapEnterprise = GpoSendBLL.GetInstance().GetNotMapData(ref dtNotMapProd, base.CurrentUserOrgId);

                if (dtNotMapProd.Rows.Count > 0)
                {
                    DataColumn dc = new DataColumn("IsMap");
                    dc.DataType     = System.Type.GetType("System.String");
                    dc.DefaultValue = "未匹配";
                    dtNotMapProd.Columns.Add(dc);
                    ProductMapAuto productmapauto = new ProductMapAuto(dtNotMapProd);
                    productmapauto.ShowDialog();
                }
                if (dtNotMapEnterprise.Rows.Count > 0)
                {
                    DataColumn dc = new DataColumn("IsMap");
                    dc.DataType     = System.Type.GetType("System.String");
                    dc.DefaultValue = "未匹配";
                    dtNotMapEnterprise.Columns.Add(dc);
                    EnterpriseMapAuto enterprisemapauto = new EnterpriseMapAuto(dtNotMapEnterprise);
                    enterprisemapauto.ShowDialog();
                }

                setErpSendMapData(out iCount);
            }



            IList result = new ArrayList();

            foreach (DataGridViewRow dgvr in dgvErpSend.Rows)
            {
                //"导出采购订单"判断业务流程("进销存"企业对接功能),shangfu 2007-8-28
                //如果为1就是进销存对接接口
                if (clientPlat.Equals("1"))
                {
                    if (dgvr.Cells["ordItemId"].Value == null || dgvr.Cells["ordItemId"].Value.ToString() == "")
                    {
                        continue;
                    }
                }
                else
                {
                    if (dgvr.Cells["PRODUCT_CODE"].Value == null || dgvr.Cells["PRODUCT_CODE"].Value.ToString() == "")
                    {
                        continue;
                    }
                }

                if ("0".Equals(dgvr.Cells["type"].Value.ToString()))
                {
                    setOrderItem(dgvr, result);
                }
            }

            SalerOrderItemList frm = new SalerOrderItemList(OrderId, Flag, result);

            frm.ShowDialog();
            this.Close();
        }