public RMS.Common.ObjectModel.CResult Cat2Delete(RMS.Common.ObjectModel.CCategory2 p_objCat2) { CResult objResult = new CResult(); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteCategory2), p_objCat2.Category2ID); this.ExecuteNonQuery(sSql); objResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database"); objResult.IsException = true; objResult.Message = ex.Message; } finally { this.CloseConnection(); } return(objResult); }
public CResult Cat2Delete(CCategory2 oCat) { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteCategory2), oCat.Category2ID); this.ExecuteNonQuery(sSql); oResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database"); throw new Exception("Exception occure at ItemDelete()", ex); } finally { this.CloseConnection(); } return oResult; }
private CCategory2 ReaderToCategory2(IDataReader inReader) { CCategory2 tempCategory2 = new CCategory2(); if (inReader["cat2_id"] != null) tempCategory2.Category2ID = int.Parse(inReader["cat2_id"].ToString()); if (inReader["cat2_name"] != null) tempCategory2.Category2Name = inReader["cat2_name"].ToString(); if(inReader["cat2_order"] != null) tempCategory2.Category2Order = int.Parse(inReader["cat2_order"].ToString()); if (inReader["cat1_id"] != null) tempCategory2.Category1ID = int.Parse(inReader["cat1_id"].ToString()); if (inReader["cat2_type"] != null) tempCategory2.Category2Type = int.Parse(inReader["cat2_type"].ToString()); if (inReader["cat2_color"] != null) tempCategory2.Category2Color = inReader["cat2_color"].ToString(); if (inReader["view_table"] != null) tempCategory2.Category2ViewTable = int.Parse(inReader["view_table"].ToString()); if (inReader["view_bar"] != null) tempCategory2.Category2ViewBar = int.Parse(inReader["view_bar"].ToString()); if (inReader["view_takeaway"] != null) tempCategory2.Category2ViewTakeAway = int.Parse(inReader["view_takeaway"].ToString()); return tempCategory2; }
public CResult AddCat2(CCategory2 inUser) { CResult oResult = new CResult(); try { bool bTempFlag = CheckCat(inUser); if (bTempFlag) { oResult.Message = "Category1 exists with this name."; } else { bTempFlag = CheckCatOrder(inUser); if (bTempFlag) { oResult.Message = "Category order exists. Write another order."; } else { this.OpenConnection(); string sSql = "";// String.Format(SqlQueries.GetQuery(Query.AddCategory1), inUser.Category1Name, inUser.Category1Order, inUser.ParentCatID); this.ExecuteNonQuery(sSql); oResult.IsSuccess = true; } } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database"); //throw new Exception("Exception occure at ItemInsert()", ex); } finally { this.CloseConnection(); } return oResult; }
public RMS.Common.ObjectModel.CResult AddCat2(RMS.Common.ObjectModel.CCategory2 inUser) { CResult oResult = new CResult(); try { bool bTempFlag = CheckCat(inUser); if (bTempFlag) { oResult.Message = "Category2 exists with this name."; } else { CResult oResult2 = GetMaxCatOrder(); if (oResult2.IsSuccess && oResult2.Data != null) { int iTempOrder = (int)oResult2.Data; iTempOrder = iTempOrder + 1; inUser.Category2Name = inUser.Category2Name.Replace("''", "'"); inUser.Category2Name = inUser.Category2Name.Replace("'", "''"); this.OpenConnection(); string sSql = String.Format(SqlQueries.GetQuery(Query.AddCategory2), inUser.Category2Name, inUser.Category1ID, iTempOrder, inUser.Category2Type, inUser.Category2Color, inUser.Category2ViewTable, inUser.Category2ViewBar, inUser.Category2ViewTakeAway, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sSql); oResult.IsSuccess = true; } } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database"); //throw new Exception("Exception occure at ItemInsert()", ex); } finally { this.CloseConnection(); } return(oResult); }
public CResult AddCategory2(CCategory2 inUser) { try { m_oResult = RMS.DataAccess.Database.Instance.Category2.AddCat2(inUser); } catch (Exception ex) { System.Console.WriteLine("Exception occuer at DeleteItem() : " + ex.Message); m_oResult.IsException = true; m_oResult.Action = EERRORNAME.EXCEPTION_OCCURE; m_oResult.SetParams(ex.Message); m_oResult.Message = ex.Message; Logger.Write("Exception : " + ex + " in DeleteItem()", LogLevel.Error, "CItemManager"); } return m_oResult; }
private bool CheckCatOrder(CCategory2 inUser) { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = "";// String.Format(SqlQueries.GetQuery(Query.CheckCat1Order), inUser.Category1Order, inUser.ParentCatID); IDataReader oReader = this.ExecuteReader(sSql); if (oReader != null) { if (oReader.Read()) { if (oReader["cat1_id"] != null) { int iTemp = Int32.Parse(oReader["cat1_id"].ToString()); return true; } } } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database"); //throw new Exception("Exception occure at ItemInsert()", ex); } finally { this.CloseConnection(); } return false; }
public CResult GetCategory2(CCategory2 inCat) { CResult oResult = null; try { this.OpenConnection(); //string sSql = string.Format(SqlQueries.GetQuery(Query.ItemGetById), gItemId); //IDataReader oReader = this.ExecuteReader(sSql); //if (oReader != null) //{ // if (oReader.Read()) // oItem = ReaderToCategory2(oReader); //} } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return oResult; }
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; }
private bool CheckCatOrder2ForUpdate(CCategory2 p_inUser) { CResult objResult = new CResult(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.CheckCat2OrderForUpdate), p_inUser.Category2Order, p_inUser.Category1ID, p_inUser.Category2ID); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { if (oReader.Read()) { if (oReader["cat2_id"] != null) { int iTemp = Int32.Parse(oReader["cat2_id"].ToString()); return true; } } } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database"); } finally { this.CloseConnection(); } return false; }
public void Category2Update(CCategory2 inCategory2) { }
private void LoadExistingData() { CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.GetCategory2(m_categoryID); CCategory2 oCat = new CCategory2(); if (oResult.IsSuccess && oResult.Data != null) { oCat = (CCategory2)oResult.Data; txtCategoryName.Text = oCat.Category2Name; txtCatOrder.Text = oCat.Category2Order.ToString(); m_cattegoryOrder = oCat.Category2Order; txtColorName.Text = oCat.Category2Color.ToString(); if (oCat.Category2ViewTable == 1) { chkTable.Checked = true; } if (oCat.Category2ViewBar == 1) { chkBar.Checked = true; } if (oCat.Category2ViewTakeAway == 1) { chkTakeAway.Checked = true; } } oResult = oManager.GetCategoryAncestors(m_categoryID, 2); CCategoryAncestor oCatAnc = (CCategoryAncestor)oResult.Data; if (oResult.IsSuccess && oResult.Data != null) { int tmpCat2ID = oCatAnc.Category2ID; int tmpCat1ID = oCatAnc.Category1ID; int tmpParentCatID = oCatAnc.ParentCategoryID; FillParentCategory(); FillFoodType(tmpParentCatID); cmbParent.SelectedValue = tmpParentCatID; cmbFoodType.SelectedValue = tmpCat1ID; CComboBoxItem oItem1 = new CComboBoxItem(1, "Food"); CComboBoxItem oItem2 = new CComboBoxItem(0, "Non Food"); cmbCategoryType.Items.Add(oItem1); cmbCategoryType.Items.Add(oItem2); cmbCategoryType.DisplayMember = "Display"; cmbCategoryType.ValueMember = "Value"; if (oCat.Category2Type == 1) { cmbCategoryType.SelectedIndex = 0; } else if (oCat.Category2Type == 0) { cmbCategoryType.SelectedIndex = 1; } } }
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 void btnSave_Click(object sender, EventArgs e) { CResult oValidResult = ValidateForm(); if (oValidResult.IsSuccess) { CCategory2 oTempCat = new CCategory2(); oTempCat.Category1ID = Int32.Parse(cmbFoodType.SelectedValue.ToString()); oTempCat.Category2Type = Int32.Parse(((CComboBoxItem)cmbCategoryType.SelectedItem).Value.ToString()); oTempCat.Category2Name = txtCategoryName.Text.Trim(); oTempCat.Category2Color = txtColorName.Text.Trim(); if (chkTable.Checked) { oTempCat.Category2ViewTable = 1; } if (chkTakeAway.Checked) { oTempCat.Category2ViewBar = 1; } if (chkBar.Checked) { oTempCat.Category2ViewTakeAway = 1; } CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.AddCategory2(oTempCat); if (oResult.IsSuccess) { lblSaveStatus.Text = "Category has been saved successfully."; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = oValidResult.Message; lblSaveStatus.Visible = true; } }
private void LoadSubCategory() { List<CCategory2> tempCategory2List = new List<CCategory2>(); CCategory2DAO aCategory2Dao=new CCategory2DAO(); tempCategory2List = aCategory2Dao.GetAllCategory2(); CCategory2 aCategory2=new CCategory2(); aCategory2.Category2ID = 0; aCategory2.Category2Name = "AddMisc"; tempCategory2List.Add(aCategory2); cmbsubcategory.DataSource = tempCategory2List; cmbsubcategory.DisplayMember = "Category2Name"; cmbsubcategory.ValueMember = "Category2ID"; }
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); }
private CCategory2 ReaderToCategory2(IDataReader oReader) { CCategory2 oItem = new CCategory2(); if (oReader["cat2_id"] != null) oItem.Category2ID = Int32.Parse(oReader["cat2_id"].ToString()); if (oReader["cat2_name"] != null) oItem.Category2Name = oReader["cat2_name"].ToString(); if (oReader["cat1_id"] != null) oItem.Category1ID = Int32.Parse(oReader["cat1_id"].ToString()); if (oReader["cat2_order"] != null) oItem.Category2Order = Int32.Parse(oReader["cat2_order"].ToString()); if (oReader["cat2_type"] != null) oItem.Category2Type = Int32.Parse(oReader["cat2_type"].ToString()); if (oReader["cat2_color"] != null) oItem.Category2Color = oReader["cat2_color"].ToString(); if (oReader["view_table"] != null) oItem.Category2ViewTable = Int32.Parse(oReader["view_table"].ToString()); if (oReader["view_bar"] != null) oItem.Category2ViewBar = Int32.Parse(oReader["view_bar"].ToString()); if (oReader["view_takeaway"] != null) oItem.Category2ViewTakeAway = Int32.Parse(oReader["view_takeaway"].ToString()); return oItem; }
public void Category2Delete(CCategory2 inCategory2) { }
private void btnUpdate_Click(object sender, EventArgs e) { CResult oResult = ValidateForm(); if (oResult.IsSuccess) { String tempName = txtCategoryName.Text; int tempCat3Order = int.Parse(txtCatOrder.Text); String tempColor = txtColorName.Text.Trim(); int tempViewTable = chkTable.Checked == true ? 1 : 0; int tempViewBar = chkBar.Checked == true ? 1 : 0; int tempViewTW = chkTakeAway.Checked == true ? 1 : 0; CCategory2 oCat = new CCategory2(); oCat.Category2Name = tempName; oCat.Category2Order = tempCat3Order; oCat.Category2Color = tempColor; oCat.Category1ID = Int32.Parse(cmbFoodType.SelectedValue.ToString()); oCat.Category2ID = m_categoryID; oCat.Category2ViewTable = tempViewTable; oCat.Category2ViewBar = tempViewBar; oCat.Category2ViewTakeAway = tempViewTW; oCat.Category2Type = ((CComboBoxItem)cmbCategoryType.SelectedItem).Value; CCategoryManager oManager = new CCategoryManager(); CResult oResult2 = oManager.UpdateCategory2(oCat, m_cattegoryOrder); if (oResult2.IsSuccess) { lblSaveStatus.Text = "Category2 information is updated successfully. "; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult2.Message; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } }
public CResult UpdateCategory2Order(CCategory2 inUser, CCategory2 inUser2, bool inUpFlag) { try { if (inUpFlag) { //up m_oResult = RMS.DataAccess.Database.Instance.Category2.Cat2UpdateOrderUp(inUser, inUser2); } else { //down m_oResult = RMS.DataAccess.Database.Instance.Category2.Cat2UpdateOrderDown(inUser, inUser2); } } catch (Exception ex) { System.Console.WriteLine("Exception occuer at DeleteItem() : " + ex.Message); m_oResult.IsException = true; m_oResult.Action = EERRORNAME.EXCEPTION_OCCURE; m_oResult.SetParams(ex.Message); m_oResult.Message = ex.Message; Logger.Write("Exception : " + ex + " in DeleteItem()", LogLevel.Error, "CItemManager"); } return m_oResult; }
private void dgvCategory_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == 5) { Int32 categoryID = Convert.ToInt32("0" + dgvCategory.Rows[e.RowIndex].Cells[0].Value); UpdateCategoryCtl objUpdate = new UpdateCategoryCtl(categoryID); objUpdate.Parent = this.ParentForm; UserControlManager.UserControls.Push(this); Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"]; string s = pnl.Name; objUpdate.ParentForm.Controls[s].Controls.Clear(); objUpdate.ParentForm.Controls[s].Controls.Add(objUpdate); } else if (e.ColumnIndex == 6) { if (MessageBox.Show("Are you sure you want to delete the selected category?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int parentCatId = 0; bool bTempBool = Int32.TryParse(dgvCategory.Rows[e.RowIndex].Cells[0].Value.ToString(), out parentCatId); if (bTempBool) { CCategory2 oCat = new CCategory2(); oCat.Category2ID = parentCatId; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.DeleteCat2(oCat); if (oResult.IsSuccess) { dgvCategory.Rows.RemoveAt(e.RowIndex); } } } } } catch (Exception exp) { throw exp; } }
public void Category2Insert(CCategory2 inCategory2) { }
private void btnDown_Click(object sender, EventArgs e) { try { if (m_selectedIndex >= 0 && dgvCategory.Rows.Count > m_selectedIndex) { int iTempInt = Int32.Parse(dgvCategory.Rows[m_selectedIndex].Cells[0].Value.ToString()); int iTempInt3 = Int32.Parse(dgvCategory.Rows[m_selectedIndex].Cells[3].Value.ToString()); CCategory2 oCat = new CCategory2(); oCat.Category2ID = iTempInt; oCat.Category2Order = iTempInt3; if ((m_selectedIndex + 1) > 0 && dgvCategory.Rows.Count > (m_selectedIndex + 1)) { int iTempInt2 = Int32.Parse(dgvCategory.Rows[(m_selectedIndex + 1)].Cells[0].Value.ToString()); int iTempInt4 = Int32.Parse(dgvCategory.Rows[(m_selectedIndex + 1)].Cells[3].Value.ToString()); int iTempIndex = m_selectedIndex + 1; CCategory2 oCat2 = new CCategory2(); oCat2.Category2ID = iTempInt2; oCat2.Category2Order = iTempInt4; CCategoryManager oCatManager = new CCategoryManager(); CResult oResult = oCatManager.UpdateCategory2Order(oCat, oCat2, false); if (oResult.IsSuccess) { if (m_bGridFlag) { this.FillFoodCategory(); dgvCategory.Rows[0].Selected = false; dgvCategory.Rows[iTempIndex].Selected = true; m_selectedIndex = iTempIndex; if (m_selectedIndex > 12) { dgvCategory.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12; } } else { this.FillFoodCategory(); dgvCategory.Rows[0].Selected = false; dgvCategory.Rows[iTempIndex].Selected = true; m_selectedIndex = iTempIndex; if (m_selectedIndex > 12) { dgvCategory.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12; } } } } } } catch (Exception exp) { MessageBox.Show(exp.Message + "Error Occured. Please contact to your administrator.", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private CResult GetOrderCandidateLower(CCategory2 oCat, int inCatOrder) { CResult oResult = new CResult(); try { List<int> iTempList = new List<int>(); List<CCat2Rank> oTempCat2List = new List<CCat2Rank>(); if (oCat.Category2Order <= inCatOrder) { oResult.Data = oTempCat2List; oResult.IsSuccess = true; } else { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.GetCat2OrderCandidateLower), inCatOrder, oCat.Category2Order); IDataReader oReader = this.ExecuteReader(sSql); 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 i = 0; i < iTempList.Count; i++) { int iTempCat2ID = iTempList[i]; 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; }
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; }