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 bool CheckCat2ForUpdate(CCategory2 inUser) { CResult oResult = new CResult(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.CheckDupCat2ForUpdate), inUser.Category2Name, inUser.Category1ID, 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 RMS.Common.ObjectModel.CResult GetCategory2(int p_inCat2ID) { CResult oResult = new CResult(); try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.GetCategory2), p_inCat2ID); IDataReader objReader = this.ExecuteReader(sqlCommand); if (objReader != null) { if (objReader.Read()) { CCategory2 oCat2 = ReaderToCategory2(objReader); oResult.Data = oCat2; oResult.IsSuccess = true; } } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return(oResult); }
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; } }
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; } }
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 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); }
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); }
public CResult GetCategory2(CCategory2 inUser) { try { // m_oResult = Database.Instance.Category1.AddCat1(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 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; } } }
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); }
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 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); }