| | |
| | | } |
| | | } |
| | | |
| | | //判定该用户与客户是否已经关联 |
| | | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; |
| | | //判定客户是否已经关联用户 |
| | | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + |
| | | " from Gy_UserCustomerRelation as a" + |
| | | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + |
| | | " left join Gy_Customer as c on a.HCusID = c.HItemID " + |
| | | " where a.HCusID = " + HCusID; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!= HUserID) |
| | | { |
| | | err += "用户已经关联该客户;"; |
| | | err += "用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】;"; |
| | | } |
| | | else |
| | | { |
| | | //判定该用户与客户是否已经关联 |
| | | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | err += "用户已经关联该客户;"; |
| | | } |
| | | } |
| | | |
| | | tb2.Rows[i - 1]["判定结果"] = err; |
| | |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + |
| | | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + |
| | | " from Gy_UserCustomerRelation as a" + |
| | | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + |
| | | " left join Gy_Customer as c on a.HCusID = c.HItemID " + |
| | | " where a.HCusID = " + HCusID; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + |
| | | "values(" + |
| | | "'" + HUserID + "'" + |
| | | "," + HCusID + "" + |
| | | ")"; |
| | | oCN.RunProc(sql); |
| | | oCN.RunProc(sql); |
| | | } |
| | | else |
| | | { |
| | | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; |
| | | } |
| | | i++; |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | i++; |
| | | } |
| | | }else if(saveType == "2") |
| | | //判断是否存在错误 |
| | | if (err.Length > 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "导入错误:" + err; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else if(saveType == "2") |
| | | { |
| | | oCN.BeginTran(); |
| | | string err = ""; |
| | |
| | | string HOrgNumber = item["组织代码"].ToString(); |
| | | string HOrgName = item["组织名称"].ToString(); |
| | | |
| | | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; |
| | | |
| | | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + |
| | | " from Gy_UserCustomerRelation as a" + |
| | | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + |
| | | " left join Gy_Customer as c on a.HCusID = c.HItemID " + |
| | | " where a.HCusID = " + HCusID; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!=HUserID) |
| | | { |
| | | sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + |
| | | "values(" + |
| | | "'" + HUserID + "'" + |
| | | "," + HCusID + "" + |
| | | ")"; |
| | | oCN.RunProc(sql); |
| | | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; |
| | | } |
| | | else |
| | | { |
| | | err += "第" + i + "行:用户已经关联该客户!"; |
| | | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + |
| | | "values(" + |
| | | "'" + HUserID + "'" + |
| | | "," + HCusID + "" + |
| | | ")"; |
| | | oCN.RunProc(sql); |
| | | } |
| | | else |
| | | { |
| | | err += "第" + i + "行:用户已经关联该客户!"; |
| | | } |
| | | } |
| | | i++; |
| | | } |
| | |
| | | string HCusName = item["HCusName"].ToString(); //客户名称 |
| | | |
| | | |
| | | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; |
| | | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + |
| | | " from Gy_UserCustomerRelation as a" + |
| | | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + |
| | | " left join Gy_Customer as c on a.HCusID = c.HItemID " + |
| | | " where a.HCusID = " + HCusID; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | err += "第" + i + "行:用户【" + HUserName + "】已经关联客户【" + HCusName + "】"; |
| | | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; |
| | | } |
| | | i++; |
| | | } |
| | |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID + " and HItemID <> " + HItemID; |
| | | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + |
| | | " from Gy_UserCustomerRelation as a" + |
| | | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + |
| | | " left join Gy_Customer as c on a.HCusID = c.HItemID " + |
| | | " where a.HCusID = " + HCusID + " and a.HItemID <> " + HItemID; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if(ds.Tables[0].Rows.Count == 0) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | err += "第" + i + "行:用户【" + HUserName + "】已经关联客户【" + HCusName + "】"; |
| | | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; |
| | | } |
| | | } |
| | | else |