private CResult GetOrderCandidateSingle(CCategory2 oCat) { CResult oResult = new CResult(); try { List <int> iTempList = new List <int>(); List <CCat2Rank> oTempCat2List = new List <CCat2Rank>(); this.OpenConnection(); int iTempCat2ID = oCat.Category2ID; CResult oResult2 = GetChildCat3(oCat.Category2ID); CCat2Rank oTempCat2Rank = new CCat2Rank(); oTempCat2Rank.Category2ID = iTempCat2ID; if (oResult2.IsSuccess && oResult2.Data != null) { List <CCat3Rank> oTempChildList = (List <CCat3Rank>)oResult2.Data; oTempCat2Rank.ChildCat3List = oTempChildList; } CResult oResult3 = GetChildCat4ByCat2(oCat.Category2ID); if (oResult3.IsSuccess && oResult3.Data != null) { List <CCat4Rank> oTempChildList2 = (List <CCat4Rank>)oResult3.Data; oTempCat2Rank.ChildCat4List = oTempChildList2; } oResult.Data = oTempCat2Rank; oResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return(oResult); }
private CResult GetOrderCandidateLower(CCategory2 p_objCat2, int p_inCatOrder) { CResult oResult = new CResult(); try { List <int> iTempList = new List <int>(); List <CCat2Rank> oTempCat2List = new List <CCat2Rank>(); if (p_objCat2.Category2Order <= p_inCatOrder) { oResult.Data = oTempCat2List; oResult.IsSuccess = true; } else { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.GetCat2OrderCandidateLower), p_inCatOrder, p_objCat2.Category2Order); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { while (oReader.Read()) { if (oReader["cat2_id"] != null) { int iTempInt = Int32.Parse(oReader["cat2_id"].ToString()); iTempList.Add(iTempInt); } } oReader.Close(); for (int listCounter = 0; listCounter < iTempList.Count; listCounter++) { int iTempCat2ID = iTempList[listCounter]; CResult oResult2 = GetChildCat3(iTempCat2ID); CCat2Rank oTempCat2Rank = new CCat2Rank(); oTempCat2Rank.Category2ID = iTempCat2ID; if (oResult2.IsSuccess && oResult2.Data != null) { List <CCat3Rank> oTempChildList = (List <CCat3Rank>)oResult2.Data; oTempCat2Rank.ChildCat3List = oTempChildList; } CResult oResult3 = GetChildCat4ByCat2(iTempCat2ID); if (oResult3.IsSuccess && oResult3.Data != null) { List <CCat4Rank> oTempChildList2 = (List <CCat4Rank>)oResult3.Data; oTempCat2Rank.ChildCat4List = oTempChildList2; } oTempCat2List.Add(oTempCat2Rank); } oResult.Data = oTempCat2List; oResult.IsSuccess = true; } } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return(oResult); }
public RMS.Common.ObjectModel.CResult Cat2UpdateOrderDown(RMS.Common.ObjectModel.CCategory2 oCat, RMS.Common.ObjectModel.CCategory2 oCat2) { CResult objResult = new CResult(); try { CCommonConstants objCommonConstants = ConfigManager.GetConfig <CCommonConstants>(); CCat2Rank objTempRankList1 = new CCat2Rank(); CCat2Rank objRankTempList2 = new CCat2Rank(); CResult oResult2 = GetOrderCandidateSingle(oCat); if (oResult2.IsSuccess && oResult2.Data != null) { objTempRankList1 = (CCat2Rank)oResult2.Data; } CResult oResult3 = GetOrderCandidateSingle(oCat2); if (oResult3.IsSuccess && oResult3.Data != null) { objRankTempList2 = (CCat2Rank)oResult3.Data; } this.OpenConnectionWithTransection(); List <CCat3Rank> oTempCat3List = objTempRankList1.ChildCat3List; List <CCat4Rank> oTempCat4List = objTempRankList1.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, oCat2.Category2Order); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, oCat2.Category2Order); } oTempCat3List = objRankTempList2.ChildCat3List; oTempCat4List = objRankTempList2.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, oCat.Category2Order); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, oCat.Category2Order); } string sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), objCommonConstants.MaxOrderChange, oCat.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), oCat.Category2Order, oCat2.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), oCat2.Category2Order, oCat.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); objResult.IsSuccess = true; this.CommitTransection(); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database"); this.RollBackTransection(); } finally { this.CloseConnection(); } return(objResult); }
public RMS.Common.ObjectModel.CResult Cat2Update(RMS.Common.ObjectModel.CCategory2 p_objCat2, int p_catOrder) { CResult objResult = new CResult(); try { bool blnTempFlag = CheckCat2ForUpdate(p_objCat2); if (blnTempFlag) { objResult.Message = "Category exists with this name."; } else { p_objCat2.Category2Name = p_objCat2.Category2Name.Replace("''", "'"); p_objCat2.Category2Name = p_objCat2.Category2Name.Replace("'", "''"); List <CCat2Rank> objRankTempList1 = new List <CCat2Rank>(); List <CCat2Rank> objRankTempList2 = new List <CCat2Rank>(); CResult objResult3 = GetOrderCandidateLower(p_objCat2, p_catOrder); if (objResult3.IsSuccess && objResult3.Data != null) { objRankTempList2 = (List <CCat2Rank>)objResult3.Data; } CResult oResult2 = GetOrderCandidate(p_objCat2); if (oResult2.IsSuccess && oResult2.Data != null) { objRankTempList1 = (List <CCat2Rank>)oResult2.Data; } this.OpenConnectionWithTransection(); string sqlCommand = ""; int iTempInt2 = 0; int iTempInt3 = 0; int counter = 0; for (counter = 0; counter < objRankTempList1.Count; counter++) { CCat2Rank oTempCat2Rank = objRankTempList1[counter]; if (oTempCat2Rank.Category2ID == p_objCat2.Category2ID) { iTempInt2 = p_objCat2.Category2Order; //iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } } else { iTempInt2 = p_objCat2.Category2Order + 1 + iTempInt3; iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); } } sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2), p_objCat2.Category2Name, p_objCat2.Category1ID, p_objCat2.Category2Order, p_objCat2.Category2Type, p_objCat2.Category2Color, p_objCat2.Category2ViewTable, p_objCat2.Category2ViewBar, p_objCat2.Category2ViewTakeAway, p_objCat2.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); //this.CommitTransection(); sqlCommand = ""; iTempInt3 = 1; for (counter = 0; counter < objRankTempList2.Count; counter++) { CCat2Rank oTempCat2Rank = objRankTempList2[counter]; if (oTempCat2Rank.Category2ID == p_objCat2.Category2ID) { iTempInt2 = p_objCat2.Category2Order; //iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } } else { iTempInt2 = p_catOrder + iTempInt3 - 1; iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); } } this.CommitTransection(); objResult.IsSuccess = true; } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database"); this.RollBackTransection(); } finally { this.CloseConnection(); } return(objResult); }
private CResult GetOrderCandidateSingle(CCategory2 oCat) { CResult oResult = new CResult(); try { List <int> iTempList = new List <int>(); List <CCat2Rank> oTempCat2List = new List <CCat2Rank>(); this.OpenConnection(); //string sSql = string.Format(SqlQueries.GetQuery(Query.GetCat2OrderCandidateLower), inCatOrder, oCat.Category2Order); // IDataReader oReader = this.ExecuteReader(sSql); //for (int i = 0; i < iTempList.Count; i++) //{ int iTempCat2ID = oCat.Category2ID; CResult oResult2 = GetChildCat3(oCat.Category2ID); CCat2Rank oTempCat2Rank = new CCat2Rank(); oTempCat2Rank.Category2ID = iTempCat2ID; if (oResult2.IsSuccess && oResult2.Data != null) { List <CCat3Rank> oTempChildList = (List <CCat3Rank>)oResult2.Data; oTempCat2Rank.ChildCat3List = oTempChildList; } CResult oResult3 = GetChildCat4ByCat2(oCat.Category2ID); if (oResult3.IsSuccess && oResult3.Data != null) { List <CCat4Rank> oTempChildList2 = (List <CCat4Rank>)oResult3.Data; oTempCat2Rank.ChildCat4List = oTempChildList2; } // oTempCat2List.Add(oTempCat2Rank); //} oResult.Data = oTempCat2Rank; oResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return(oResult); }
public RMS.Common.ObjectModel.CResult Cat2Update(RMS.Common.ObjectModel.CCategory2 oCat, int inCatOrder) { CResult oResult = new CResult(); try { bool bTempFlag = CheckCat2ForUpdate(oCat); if (bTempFlag) { oResult.Message = "Category exists with this name."; } else { oCat.Category2Name = oCat.Category2Name.Replace("''", "'"); oCat.Category2Name = oCat.Category2Name.Replace("'", "''"); List <CCat2Rank> oTempList = new List <CCat2Rank>(); List <CCat2Rank> oTempList2 = new List <CCat2Rank>(); CResult oResult3 = GetOrderCandidateLower(oCat, inCatOrder); if (oResult3.IsSuccess && oResult3.Data != null) { oTempList2 = (List <CCat2Rank>)oResult3.Data; } CResult oResult2 = GetOrderCandidate(oCat); if (oResult2.IsSuccess && oResult2.Data != null) { oTempList = (List <CCat2Rank>)oResult2.Data; } this.OpenConnectionWithTransection(); string sSql = ""; int iTempInt = 0; int iTempInt2 = 0; int iTempInt3 = 0; int i = 0; for (i = 0; i < oTempList.Count; i++) { CCat2Rank oTempCat2Rank = oTempList[i]; if (oTempCat2Rank.Category2ID == oCat.Category2ID) { iTempInt2 = oCat.Category2Order; //iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } } else { iTempInt2 = oCat.Category2Order + 1 + iTempInt3; iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sSql); } } sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2), oCat.Category2Name, oCat.Category1ID, oCat.Category2Order, oCat.Category2Type, oCat.Category2Color, oCat.Category2ViewTable, oCat.Category2ViewBar, oCat.Category2ViewTakeAway, oCat.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sSql); //this.CommitTransection(); sSql = ""; iTempInt3 = 1; for (i = 0; i < oTempList2.Count; i++) { CCat2Rank oTempCat2Rank = oTempList2[i]; if (oTempCat2Rank.Category2ID == oCat.Category2ID) { iTempInt2 = oCat.Category2Order; //iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } } else { iTempInt2 = inCatOrder + iTempInt3 - 1; iTempInt3 = iTempInt3 + 1; List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List; List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List; if (oTempCat3List.Count > 0) { UpdateChildCat3Rank(oTempCat3List, iTempInt2); } if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempInt2); } sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sSql); } } this.CommitTransection(); oResult.IsSuccess = true; } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database"); //throw new Exception("Exception occure at ItemDelete()", ex); this.RollBackTransection(); } finally { this.CloseConnection(); } return(oResult); }