public ConsortiaAllyInfo[] GetConsortiaAllyPage(int page, int size, ref int total, int order, int consortiaID, int state, string name) { List<ConsortiaAllyInfo> infos = new List<ConsortiaAllyInfo>(); string sWhere = " IsExist=1 and ConsortiaID<>" + consortiaID; Dictionary<int, int> consortiaIDs = GetConsortiaByAlly(consortiaID); try { if (state != -1) { string ids = string.Empty; foreach (int id in consortiaIDs.Keys) { ids += id + ","; } ids += 0; if (state == 0) { sWhere += " and ConsortiaID not in (" + ids + ") "; } else { sWhere += " and ConsortiaID in (" + ids + ") "; } } if (!string.IsNullOrEmpty(name)) { sWhere += " and ConsortiaName like '%" + name + "%' "; } DataTable dt = GetPage("Consortia", sWhere, page, size, "*", "ConsortiaID", "ConsortiaID", ref total); foreach (DataRow dr in dt.Rows) { ConsortiaAllyInfo info = new ConsortiaAllyInfo(); //info.ID = (int)dr["ID"]; info.Consortia1ID = (int)dr["ConsortiaID"]; info.ConsortiaName1 = dr["ConsortiaName"] == null ? "" : dr["ConsortiaName"].ToString(); info.ConsortiaName2 = ""; info.Count1 = (int)dr["Count"]; info.Repute1 = (int)dr["Repute"]; info.ChairmanName1 = dr["ChairmanName"] == null ? "" : dr["ChairmanName"].ToString(); info.ChairmanName2 = ""; info.Level1 = (int)dr["Level"]; info.Honor1 = (int)dr["Honor"]; info.Description1 = dr["Description"] == null ? "" : dr["Description"].ToString(); info.Description2 = ""; info.Riches1 = (int)dr["Riches"]; info.Date = DateTime.Now; info.IsExist = true; if (consortiaIDs.ContainsKey(info.Consortia1ID)) { info.State = consortiaIDs[info.Consortia1ID]; } info.ValidDate = 0; infos.Add(info); } //try //{ // string sWhere = " IsExist=1 "; // if (consortiaID != -1) // { // sWhere += " and ((Consortia1ID =" + consortiaID + " or Consortia2ID = " + consortiaID + " "; // sWhere += " and ((Consortia1ID =" + consortiaID + " "; // if (!string.IsNullOrEmpty(name)) // { // sWhere += " and ConsortiaName2 like '%" + name + "%'"; // } // sWhere += ")"; // sWhere += " or (Consortia2ID = " + consortiaID + " "; // if (!string.IsNullOrEmpty(name)) // { // sWhere += " and ConsortiaName1 like '%" + name + "%'"; // } // sWhere += "))"; // } // if (state != -1) // { // sWhere += " and State =" + state + " "; // } // if (string.IsNullOrEmpty(name)) // { // sWhere += " and (ConsortiaName1 like '%" + name + "%' or ConsortiaName2 like '%" + name + "%') "; // } // string sOrder = "ConsortiaName1,ConsortiaName2"; // switch (order) // { // case 1: // sOrder = "Repute1,Repute2"; // break; // case 2: // sOrder = "ChairmanName1,ChairmanName2"; // break; // case 3: // sOrder = "Count1,Count2"; // break; // case 4: // sOrder = "Level1,Level2"; // break; // case 5: // sOrder = "Honor1,Honor2"; // break; // } // sOrder += ",ID "; // DataTable dt = GetPage("V_Consortia_Ally", sWhere, page, size, "*", sOrder, "ID", ref total); //foreach (DataRow dr in dt.Rows) //{ // ConsortiaAllyInfo info = new ConsortiaAllyInfo(); // // info.ID = (int)dr["ID"]; // info.Consortia1ID = (int)dr["Consortia1ID"]; // if (info.Consortia1ID != consortiaID) // { // info.Consortia2ID = (int)dr["Consortia2ID"]; // info.ConsortiaName1 = dr["ConsortiaName1"] == null ? "" : dr["ConsortiaName1"].ToString(); // info.ConsortiaName2 = dr["ConsortiaName2"] == null ? "" : dr["ConsortiaName2"].ToString(); // info.Count1 = (int)dr["Count1"]; // info.Count2 = (int)dr["Count2"]; // info.Repute1 = (int)dr["Repute1"]; // info.Repute2 = (int)dr["Repute2"]; // info.ChairmanName1 = dr["ChairmanName1"] == null ? "" : dr["ChairmanName1"].ToString(); // info.ChairmanName2 = dr["ChairmanName2"] == null ? "" : dr["ChairmanName2"].ToString(); // info.Level1 = (int)dr["Level1"]; // info.Level2 = (int)dr["Level2"]; // info.Honor1 = (int)dr["Honor1"]; // info.Honor2 = (int)dr["Honor2"]; // info.Description1 = dr["Description1"] == null ? "" : dr["Description1"].ToString(); // info.Description2 = dr["Description2"] == null ? "" : dr["Description2"].ToString(); // info.Riches1 = (int)dr["Riches1"]; // info.Riches2 = (int)dr["Riches2"]; // } // else // { // info.Consortia1ID = (int)dr["Consortia2ID"]; // info.Consortia2ID = (int)dr["Consortia1ID"]; // info.ConsortiaName1 = dr["ConsortiaName2"] == null ? "" : dr["ConsortiaName2"].ToString(); // info.ConsortiaName2 = dr["ConsortiaName1"] == null ? "" : dr["ConsortiaName1"].ToString(); // info.Count1 = (int)dr["Count2"]; // info.Count2 = (int)dr["Count1"]; // info.Repute1 = (int)dr["Repute2"]; // info.Repute2 = (int)dr["Repute1"]; // info.ChairmanName1 = dr["ChairmanName2"] == null ? "" : dr["ChairmanName2"].ToString(); // info.ChairmanName2 = dr["ChairmanName1"] == null ? "" : dr["ChairmanName1"].ToString(); // info.Level1 = (int)dr["Level2"]; // info.Level2 = (int)dr["Level1"]; // info.Honor1 = (int)dr["Honor2"]; // info.Honor2 = (int)dr["Honor1"]; // info.Description1 = dr["Description2"] == null ? "" : dr["Description2"].ToString(); // info.Description2 = dr["Description1"] == null ? "" : dr["Description1"].ToString(); // info.Riches1 = (int)dr["Riches2"]; // info.Riches2 = (int)dr["Riches1"]; // } // info.Date = (DateTime)dr["Date"]; // info.IsExist = (bool)dr["IsExist"]; // info.State = (int)dr["State"]; // info.ValidDate = (int)dr["ValidDate"]; // infos.Add(info); //} } catch (Exception e) { if (log.IsErrorEnabled) log.Error("GetConsortiaAllyPage", e); } finally { } return infos.ToArray(); }
public bool AddConsortiaAlly(ConsortiaAllyInfo info, int userID, ref string msg) { bool result = false; try { SqlParameter[] para = new SqlParameter[9]; para[0] = new SqlParameter("@ID", info.ID); para[0].Direction = ParameterDirection.InputOutput; para[1] = new SqlParameter("@Consortia1ID", info.Consortia1ID); para[2] = new SqlParameter("@Consortia2ID", info.Consortia2ID); para[3] = new SqlParameter("@State", info.State); para[4] = new SqlParameter("@Date", info.Date); para[5] = new SqlParameter("@ValidDate", info.ValidDate); para[6] = new SqlParameter("@IsExist", info.IsExist); para[7] = new SqlParameter("@UserID", userID); para[8] = new SqlParameter("@Result", System.Data.SqlDbType.Int); para[8].Direction = ParameterDirection.ReturnValue; db.RunProcedure("SP_ConsortiaAlly_Add", para); int returnValue = (int)para[8].Value; result = returnValue == 0; switch (returnValue) { case 2: msg = "ConsortiaBussiness.AddConsortiaAlly.Msg2"; break; case 3: msg = "ConsortiaBussiness.AddConsortiaAlly.Msg3"; break; } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } return result; }
public ConsortiaAllyInfo[] GetConsortiaAllyAll() { List<ConsortiaAllyInfo> infos = new List<ConsortiaAllyInfo>(); SqlDataReader reader = null; try { db.GetReader(ref reader, "SP_ConsortiaAlly_All"); while (reader.Read()) { ConsortiaAllyInfo info = new ConsortiaAllyInfo(); info.Consortia1ID = (int)reader["Consortia1ID"]; info.Consortia2ID = (int)reader["Consortia2ID"]; info.Date = (DateTime)reader["Date"]; info.ID = (int)reader["ID"]; info.State = (int)reader["State"]; info.ValidDate = (int)reader["ValidDate"]; info.IsExist = (bool)reader["IsExist"]; infos.Add(info); } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } return infos.ToArray(); }
public static XElement CreateConsortiaAllyInfo(ConsortiaAllyInfo info) { return new XElement("Item", new XAttribute("ID", info.ID), //new XAttribute("CelebCount", info.CelebCount), new XAttribute("ChairmanName", info.ChairmanName1 == null ? "" : info.ChairmanName1), new XAttribute("ConsortiaID", info.Consortia1ID), //new XAttribute("Consortia2ID", info.Consortia2ID), new XAttribute("ConsortiaName", info.ConsortiaName1 == null ? "" : info.ConsortiaName1), new XAttribute("Count", info.Count1), new XAttribute("Honor", info.Honor1), new XAttribute("State", info.State), new XAttribute("Date", info.Date.ToString("yyyy-MM-dd HH:mm:ss")), new XAttribute("Level", info.Level1), new XAttribute("IsApply", info.IsApply), new XAttribute("Description", info.Description1), new XAttribute("Riches", info.Riches1), new XAttribute("Repute", info.Repute1)); }