/// <summary>
        ///  根据MDM洲信息来编辑Entity
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            Dbconn conn = new Dbconn("MDM_Master");

            try
            {
                string strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                string strStoreEntityCode = "0011";
                string strMarketTableName = "Continent_For_FM";

                DataSet ds = Common.Common.GetDSByExcelXML(strXML);

                //获取洲的所有属性
                MDM_Entity_Market_PropertyList clsPropertyList = new MDM_Entity_Market_PropertyList();
                clsPropertyList.Request = Common.Common.GetRequestDataSet(new string[2] { "Entity", "MarketTableName" }, new string[2] { strStoreEntityCode, strMarketTableName });
                DataTable dt_PropertyList = clsPropertyList.GetData().Tables[0];

                //修改洲数据
                string strUpdateXML = "<table Entity=\"" + strStoreEntityCode + "\" Expression=\"CN\">";

                for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                {

                    strUpdateXML += "<row>";
                    strUpdateXML += "<body_ID>" + ds.Tables["LIST"].Rows[i]["body_ID"].ToString() + "</body_ID>";

                    for (int j = 0; j < ds.Tables["LIST"].Columns.Count; j++)
                    {
                        string strColumnName = ds.Tables["LIST"].Columns[j].ColumnName;

                        //如果修改的列是属于洲信息的话,要对洲的Entity进行修改
                        DataRow[] drList = dt_PropertyList.Select("Table_Property_Name = '" + strColumnName + "'");
                        if (drList.Length > 0)
                        {
                            string strPorpertyname = drList[0]["Porperty_Name"].ToString();
                            strUpdateXML += "<" + strPorpertyname + ">" + ds.Tables["LIST"].Rows[i][j].ToString() + "</" + strPorpertyname + ">";

                        }
                    }
                    strUpdateXML += "</row>";

                }
                strUpdateXML += "</table>";

                MDM_Entity_Edit cls_Entity_Edit = new MDM_Entity_Edit();
                cls_Entity_Edit.Request = Common.Common.GetRequestDataSet(new string[1] { "XML" }, new string[1] { strUpdateXML });
                cls_Entity_Edit.Execute();

                return Common.Common.GetRequestDataSet(new string[1] { "result" }, new string[1] { "true" });
            }
            catch
            {

                throw;
            }
        }
        /// <summary>
        /// 根据MDM销售大区来编辑Entity
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            Dbconn conn = new Dbconn("MDM_Master");

            try
            {
                string strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                string strEntityCode = "0018";
                string strMarketTableName = "SaleArea_For_FM";

                DataSet ds = Common.Common.GetDSByExcelXML(strXML);

                //获取销售大区的所有属性
                MDM_Entity_Market_PropertyList clsPropertyList = new MDM_Entity_Market_PropertyList();
                clsPropertyList.Request = Common.Common.GetRequestDataSet(new string[2] { "Entity", "MarketTableName" }, new string[2] { strEntityCode, strMarketTableName });
                DataTable dt_PropertyList = clsPropertyList.GetData().Tables[0];

                //修改销售大区数据
                DataTable dtSaleArea = new DataTable(strEntityCode);
                dtSaleArea.Namespace = "CN"; //定义表达方式

                DataTable dtSaleAreaLink = new DataTable("L0014");
                dtSaleAreaLink.Namespace = "CN"; //定义表达方式

                dtSaleAreaLink.Columns.Add("Body_ID");
                dtSaleAreaLink.Columns.Add("Body_ID_0008");
                dtSaleAreaLink.Columns.Add("Body_ID_0018");

                bool bCreateTable = true;

                for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                {
                    DataRow dr = dtSaleArea.NewRow();
                    DataRow drLink = dtSaleAreaLink.NewRow();

                    //drLink["body_ID"] = ds.Tables["LIST"].Rows[i]["body_ID"].ToString();
                    drLink["Body_ID_0008"] = ds.Tables["LIST"].Rows[i]["Body_ID_0008"].ToString();
                    
                    if (drLink["Body_ID_0008"].ToString() == "")
                    {
                        throw new Exception("店铺品牌的Body_ID不能为空!");
                    }
                    dtSaleAreaLink.Rows.Add(drLink);


                    if (bCreateTable)
                    {
                        dtSaleArea.Columns.Add("body_ID");
                    }


                    dr["body_ID"] = ds.Tables["LIST"].Rows[i]["body_ID_0018"].ToString();
                    for (int j = 0; j < ds.Tables["LIST"].Columns.Count; j++)
                    {
                        string strColumnName = ds.Tables["LIST"].Columns[j].ColumnName;

                        //如果修改的列是属于品牌信息的话,要对品牌的Entity进行修改
                        DataRow[] drList = dt_PropertyList.Select("Table_Property_Name = '" + strColumnName + "'");
                        if (drList.Length > 0)
                        {
                            string strPorpertyname = drList[0]["Porperty_Name"].ToString();

                            if (bCreateTable)
                            {
                                dtSaleArea.Columns.Add(strPorpertyname);
                            }
                            dr[strPorpertyname] = ds.Tables["LIST"].Rows[i][j].ToString();

                        }
                    }

                    dtSaleArea.Rows.Add(dr);
                    bCreateTable = false;

                }

                DataSet dsRequest = new DataSet();
                dsRequest.Tables.Add(dtSaleArea);

                MDM_Entity_Edit cls_Entity_Edit = new MDM_Entity_Edit();
                cls_Entity_Edit.Request = dsRequest;
                cls_Entity_Edit.GetDataByRequestDs = true;
                cls_Entity_Edit.Execute();

                ArrayList listBody_0018 = cls_Entity_Edit.BodyID; //获取品牌的BODYID

                //修改LINK数据
                for (int i = 0; i < listBody_0018.Count; i++)
                {
                    dtSaleAreaLink.Rows[i]["Body_ID_0018"] = listBody_0018[i].ToString();

                    //到表里查找Link的BodyID
                    string strSQL = "SELECT Body_ID FROM MDM_L0014_B WHERE Body_ID_0018='" + listBody_0018[i].ToString() + "'";
                    string strLinkBodyID = conn.GetDataTableFirstValue(strSQL).ToString();

                    dtSaleAreaLink.Rows[i]["Body_ID"] = strLinkBodyID;


                }
                dsRequest.Clear();
                dsRequest.Tables.Add(dtSaleAreaLink);
                cls_Entity_Edit.Request = dsRequest;
                cls_Entity_Edit.Execute();
                ArrayList listBody = cls_Entity_Edit.BodyID;
                string strMessage = "影响的行数为:" + listBody.Count.ToString() +"行" ;
                for (int i = 0; i < listBody.Count; i++)
                {
                    strMessage += ";" + listBody[i].ToString();
                }
                return Common.Common.GetRequestDataSet(new string[2] { "result", "Message" }, new string[2] { "true", strMessage });
            }
            catch
            {

                throw;
            }
        }
        /// <summary>
        ///  根据MDM国家区域信息来编辑Entity
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            Dbconn conn = new Dbconn("MDM_Master");

            try
            {
                string strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

               
                DataSet ds = Common.Common.GetDSByExcelXML(strXML);

                GetEntityCode(ds);

                if (m_EntityCode_S == "")
                {
                    return new DataSet();
                }

                ds.Tables["LIST"].Columns.Remove("type");


                //获所有属性
                MDM_Entity_Market_PropertyList clsPropertyList = new MDM_Entity_Market_PropertyList();
                clsPropertyList.Request = Common.Common.GetRequestDataSet(new string[2] { "Entity", "MarketTableName" }, new string[2] { m_EntityCode_S, m_MKTTableName });
                DataTable dt_PropertyList = clsPropertyList.GetData().Tables[0];

                //修改国家数据
                string strUpdateXML = "<table Entity=\"" + m_EntityCode_S + "\" Expression=\"CN\">";

                for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                {

                    strUpdateXML += "<row>";
                    strUpdateXML += "<body_ID>" + ds.Tables["LIST"].Rows[i]["body_ID_" + m_EntityCode_S].ToString() + "</body_ID>";

                    for (int j = 0; j < ds.Tables["LIST"].Columns.Count; j++)
                    {
                        string strColumnName = ds.Tables["LIST"].Columns[j].ColumnName;

                        //如果修改的列是属于国家信息的话,要对洲的Entity进行修改
                        DataRow[] drList = dt_PropertyList.Select("Table_Property_Name = '" + strColumnName + "'");
                        if (drList.Length > 0)
                        {
                            string strPorpertyname = drList[0]["Porperty_Name"].ToString();
                            strUpdateXML += "<" + strPorpertyname + ">" + ds.Tables["LIST"].Rows[i][j].ToString() + "</" + strPorpertyname + ">";

                        }
                    }
                    strUpdateXML += "</row>";

                }
                strUpdateXML += "</table>";

                MDM_Entity_Edit cls_Entity_Edit = new MDM_Entity_Edit();
                cls_Entity_Edit.Request = Common.Common.GetRequestDataSet(new string[1] { "XML" }, new string[1] { strUpdateXML });
                cls_Entity_Edit.Execute();
                ArrayList alBodyID = cls_Entity_Edit.BodyID;

                //修改国家与洲的Link
                strUpdateXML = "<table Entity=\"" + m_LinkEntityCode + "\" Expression=\"CN\">";

                for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                {
                    //获取国家的bodyid
                    string strBodyID = alBodyID[i].ToString();
                    
                    //到表里查找Link的BodyID
                    string strSQL = "SELECT Body_ID FROM MDM_" + m_LinkEntityCode + "_B WHERE Body_ID_" + m_EntityCode_S + "='" + strBodyID + "'";
                    string strLinkBodyID = conn.GetDataTableFirstValue(strSQL).ToString();

                    strUpdateXML += "<row>";
                    strUpdateXML += "<body_ID>" + strLinkBodyID + "</body_ID>";
                    strUpdateXML += "<body_ID_" + m_EntityCode_S + ">" + strBodyID + "</body_ID_" + m_EntityCode_S + ">";
                    strUpdateXML += "<body_ID_" + m_EntityCode_P + ">" + ds.Tables["LIST"].Rows[i]["body_ID_" + m_EntityCode_P].ToString() + "</body_ID_" + m_EntityCode_P + ">";

                    strUpdateXML += "</row>";

                }
                strUpdateXML += "</table>";
                cls_Entity_Edit.Request = Common.Common.GetRequestDataSet(new string[1] { "XML" }, new string[1] { strUpdateXML });
                cls_Entity_Edit.Execute();

                return Common.Common.GetRequestDataSet(new string[1] { "result" }, new string[1] { "true" });
            }
            catch
            {

                throw;
            }
        }
        /// <summary>
        /// 根据MDM店铺的Market数据来编辑Entity
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            Dbconn conn = new Dbconn("MDM_Master");

            try
            {
                string strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                string strEntityCode = "0006";
                string strMarketTableName = "Store_For_FM";

                DataSet ds = Common.Common.GetDSByExcelXML(strXML);

                //获取店铺的所有属性
                MDM_Entity_Market_PropertyList clsPropertyList = new MDM_Entity_Market_PropertyList();
                clsPropertyList.Request = Common.Common.GetRequestDataSet(new string[2] { "Entity", "MarketTableName" }, new string[2] { strEntityCode, strMarketTableName });
                DataTable dt_PropertyList = clsPropertyList.GetData().Tables[0];

                //修改店铺数据
                DataTable dtStore = new DataTable(strEntityCode);
                dtStore.Namespace = "CN"; //定义表达方式

                DataTable dtStoreLink = new DataTable("L0013");
                dtStoreLink.Namespace = "CN"; //定义表达方式

                dtStoreLink.Columns.Add("Body_ID");
                dtStoreLink.Columns.Add("Body_ID_0001");
                dtStoreLink.Columns.Add("Body_ID_0006");
                dtStoreLink.Columns.Add("Body_ID_0010");
                dtStoreLink.Columns.Add("Body_ID_L0011");
                dtStoreLink.Columns.Add("Body_ID_L0014");

                bool bCreateTable = true;

                GetBaseData(ds.Tables["LIST"]);

                for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                {
                    DataRow dr = dtStore.NewRow();
                    DataRow drLink = dtStoreLink.NewRow();

                    drLink["body_ID"] = ds.Tables["LIST"].Rows[i]["body_ID"].ToString();

                    DataTable dtLinkOld = new DataTable();
                    string strLinkBody_ID = drLink["body_ID"].ToString().Trim();
                    if (strLinkBody_ID != "")
                    {
                        //获取所有的BODY_ID数据
                        dtLinkOld = conn.GetDataTable(@"SELECT * FROM MDM_L0013_B WHERE Body_ID='"+strLinkBody_ID+"'");
                        if (dtLinkOld.Rows.Count == 0)
                        {
                            throw new Exception("传入的BodyID不正确");
                        }
                    }

                    //取到对应的BodyID
                    if (ds.Tables["LIST"].Columns.Contains("公司中文简称"))
                    {
                        string str公司中文简称 = ds.Tables["LIST"].Rows[i]["公司中文简称"].ToString();
                        if (str公司中文简称 != "")
                        {
                            drLink["Body_ID_0001"] = GetBodyID("公司", "公司中文简称='" + str公司中文简称 + "'");
                        }

                        if (drLink["Body_ID_0001"].ToString() == "")
                        {
                            if (strLinkBody_ID != "")
                            {
                                //如果没有传入公司信息的话,可能是由于用户没有权限,所以使用旧值
                                drLink["Body_ID_0001"] = dtLinkOld.Rows[0]["Body_ID_0001"];
                            }
                            else
                            {
                                //如果是添加状态的话,必须要有BodyID
                                throw new Exception("公司中文简称的信息不正确或者没有权限!");
                            }
                        }
                    }
                    else
                    {
                        if (strLinkBody_ID != "")
                        {
                            //如果没有传入公司信息的话,可能是由于用户没有权限,所以使用旧值
                            drLink["Body_ID_0001"] = dtLinkOld.Rows[0]["Body_ID_0001"];
                        }
                    }

                    if (ds.Tables["LIST"].Columns.Contains("加盟商编码"))
                    {
                        string str加盟商编码 = ds.Tables["LIST"].Rows[i]["加盟商编码"].ToString();
                        if (str加盟商编码 != "")
                        {
                            drLink["Body_ID_0010"] = GetBodyID("加盟商", "加盟商编码='" + str加盟商编码 + "'");
                        }

                        if (drLink["Body_ID_0010"].ToString() == "")
                        {
                            if (strLinkBody_ID != "")
                            {
                                //如果没有传入加盟商信息的话,可能是由于用户没有权限,所以使用旧值
                                drLink["Body_ID_0010"] = dtLinkOld.Rows[0]["Body_ID_0010"];
                            }
                            else
                            {
                                //如果是添加状态的话,必须要有BodyID
                                throw new Exception("加盟商编码的信息不正确或者没有权限!");
                            }
                        }
                    }
                    else
                    {
                        if (strLinkBody_ID != "")
                        {
                            //如果没有传入加盟商信息的话,可能是由于用户没有权限,所以使用旧值
                            drLink["Body_ID_0010"] = dtLinkOld.Rows[0]["Body_ID_0010"];
                        }
                       
                    }
                    string str加盟商Body_id = drLink["Body_ID_0010"].ToString();

                    //添加状态下,如果加盟商编码为空的话,就无法生成POS编号,所以是不允许的
                    if (strLinkBody_ID == "" && str加盟商Body_id == "")
                    {
                        throw new Exception("加盟商编码的信息不正确");
                    }

                    if (ds.Tables["LIST"].Columns.Contains("县级市编号"))
                    {
                        string str县级市 = ds.Tables["LIST"].Rows[i]["县级市编号"].ToString();

                        if (str县级市 != "")
                        {
                            drLink["Body_ID_L0011"] = GetBodyID("县", "县级市编号='" + str县级市 + "'");
                        }

                        if (drLink["Body_ID_L0011"].ToString() == "")
                        {
                            if (strLinkBody_ID != "")
                            {
                                //如果没有传入县级市信息的话,可能是由于用户没有权限,所以使用旧值
                                drLink["Body_ID_L0011"] = dtLinkOld.Rows[0]["Body_ID_L0011"];
                            }
                        }
                    }

                    if (ds.Tables["LIST"].Columns.Contains("销售大区名称"))
                    {
                        string str销售大区名称 = ds.Tables["LIST"].Rows[i]["销售大区名称"].ToString();

                        if (str销售大区名称 != "")
                        {
                            drLink["Body_ID_L0014"] = GetBodyID("销售大区", "销售大区名称='" + str销售大区名称 + "'");
                        }

                        if (drLink["Body_ID_L0014"].ToString() == "")
                        {
                            if (strLinkBody_ID != "")
                            {
                                //如果没有传入销售大区信息的话,可能是由于用户没有权限,所以使用旧值
                                drLink["Body_ID_L0014"] = dtLinkOld.Rows[0]["Body_ID_L0014"];
                            }
                        }
                    }
                    dtStoreLink.Rows.Add(drLink);

                    if (bCreateTable)
                    {
                        dtStore.Columns.Add("body_ID");
                    }

                    dr["body_ID"] = ds.Tables["LIST"].Rows[i]["body_ID_0006"].ToString();

                    if (dr["body_ID"].ToString().Trim() == "")
                    {
                        ds.Tables["LIST"].Rows[i]["POS编号"] = GetStoreCode(str加盟商Body_id,conn);
                    }

                    for (int j = 0; j < ds.Tables["LIST"].Columns.Count; j++)
                    {
                        string strColumnName = ds.Tables["LIST"].Columns[j].ColumnName;

                        //如果修改的列是属于店铺信息的话,要对店铺的Entity进行修改
                        DataRow[] drList = dt_PropertyList.Select("Table_Property_Name = '" + strColumnName + "'");
                        if (drList.Length > 0)
                        {
                            string strPorpertyname = drList[0]["Porperty_Name"].ToString();
                                                        
                            if (bCreateTable)
                            {
                                dtStore.Columns.Add(strPorpertyname);
                            }
                            dr[strPorpertyname] = ds.Tables["LIST"].Rows[i][j].ToString();

                        }
                    }

                    dtStore.Rows.Add(dr);
                    bCreateTable = false;

                }

                DataSet dsRequest = new DataSet();
                dsRequest.Tables.Add(dtStore);

                MDM_Entity_Edit cls_Entity_Edit = new MDM_Entity_Edit();
                cls_Entity_Edit.Request = dsRequest;
                cls_Entity_Edit.GetDataByRequestDs = true;
                cls_Entity_Edit.Execute();

                ArrayList listBody_0006 = cls_Entity_Edit.BodyID; //获取店铺的BODYID

                //修改LINK数据
                for (int i = 0; i < listBody_0006.Count; i++)
                {
                    dtStoreLink.Rows[i]["Body_ID_0006"] = listBody_0006[i].ToString();
                }
                dsRequest.Clear();
                dsRequest.Tables.Add(dtStoreLink);
                cls_Entity_Edit.Request = dsRequest;
                cls_Entity_Edit.Execute();

                ArrayList listBody = cls_Entity_Edit.BodyID;
                string strMessage = "影响的行数为:" + listBody.Count.ToString() + "行";
                for (int i = 0; i < listBody.Count; i++)
                {
                    strMessage += ";" + listBody[i].ToString();
                }
                return Common.Common.GetRequestDataSet(new string[2] { "result", "Message" }, new string[2] { "true", strMessage });
            }
            catch
            {

                throw;
            }
        }
        /// <summary>
        /// 根据MDM加盟商信息来编辑Entity
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            Dbconn conn = new Dbconn("MDM_Master");

            try
            {
                string strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                string strStoreEntityCode = "0010";
                string strMarketTableName = "Merchant_For_FM";

                DataSet ds = Common.Common.GetDSByExcelXML(strXML);
                               
                //判断Link是否需要修改

                //获取加盟商的所有属性
                MDM_Entity_Market_PropertyList clsPropertyList = new MDM_Entity_Market_PropertyList();
                clsPropertyList.Request = Common.Common.GetRequestDataSet(new string[2] { "Entity", "MarketTableName" }, new string[2] { strStoreEntityCode, strMarketTableName });
                DataTable dt_PropertyList = clsPropertyList.GetData().Tables[0];

                //修改加盟商数据
                string strUpdateXML = "<table Entity=\"" + strStoreEntityCode + "\" Expression=\"CN\">";

                int nMaxCode = 0;


                for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                {

                    strUpdateXML += "<row>";
                    strUpdateXML += "<body_ID>" + ds.Tables["LIST"].Rows[i]["body_ID"].ToString() + "</body_ID>";

                    //新增
                    if (ds.Tables["LIST"].Rows[i]["body_ID"].ToString() == "")
                    {
                        //判断公司
                        string strComCode = GetComCode(ds.Tables["LIST"].Rows[i]["公司"].ToString());

                        if (strComCode == "")
                        {
                            throw new Exception("公司不正确。");
                        }


                        string strCode = "";


                        string strMaxCode = "";

                        if (m_MaxCodeName.Contains(strComCode))
                        {
                            strMaxCode = m_MaxCode[m_MaxCodeName.IndexOf(strComCode)].ToString();
                        }
                        else
                        {
                            strMaxCode = conn.GetDataTableFirstValue(@"
                                        SELECT  MAX(Value_Text) AS code
                                        FROM    [dbo].[Lib_ExdPropertyList] t1 
                                                LEFT JOIN dbo.MDM_0010_E t2 ON t1.Property_ID = t2.Property_ID
                                        WHERE   Class_name = '0010' AND property_name = '加盟商编码' AND Body_ID IN (
                                                SELECT  t2.Body_ID
                                                FROM    [dbo].[Lib_ExdPropertyList] t1
                                                        LEFT JOIN dbo.MDM_0010_E t2 ON t1.Property_ID = t2.Property_ID
                                                WHERE   Property_Name = '公司' AND t2.Value_Text = '" + ds.Tables["LIST"].Rows[i]["公司"].ToString() + @"' )
                            ").ToString();

                        }


                        if (strMaxCode == "" || strMaxCode == strComCode + "0001")
                        {
                            strCode = strComCode + "1000";
                        }
                        else
                        {
                            strCode = strComCode + (Convert.ToInt32(strMaxCode.Substring(1)) + 1).ToString();
                        }

                        if (m_MaxCodeName.Contains(strComCode))
                        {
                            m_MaxCode[m_MaxCodeName.IndexOf(strComCode)] = strCode;
                        }
                        else
                        {
                            m_MaxCode.Add(strCode);
                            m_MaxCodeName.Add(strComCode);
                        }

                        ds.Tables["LIST"].Rows[i]["加盟商编码"] = strCode;
                    }


                    for (int j = 0; j < ds.Tables["LIST"].Columns.Count; j++)
                    {
                        string strColumnName = ds.Tables["LIST"].Columns[j].ColumnName;

                        //如果修改的列是属于加盟商信息的话,要对加盟商的Entity进行修改
                        DataRow[] drList = dt_PropertyList.Select("Table_Property_Name = '" + strColumnName + "'");
                        if (drList.Length > 0)
                        {
                            string strPorpertyname = drList[0]["Porperty_Name"].ToString();
                            strUpdateXML += "<" + strPorpertyname + ">" + ds.Tables["LIST"].Rows[i][j].ToString() + "</" + strPorpertyname + ">";

                        }
                    }
                    strUpdateXML += "</row>";

                }
                strUpdateXML += "</table>";

                MDM_Entity_Edit cls_Entity_Edit = new MDM_Entity_Edit();
                cls_Entity_Edit.Request = Common.Common.GetRequestDataSet(new string[1] { "XML" }, new string[1] { strUpdateXML });
                cls_Entity_Edit.Execute();

                return Common.Common.GetRequestDataSet(new string[1] { "result" }, new string[1] { "true" });
            }
            catch
            {

                throw;
            }
        }