/// <summary> /// 编辑县级市信息 /// </summary> /// <returns></returns> public DataSet GetData() { Dbconn conn = new Dbconn("MDM_Master2"); try { DataSet ds_Return = new DataSet(); DataSet dsRequest = new DataSet(); string strXML = ""; strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); if (strXML == "") { throw new Exception("提交的XML为空!"); } DataSet dsXML = Common.Common.GetDSByExcelXML(strXML); DataTable dt_OPTYPE = dsXML.Tables["OPTYPE"]; string strMDM_Class = "0016"; string strMDM_LinkClass = "L0011"; conn.LockTableList.Add("MDM_" + strMDM_LinkClass + "_B"); conn.LockTableList.Add("MDM_" + strMDM_Class + "_B"); conn.LockTableList.Add("MDM_" + strMDM_LinkClass + "_E"); conn.LockTableList.Add("MDM_" + strMDM_Class + "_E"); conn.BeginTransaction(); //获取所有属性 MDM2_GetEntityPropertyList cls = new MDM2_GetEntityPropertyList(); cls.hzyMessage = this.hzyMessage; cls.MainEntity = strMDM_Class; DataTable dtPorperty = cls.GetData().Tables[0]; for (int i = 0; i < dt_OPTYPE.Rows.Count; i++) { DataTable dt_List = dsXML.Tables[i + 1]; if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "UPDATE" || dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT" ) { //插入BODY表 for (int j = 0; j < dt_List.Rows.Count; j++) { string strBody_id_0016 = ""; string strBody_id_L0011 = ""; string strBody_id_0015 = null;//用于存放地级市的信息,如果为null,表示不做变更,如果不为NULL,需要变更 if (dt_List.Columns.Contains("Body_id_0015")) { strBody_id_0015 = dt_List.Rows[j]["Body_id_0015"].ToString(); if (strBody_id_0015 != "") { //核对boid_ID是否存在 MDM2_BodyIDCheck clsCheck = new MDM2_BodyIDCheck(); clsCheck.Conn = conn; clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = "0015"; clsCheck.Body_ID = strBody_id_0015; if (clsCheck.Execute() == false) { throw new Exception("省的信息不正确!"); } } } strBody_id_0016 = dt_List.Rows[j]["body_ID_0016"].ToString(); strBody_id_L0011 = dt_List.Rows[j]["body_ID"].ToString(); MDM2_EntityCreatedBodyID_Edit clsBody = new MDM2_EntityCreatedBodyID_Edit(); if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT") { //处理0016的实体 clsBody.Conn = conn; clsBody.hzyMessage = hzyMessage; clsBody.MDMClass = strMDM_Class; clsBody.Execute(); strBody_id_0016 = clsBody.BodyID; if (strBody_id_0016 == "") { throw new Exception("BodyID_0016创建失败!"); } if (strBody_id_0015 == null) { throw new Exception("省信息不正确!"); } strBody_id_L0011 = ""; } else if (strBody_id_0016 != "" && strBody_id_L0011 != "") //更新 { //核对0010是否存在 MDM2_BodyIDCheck clsCheck = new MDM2_BodyIDCheck(); clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = strMDM_Class; clsCheck.Body_ID = strBody_id_0016; clsCheck.Conn = conn; if (clsCheck.Execute() == false) { throw new Exception("Body_id_0016信息不正确!"); } //核对L0010是否存在 clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = strMDM_LinkClass; clsCheck.Body_ID = strBody_id_L0011; clsCheck.Conn = conn; if (clsCheck.Execute() == false) { throw new Exception("Body_id_L0011信息不正确!"); } } else { throw new Exception("传入的参数有误,如果反复出现,请重新登录!"); } clsBody.MDMClass = strMDM_LinkClass; clsBody.BodyID = strBody_id_L0011; clsBody.LinkBodyIDList = strBody_id_0015 + "," + strBody_id_0016; clsBody.Execute(); strBody_id_L0011 = clsBody.BodyID; //处理0015的实体 for (int k = 0; k < dt_List.Columns.Count; k++) { string strColumnName = dt_List.Columns[k].ColumnName; if (dtPorperty.Select("Property_Name='" + strColumnName + "'").Length == 0) { continue; } MDM2_EntityPropertyValue_Edit clsProperty = new MDM2_EntityPropertyValue_Edit(); clsProperty.Conn = conn; clsProperty.hzyMessage = hzyMessage; clsProperty.MDMClass = strMDM_Class; clsProperty.ExpressionName = "CN"; clsProperty.PropertyName = strColumnName; clsProperty.BodyID = strBody_id_0016; clsProperty.PropertyValue = dt_List.Rows[j][k].ToString(); if (clsProperty.Execute() == false) { throw new Exception("修改失败," + clsProperty.Message); } } } } else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "DELETE") { for (int rowIndex = 0; rowIndex < dt_List.Rows.Count; rowIndex++) { string strBody_id_L0011 = dt_List.Rows[rowIndex]["body_id"].ToString(); string strBody_ID_0016 = conn.GetDataTableFirstValue("select body_id_0016 from MDM_L0011_B where Body_id=@param0", new string[1] { strBody_id_L0011 }).ToString(); MDM2_EntityDeleteBodyID_Edit clsDelete = new MDM2_EntityDeleteBodyID_Edit(); clsDelete.Conn = conn; clsDelete.hzyMessage = hzyMessage; //删除行政区实体的数据 if (strBody_ID_0016 != "") { clsDelete.MDMClass = strMDM_Class; clsDelete.BodyID = strBody_ID_0016; if (clsDelete.Execute() == false) { throw new Exception("删除失败。"); } } //删除Link数据 clsDelete.MDMClass = strMDM_LinkClass; clsDelete.BodyID = strBody_id_L0011; if (clsDelete.Execute() == false) { throw new Exception("删除失败。"); } } } } dt_EditResult.Rows.Add(new object[] { true, "操作成功" }); ds_Return.Tables.Add(dt_EditResult); conn.CommitTransaction(); return ds_Return; } catch { conn.RollbackTransaction(); throw; } }
/// <summary> /// 编辑店铺信息 /// </summary> /// <returns></returns> public DataSet GetData() { bool bRollBack = false; Dbconn conn = null; if (m_Conn == null) { conn = new Dbconn("MDM_Master2"); bRollBack = true; } else { conn = m_Conn; } try { DataSet ds_Return = new DataSet(); DataSet dsRequest = new DataSet(); string strXML = ""; string strAutoCode = ""; strXML = m_request.Tables[0].Rows[0]["XML"].ToString(); strAutoCode = m_request.Tables[0].Rows[0]["AutoCode"].ToString(); if (strXML == "") { throw new Exception("提交的XML为空!"); } DataSet dsXML = Common.Common.GetDSByExcelXML(strXML); DataTable dt_OPTYPE = dsXML.Tables["OPTYPE"]; string strMDM_Class_0006 = "0006"; string strMDM_LinkClass = "L0013"; conn.LockTableList.Add("MDM_" + strMDM_LinkClass + "_B"); conn.LockTableList.Add("MDM_" + strMDM_Class_0006 + "_B"); conn.LockTableList.Add("MDM_" + strMDM_LinkClass + "_E"); conn.LockTableList.Add("MDM_" + strMDM_Class_0006 + "_E"); conn.BeginTransaction(); //获取所有属性 MDM2_GetEntityPropertyList cls = new MDM2_GetEntityPropertyList(); cls.hzyMessage = this.hzyMessage; cls.MainEntity = strMDM_Class_0006; DataTable dtPorperty = cls.GetData().Tables[0]; for (int i = 0; i < dt_OPTYPE.Rows.Count; i++) { DataTable dt_List = dsXML.Tables[i + 1]; if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "UPDATE" || dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT" ) { //插入BODY表 for (int j = 0; j < dt_List.Rows.Count; j++) { string str店铺ID = ""; bool bIsInsert = false; string strBody_id_0006 = ""; string strBody_id_L0013 = ""; string strBody_id_L0006 = null;//用于存放加盟商的信息,如果为null,表示不做变更,如果不为NULL,需要变更 string strBody_id_L0011 = null;//用于存放县级市的信息,如果为null,表示不做变更,如果不为NULL,需要变更 string strBody_id_L0014 = null;//用于存放销售大区的信息,如果为null,表示不做变更,如果不为NULL,需要变更 strBody_id_0006 = dt_List.Rows[j]["body_ID_0006"].ToString(); strBody_id_L0013 = dt_List.Rows[j]["body_ID"].ToString(); if (dt_List.Columns.Contains("Body_id_L0006")) { strBody_id_L0006 = dt_List.Rows[j]["Body_id_L0006"].ToString(); if (strBody_id_L0006 != "") { //核对boid_ID是否存在 MDM2_BodyIDCheck clsCheck = new MDM2_BodyIDCheck(); clsCheck.Conn = conn; clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = "L0006"; clsCheck.Body_ID = strBody_id_L0006; if (clsCheck.Execute() == false) { throw new Exception("加盟商信息不正确!"); } } } if (dt_List.Columns.Contains("Body_id_L0011")) { strBody_id_L0011 = dt_List.Rows[j]["Body_id_L0011"].ToString(); if (strBody_id_L0011 != "") { //核对boid_ID是否存在 MDM2_BodyIDCheck clsCheck = new MDM2_BodyIDCheck(); clsCheck.Conn = conn; clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = "L0011"; clsCheck.Body_ID = strBody_id_L0011; if (clsCheck.Execute() == false) { throw new Exception("县级市信息不正确!"); } } } if (dt_List.Columns.Contains("Body_id_L0014")) { strBody_id_L0014 = dt_List.Rows[j]["Body_id_L0014"].ToString(); if (strBody_id_L0014 != "") { //核对boid_ID是否存在 MDM2_BodyIDCheck clsCheck = new MDM2_BodyIDCheck(); clsCheck.Conn = conn; clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = "L0014"; clsCheck.Body_ID = strBody_id_L0014; if (clsCheck.Execute() == false) { throw new Exception("销售大区信息不正确!"); } } } MDM2_EntityCreatedBodyID_Edit clsBody = new MDM2_EntityCreatedBodyID_Edit(); if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT") { //处理0006的实体 clsBody.Conn = conn; clsBody.hzyMessage = hzyMessage; clsBody.MDMClass = strMDM_Class_0006; clsBody.Execute(); strBody_id_0006 = clsBody.BodyID; if (strBody_id_0006 == "") { throw new Exception("BodyID_0006创建失败!"); } strBody_id_L0013 = ""; //生成新的店铺编码 bIsInsert = true; if (strAutoCode == "0") { str店铺ID = dt_List.Rows[j]["店铺ID"].ToString(); } else { str店铺ID = GetDepotID(strBody_id_L0006, conn); } } else if (strBody_id_0006 != "" && strBody_id_L0013 != "") //更新 { if (strAutoCode == "0" && dt_List.Columns.Contains("店铺id")) { str店铺ID = dt_List.Rows[j]["店铺id"].ToString(); } //核对0006是否存在 MDM2_BodyIDCheck clsCheck = new MDM2_BodyIDCheck(); clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = strMDM_Class_0006; clsCheck.Body_ID = strBody_id_0006; clsCheck.Conn = conn; if (clsCheck.Execute() == false) { throw new Exception("Body_id_0006信息不正确!"); } //核对L0013是否存在 clsCheck.hzyMessage = this.hzyMessage; clsCheck.MDMClass = strMDM_LinkClass; clsCheck.Body_ID = strBody_id_L0013; clsCheck.Conn = conn; if (clsCheck.Execute() == false) { throw new Exception("Body_id_L0013信息不正确!"); } if (strBody_id_L0006 == null) { strBody_id_L0006 = conn.GetDataTableFirstValue(@"SELECT Body_id_L0006 FROM MDM_Market2.dbo.V_L0013 WHERE body_id='" + strBody_id_L0013 + @"' ").ToString(); } if (strBody_id_L0011 == null) { strBody_id_L0011 = conn.GetDataTableFirstValue(@"SELECT Body_id_L0011 FROM MDM_Market2.dbo.V_L0013 WHERE body_id='" + strBody_id_L0013 + @"' ").ToString(); } if (strBody_id_L0014 == null) { strBody_id_L0014 = conn.GetDataTableFirstValue(@"SELECT Body_id_L0014 FROM MDM_Market2.dbo.V_L0013 WHERE body_id='" + strBody_id_L0013 + @"' ").ToString(); } } else { throw new Exception("传入的参数有误,如果反复出现,请重新登录!"); } //处理L0013的实体 clsBody.MDMClass = strMDM_LinkClass; clsBody.BodyID = strBody_id_L0013; clsBody.LinkBodyIDList = strBody_id_0006 + "," + strBody_id_L0006 + "," + strBody_id_L0011 + "," + strBody_id_L0014; clsBody.Execute(); strBody_id_L0013 = clsBody.BodyID; MDM2_EntityPropertyValue_Edit clsProperty = new MDM2_EntityPropertyValue_Edit(); string strAMMessage = ""; DataTable dtAMList = new DataTable(); //插入店铺编号 if (bIsInsert == true) { clsProperty.Conn = conn; clsProperty.hzyMessage = hzyMessage; clsProperty.MDMClass = strMDM_Class_0006; clsProperty.ExpressionName = "CN"; clsProperty.PropertyName = "店铺ID"; clsProperty.BodyID = strBody_id_0006; clsProperty.PropertyValue = str店铺ID; if (clsProperty.Execute() == false) { throw new Exception("修改失败," + clsProperty.Message); } //如果是新增店铺,需要发送小翅膀提醒 string strDepotName = ""; if (dt_List.Columns.Contains("店铺名称")) { strDepotName = str店铺ID + " " + dt_List.Rows[j]["店铺名称"].ToString(); } else { strDepotName = str店铺ID; } dtAMList = conn.GetDataTable("SELECT * FROM CFG_AM_Send WHERE CFG_Type='新开店提醒'"); for (int amrows = 0; amrows < dtAMList.Rows.Count; amrows++) { dtAMList.Rows[amrows]["AM_Message"] = dtAMList.Rows[amrows]["AM_Message"].ToString().Replace("[@店铺信息]", strDepotName); } } else { if (dt_List.Columns.Contains("拓展类型")) { string str拓展类型 = dt_List.Rows[j]["拓展类型"].ToString(); string strDepotName = Get拓展类型Changed(strBody_id_0006, str拓展类型, conn); if (strDepotName != "") { dtAMList = conn.GetDataTable("SELECT * FROM CFG_AM_Send WHERE CFG_Type='拓展类型改变'"); for (int amrows = 0; amrows < dtAMList.Rows.Count; amrows++) { dtAMList.Rows[amrows]["AM_Message"] = dtAMList.Rows[amrows]["AM_Message"].ToString().Replace("[@店铺信息]", strDepotName).Replace("[@拓展类型]", str拓展类型); } } } } for (int k = 0; k < dt_List.Columns.Count; k++) { string strColumnName = dt_List.Columns[k].ColumnName; if (strColumnName.ToUpper() == "店铺ID") { if (bIsInsert == false && strAutoCode != "0") { continue; } else { dt_List.Rows[j][k] = str店铺ID; } } if (dtPorperty.Select("Property_Name='" + strColumnName + "'").Length == 0) { continue; } clsProperty.Conn = conn; clsProperty.hzyMessage = hzyMessage; clsProperty.MDMClass = strMDM_Class_0006; clsProperty.ExpressionName = "CN"; clsProperty.PropertyName = strColumnName; clsProperty.BodyID = strBody_id_0006; clsProperty.PropertyValue = dt_List.Rows[j][k].ToString(); if (clsProperty.Execute() == false) { throw new Exception("修改失败," + clsProperty.Message); } } for (int amRowIndex = 0; amRowIndex < dtAMList.Rows.Count; amRowIndex++) { AMSendWS.MsgCenter msg = new AMSendWS.MsgCenter(); string strResult = msg.SendSubjectMsg("AM", "MDM", "MDM", dtAMList.Rows[amRowIndex]["AM_Receiver"].ToString(), "信息部服务中心", dtAMList.Rows[amRowIndex]["AM_Message"].ToString(), DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd HH:mm:ss"), "1"); } } } else if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "DELETE") { for (int rowIndex = 0; rowIndex < dt_List.Rows.Count; rowIndex++) { string strBody_id_L0013 = dt_List.Rows[rowIndex]["body_id"].ToString(); string strBody_ID_0006 = conn.GetDataTableFirstValue("select body_id_0006 from MDM_L0013_B where Body_id=@param0", new string[1] { strBody_id_L0013 }).ToString(); MDM2_EntityDeleteBodyID_Edit clsDelete = new MDM2_EntityDeleteBodyID_Edit(); clsDelete.Conn = conn; clsDelete.hzyMessage = hzyMessage; //删除店铺数据 if (strBody_ID_0006 != "") { clsDelete.MDMClass = strMDM_Class_0006; clsDelete.BodyID = strBody_ID_0006; if (clsDelete.Execute() == false) { throw new Exception("删除失败。"); } } //删除主数据 clsDelete.MDMClass = strMDM_LinkClass; clsDelete.BodyID = strBody_id_L0013; if (clsDelete.Execute() == false) { throw new Exception("删除失败。"); } } } } dt_EditResult.Rows.Add(new object[] { true, "操作成功" }); ds_Return.Tables.Add(dt_EditResult); if (bRollBack) { conn.CommitTransaction(); } return ds_Return; } catch { if (bRollBack) { conn.RollbackTransaction(); } throw; } }