public RMS.Common.ObjectModel.CResult GetCategory4All() { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.GetCategory4All)); IDataReader oReader = this.ExecuteReader(sSql); List <CCategory4> oCat4List = new List <CCategory4>(); if (oReader != null) { while (oReader.Read()) { CCategory4 oCat = ReaderToCategory4(oReader); oCat4List.Add(oCat); } } oResult.Data = oCat4List; 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 CheckCatOrder4ForUpdate(CCategory4 inUser) { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = String.Format(SqlQueries.GetQuery(Query.CheckCat4OrderForUpdate), inUser.Category4Order, inUser.Category3ID, inUser.Category4ID); IDataReader oReader = this.ExecuteReader(sSql); if (oReader != null) { if (oReader.Read()) { if (oReader["cat4_id"] != null) { int iTemp = Int32.Parse(oReader["cat4_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 CResult UpdateCategory4Order(CCategory4 inUser, CCategory4 inUser2, bool inUpFlag) { try { if (inUpFlag) { //up m_oResult = RMS.DataAccess.Database.Instance.Category4.Cat4UpdateOrderUp(inUser, inUser2); } else { //down m_oResult = RMS.DataAccess.Database.Instance.Category4.Cat4UpdateOrderDown(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 dgvSelectionItem_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == 7) { Int32 itemID = Convert.ToInt32("0" + dgvSelectionItem.Rows[e.RowIndex].Cells[0].Value); UpdateSelectionItemCtl objSelection = new UpdateSelectionItemCtl(itemID); objSelection.Parent = this.ParentForm; UserControlManager.UserControls.Push(this); Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"]; string s = pnl.Name; objSelection.ParentForm.Controls[s].Controls.Clear(); objSelection.ParentForm.Controls[s].Controls.Add(objSelection); } else if (e.ColumnIndex == 8) { if (MessageBox.Show("Are you sure you want to delete the selected food type?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int selectItemCatId = 0; bool bTempBool = Int32.TryParse(dgvSelectionItem.Rows[e.RowIndex].Cells[0].Value.ToString(), out selectItemCatId); if (bTempBool) { CCategory4 objSelectItem = new CCategory4(); objSelectItem.Category4ID = selectItemCatId; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.DeleteCat4(objSelectItem); if (oResult.IsSuccess) { dgvSelectionItem.Rows.RemoveAt(e.RowIndex); } } } } } catch (Exception exp) { throw exp; } }
private CResult GetOrderCandidateLower(CCategory4 oCat, int inCatOrder) { CResult oResult = new CResult(); try { List <int> iTempList = new List <int>(); if (oCat.Category4Order <= inCatOrder) { oResult.Data = iTempList; oResult.IsSuccess = true; } else { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.GetCat4OrderCandidateLower), oCat.Category3ID, inCatOrder, oCat.Category4Order); IDataReader oReader = this.ExecuteReader(sSql); if (oReader != null) { while (oReader.Read()) { if (oReader["cat4_id"] != null) { int iTempInt = Int32.Parse(oReader["cat4_id"].ToString()); iTempList.Add(iTempInt); } } oResult.Data = iTempList; 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 DeleteCat4(CCategory4 inUser) { try { m_oResult = RMS.DataAccess.Database.Instance.Category4.Cat4Delete(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 btnSave_Click(object sender, EventArgs e) { CResult oResult = ValidateForm(); if (oResult.IsSuccess) { CCategory4 objSelectionOfItem = new CCategory4(); objSelectionOfItem.Category4Name = txtItemName.Text.Trim(); objSelectionOfItem.Category3ID = Int32.Parse(cmbFoodItem.SelectedValue.ToString()); objSelectionOfItem.Category4Description = txtDesc.Text.Trim(); if (rdoActive.Checked) { objSelectionOfItem.Category4OrderStatus = 1; } else { objSelectionOfItem.Category4OrderStatus = 0; } if (!txtTablePrice.Text.Trim().Equals(String.Empty)) { objSelectionOfItem.Category4TablePrice = Double.Parse(txtTablePrice.Text.Trim()); } if (!txtTakeAwayPrice.Text.Trim().Equals(String.Empty)) { objSelectionOfItem.Category4TakeAwayPrice = Double.Parse(txtTakeAwayPrice.Text.Trim()); } if (!txtBarPrice.Text.Trim().Equals(String.Empty)) { objSelectionOfItem.Category4BarPrice = Double.Parse(txtBarPrice.Text.Trim()); } if (chkTable.Checked) { objSelectionOfItem.Category4ViewTable = 1; } if (chkBar.Checked) { objSelectionOfItem.Category4ViewBar = 1; } if (chkTakeAway.Checked) { objSelectionOfItem.Category4ViewTakeAway = 1; } if (chkUnlimited.Checked) { objSelectionOfItem.InitialItemQuantity = 0; objSelectionOfItem.UnlimitStatus = 1; } else { objSelectionOfItem.UnlimitStatus = 0; objSelectionOfItem.InitialItemQuantity = Convert.ToInt32("0" + txtStockQuantity.Text); } CCategoryManager oManager = new CCategoryManager(); CResult oResult2 = oManager.AddCategory4(objSelectionOfItem); if (oResult2.IsSuccess) { lblSaveStatus.Text = " The product has been saved successfully."; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult2.Message; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } }
private CCategory4 ReaderToCategory4(IDataReader oReader) { CCategory4 objSelectionItem = new CCategory4(); if (oReader["cat4_id"] != null) { objSelectionItem.Category4ID = Int32.Parse(oReader["cat4_id"].ToString()); } if (oReader["cat4_name"] != null) { objSelectionItem.Category4Name = oReader["cat4_name"].ToString(); } if (oReader["cat3_id"] != null) { objSelectionItem.Category3ID = Int32.Parse(oReader["cat3_id"].ToString()); } if (oReader["description"] != null) { objSelectionItem.Category4Description = oReader["description"].ToString(); } if (oReader["table_price"] != null) { objSelectionItem.Category4TablePrice = Double.Parse(oReader["table_price"].ToString()); } if (oReader["tw_price"] != null) { objSelectionItem.Category4TakeAwayPrice = Double.Parse(oReader["tw_price"].ToString()); } if (oReader["bar_price"] != null) { objSelectionItem.Category4BarPrice = Double.Parse(oReader["bar_price"].ToString()); } if (oReader["status"] != null) { objSelectionItem.Category4OrderStatus = Int32.Parse(oReader["status"].ToString()); } if (oReader["cat4_order"] != null) { objSelectionItem.Category4Order = Int32.Parse(oReader["cat4_order"].ToString()); } if (oReader["view_table"] != null) { objSelectionItem.Category4ViewTable = Int32.Parse(oReader["view_table"].ToString()); } if (oReader["view_bar"] != null) { objSelectionItem.Category4ViewBar = Int32.Parse(oReader["view_bar"].ToString()); } if (oReader["view_takeaway"] != null) { objSelectionItem.Category4ViewTakeAway = Int32.Parse(oReader["view_takeaway"].ToString()); } if (oReader["slection_item_stock_quantity"] != null) { objSelectionItem.InitialItemQuantity = Int32.Parse("0" + oReader["slection_item_stock_quantity"].ToString()); } if (oReader["unlimited_status"] != null) { objSelectionItem.UnlimitStatus = Convert.ToInt32(oReader["unlimited_status"]); } //Vat if (oReader["vat_Rate"] != null) { objSelectionItem.vatRate = Double.Parse(oReader["vat_Rate"].ToString()); } if (oReader["vat_included"] != null) { objSelectionItem.vatIncluded = Convert.ToBoolean(oReader["vat_included"].ToString()); } if (oReader["cat4_rank"] != null) { String sTempStr = oReader["cat4_rank"].ToString(); if (!sTempStr.Equals(String.Empty)) { objSelectionItem.Rank = Int64.Parse(sTempStr); } } return(objSelectionItem); }
private void btnDown_Click(object sender, EventArgs e) { try { if (m_iSelectedIndex >= 0 && dgvSelectionItem.Rows.Count > m_iSelectedIndex) { int iTempInt = Int32.Parse(dgvSelectionItem.Rows[m_iSelectedIndex].Cells[0].Value.ToString()); int iTempInt3 = Int32.Parse(dgvSelectionItem.Rows[m_iSelectedIndex].Cells[2].Value.ToString()); CCategory4 oCat = new CCategory4(); oCat.Category4ID = iTempInt; oCat.Category4Order = iTempInt3; if ((m_iSelectedIndex + 1) > 0 && dgvSelectionItem.Rows.Count > (m_iSelectedIndex + 1)) { int iTempInt2 = Int32.Parse(dgvSelectionItem.Rows[(m_iSelectedIndex + 1)].Cells[0].Value.ToString()); int iTempInt4 = Int32.Parse(dgvSelectionItem.Rows[(m_iSelectedIndex + 1)].Cells[2].Value.ToString()); int iTempIndex = m_iSelectedIndex + 1; CCategory4 oCat2 = new CCategory4(); oCat2.Category4ID = iTempInt2; oCat2.Category4Order = iTempInt4; if (cmbFoodItem.SelectedValue != null) { int iTempInt10 = Int32.Parse(cmbFoodItem.SelectedValue.ToString()); oCat.Category3ID = iTempInt10; oCat2.Category3ID = iTempInt10; } CCategoryManager oCatManager = new CCategoryManager(); CResult oResult = oCatManager.UpdateCategory4Order(oCat, oCat2, false); if (oResult.IsSuccess) { if (m_bGridFlag) { Int32 foodItemID = Convert.ToInt32(cmbFoodItem.SelectedValue); FillSelectedItems(foodItemID); dgvSelectionItem.Rows[0].Selected = false; dgvSelectionItem.Rows[iTempIndex].Selected = true; m_iSelectedIndex = iTempIndex; if (m_iSelectedIndex > 12) { dgvSelectionItem.FirstDisplayedScrollingRowIndex = m_iSelectedIndex - 12; } } else { Int32 foodItemID = Convert.ToInt32(cmbFoodItem.SelectedValue); FillSelectedItems(foodItemID); dgvSelectionItem.Rows[0].Selected = false; dgvSelectionItem.Rows[iTempIndex].Selected = true; m_iSelectedIndex = iTempIndex; if (m_iSelectedIndex > 12) { dgvSelectionItem.FirstDisplayedScrollingRowIndex = m_iSelectedIndex - 12; } } } } } } catch (Exception exp) { MessageBox.Show(exp.Message + "Error Occured. Please contact to your administrator.", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private CCategory4 ReaderToCategory4(IDataReader oReader) { CCategory4 oItem = new CCategory4(); if (oReader["cat4_id"] != null) { oItem.Category4ID = Int32.Parse(oReader["cat4_id"].ToString()); } if (oReader["cat4_name"] != null) { oItem.Category4Name = oReader["cat4_name"].ToString(); } if (oReader["cat3_id"] != null) { oItem.Category3ID = Int32.Parse(oReader["cat3_id"].ToString()); } if (oReader["description"] != null) { oItem.Category4Description = oReader["description"].ToString(); } if (oReader["table_price"] != null) { oItem.Category4TablePrice = Double.Parse(oReader["table_price"].ToString()); } if (oReader["tw_price"] != null) { oItem.Category4TakeAwayPrice = Double.Parse(oReader["tw_price"].ToString()); } if (oReader["bar_price"] != null) { oItem.Category4BarPrice = Double.Parse(oReader["bar_price"].ToString()); } if (oReader["status"] != null) { oItem.Category4OrderStatus = Int32.Parse(oReader["status"].ToString()); } if (oReader["cat4_order"] != null) { oItem.Category4Order = Int32.Parse(oReader["cat4_order"].ToString()); } if (oReader["view_table"] != null) { oItem.Category4ViewTable = Int32.Parse(oReader["view_table"].ToString()); } if (oReader["view_bar"] != null) { oItem.Category4ViewBar = Int32.Parse(oReader["view_bar"].ToString()); } if (oReader["view_takeaway"] != null) { oItem.Category4ViewTakeAway = Int32.Parse(oReader["view_takeaway"].ToString()); } if (oReader["cat4_rank"] != null) { String sTempStr = oReader["cat4_rank"].ToString(); if (!sTempStr.Equals(String.Empty)) { oItem.Rank = Int64.Parse(sTempStr); } } return(oItem); }
private void btnSave_Click(object sender, EventArgs e) { CResult oResult = ValidateForm(); if (oResult.IsSuccess) { CCategory4 objSelectionofItem = new CCategory4(); String tempName = txtItemName.Text; int tempCat4Order = int.Parse(txtOrder.Text); String tempDescription = txtDescription.Text; if (!txtTablePrice.Text.Trim().Equals(String.Empty)) { objSelectionofItem.Category4TablePrice = Double.Parse(txtTablePrice.Text.Trim()); } if (!txtBarPrice.Text.Trim().Equals(String.Empty)) { objSelectionofItem.Category4BarPrice = Double.Parse(txtBarPrice.Text.Trim()); } if (!txtTakeawayPrice.Text.Trim().Equals(String.Empty)) { objSelectionofItem.Category4TakeAwayPrice = Double.Parse(txtTakeawayPrice.Text.Trim()); } int tempViewTable = chkTable.Checked == true ? 1 : 0; int tempViewBar = chkBar.Checked == true ? 1 : 0; int tempViewTW = chkTakeAway.Checked == true ? 1 : 0; objSelectionofItem.Category4Name = tempName; objSelectionofItem.Category4Order = tempCat4Order; objSelectionofItem.Category4Description = tempDescription; objSelectionofItem.Category4ViewTable = tempViewTable; objSelectionofItem.Category4ViewBar = tempViewBar; objSelectionofItem.Category4ViewTakeAway = tempViewTW; objSelectionofItem.Category3ID = Int32.Parse(cmbFoodItem.SelectedValue.ToString()); objSelectionofItem.Category4ID = m_selectionItemCategoryID; if (rdoActive.Checked) { objSelectionofItem.Category4OrderStatus = 1; } else { objSelectionofItem.Category4OrderStatus = 0; } if (chkunlimited.Checked) { objSelectionofItem.InitialItemQuantity = 0; objSelectionofItem.UnlimitStatus = 1; } else { objSelectionofItem.InitialItemQuantity = Convert.ToInt32("0" + txtInitialQuantity.Text); objSelectionofItem.UnlimitStatus = 0; } try { objSelectionofItem.vatRate = Convert.ToDouble(txtVateRate.Text.ToString()); } catch { objSelectionofItem.vatRate = 0.00; } if (chkVateIncluded.Checked) { objSelectionofItem.vatIncluded = true; } else { objSelectionofItem.vatIncluded = false; } CCategoryManager oManager = new CCategoryManager(); CResult oResult2 = oManager.UpdateCategory4(objSelectionofItem, m_selectionItemOrder); if (oResult2.IsSuccess) { lblSaveStatus.Text = "Item 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 LoadExistingData() { CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.GetCategory4(m_selectionItemCategoryID); CCategory4 objSelectionOfItem = new CCategory4(); if (oResult.IsSuccess && oResult.Data != null) { objSelectionOfItem = (CCategory4)oResult.Data; txtItemName.Text = objSelectionOfItem.Category4Name; txtOrder.Text = objSelectionOfItem.Category4Order.ToString(); m_selectionItemOrder = objSelectionOfItem.Category4Order; txtDescription.Text = objSelectionOfItem.Category4Description; txtTablePrice.Text = objSelectionOfItem.Category4TablePrice.ToString("F02"); txtTakeawayPrice.Text = objSelectionOfItem.Category4TakeAwayPrice.ToString("F02"); txtBarPrice.Text = objSelectionOfItem.Category4BarPrice.ToString("F02"); txtVateRate.Text = objSelectionOfItem.vatRate.ToString(); chkVateIncluded.Checked = objSelectionOfItem.vatIncluded; if (objSelectionOfItem.UnlimitStatus > 0) { chkunlimited.Checked = true; txtInitialQuantity.Clear(); } else { txtInitialQuantity.Text = objSelectionOfItem.InitialItemQuantity.ToString(); } m_iRank = objSelectionOfItem.Rank; if (objSelectionOfItem.Category4ViewTable == 1) { chkTable.Checked = true; } if (objSelectionOfItem.Category4ViewBar == 1) { chkBar.Checked = true; } if (objSelectionOfItem.Category4ViewTakeAway == 1) { chkTakeAway.Checked = true; } } oResult = oManager.GetCategoryAncestors(m_selectionItemCategoryID, 4); if (oResult.IsSuccess && oResult.Data != null) { CCategoryAncestor oCatAnc = (CCategoryAncestor)oResult.Data; int tmpCat4ID = oCatAnc.Category4ID; int tmpCat3ID = oCatAnc.Category3ID; int tmpCat2ID = oCatAnc.Category2ID; int tmpCat1ID = oCatAnc.Category1ID; int tmpParentCatID = oCatAnc.ParentCategoryID; CComboBoxItem oItem1 = new CComboBoxItem(1, "Active"); CComboBoxItem oItem2 = new CComboBoxItem(0, "InActive"); if (objSelectionOfItem.Category4OrderStatus == 1) { rdoActive.Checked = true; } else if (objSelectionOfItem.Category4OrderStatus == 0) { rdoInactive.Checked = true; } cmbParent.SelectedValue = tmpParentCatID; cmbFoodType.SelectedValue = tmpCat1ID; cmbCategory.SelectedValue = tmpCat2ID; cmbFoodItem.SelectedValue = tmpCat3ID; } }