public List<CCategory1> GetCategory1IdByParentId(int parentId) { List<CCategory1> categorys = new List<CCategory1>(); try { this.OpenConnection(); string sqlComm = String.Format(SqlQueries.GetQuery(Query.GetCategory1IdByParentId), parentId); IDataReader aReader = this.ExecuteReader(sqlComm); if (aReader != null) { while (aReader.Read()) { CCategory1 aCategory1 = new CCategory1(); aCategory1 = ReaderToCategory11(aReader); categorys.Add(aCategory1); } aReader.Close(); } } catch (Exception ex) { throw new Exception("GetCategory1IdByParentId()", ex); } finally { this.CloseConnection(); } return categorys; }
public CResult Cat1Delete(RMS.Common.ObjectModel.CCategory1 oCat) { CResult objResult = new CResult(); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteCategory1), oCat.Category1ID); this.ExecuteNonQuery(sSql); objResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database"); objResult.Message = ex.Message; objResult.IsException = true; } finally { this.CloseConnection(); } return(objResult); }
public CResult Cat1Delete(CCategory1 oCat) { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteCategory1), oCat.Category1ID); 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; }
public CResult UpdateCategory1OrderUP(RMS.Common.ObjectModel.CCategory1 p_currentCategory, RMS.Common.ObjectModel.CCategory1 p_antiCategory) { CResult oResult = new CResult(); string sqlCommand = ""; try { this.OpenConnection(); sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory1Order), p_currentCategory.Category1ID, p_antiCategory.Category1OrderNumber, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory1Order), p_antiCategory.Category1ID, p_currentCategory.Category1OrderNumber, RMSGlobal.LogInUserName, DateTime.Now.Ticks); this.ExecuteNonQuery(sqlCommand); oResult.IsSuccess = true; this.CommitTransection(); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database"); this.RollBackTransection(); } finally { this.CloseConnection(); } return(oResult); }
public CResult AddCat1(CCategory1 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; }
private CCategory1 ReaderToCategory1(IDataReader inReader) { CCategory1 tempCategory1 = new CCategory1(); if (inReader["cat1_id"] != null) tempCategory1.Category1ID = int.Parse(inReader["cat1_id"].ToString()); if (inReader["cat1_name"] != null) tempCategory1.Category1Name = inReader["cat1_name"].ToString(); if(inReader["cat1_order"] != null) tempCategory1.Category1Order = int.Parse(inReader["cat1_order"].ToString()); if(inReader["parent_cat_id"] != null) tempCategory1.Category1ParentID = int.Parse(inReader["parent_cat_id"].ToString()); return tempCategory1; }
public CResult AddCategory1(CCategory1 inUser) { try { m_oResult = RMS.DataAccess.Database.Instance.Category1.AddCat1(inUser); } catch (Exception ex) { System.Console.WriteLine("Exception occuer at new category 1 insertion : " + 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 btnUpdate_Click(object sender, EventArgs e) { CResult oResult = ValidateForm(); if (oResult.IsSuccess) { CCategory1 objFoodType = new CCategory1(); objFoodType.Category1Name = txtFoodType.Text.Trim(); //oCat.Category1Order = Int32.Parse(textBox2.Text.Trim()); objFoodType.ParentCatID = Int32.Parse(cmbParentCategory.SelectedValue.ToString()); objFoodType.Category1ID = Convert.ToInt32("0"+txtFoodType.Tag); CCategoryManager oManager = new CCategoryManager(); CResult oResult2 = oManager.UpdateCategory1(objFoodType); if (oResult2.IsSuccess) { lblSaveStatus.Text = "Food type has been updated successfully."; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult2.Message; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } }
public CResult AddCat1(RMS.Common.ObjectModel.CCategory1 p_categoryInfo) { CResult objResult = new CResult(); try { bool bTempFlag = CheckCat(p_categoryInfo); if (bTempFlag) { objResult.Message = "Category1 exists with this name."; } else { objResult = this.GetMaxCatOrder(); //New By Baruri at 31.12.2008 p_categoryInfo.Category1Name = p_categoryInfo.Category1Name.Replace("''", "'"); p_categoryInfo.Category1Name = p_categoryInfo.Category1Name.Replace("'", "''"); this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.AddCategory1), p_categoryInfo.Category1Name, p_categoryInfo.ParentCatID, p_categoryInfo.CurrentUserId, p_categoryInfo.LoginDateTime, (Int32)objResult.Data + 1); this.ExecuteNonQuery(sqlCommand); objResult.IsSuccess = true; } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database"); } finally { this.CloseConnection(); } return(objResult); }
public CResult Cat1Update(RMS.Common.ObjectModel.CCategory1 oCat) { CResult oResult = new CResult(); try { bool bTempFlag = CheckCatUpdate(oCat); if (bTempFlag) { oResult.Message = "Category order exists. Write another order."; } else { oCat.Category1Name = oCat.Category1Name.Replace("''", "'"); oCat.Category1Name = oCat.Category1Name.Replace("'", "''"); this.OpenConnection(); string sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory1), oCat.Category1Name, oCat.ParentCatID, oCat.Category1ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks); 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 bool CheckCatUpdate(CCategory1 inUser) { CResult objResult = new CResult(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.CheckDupCat1Update), inUser.Category1Name, inUser.ParentCatID, inUser.Category1ID); IDataReader oReader = this.ExecuteReader(sqlCommand); 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"); } finally { this.CloseConnection(); } return false; }
private CCategory1 ReaderToCategory1(IDataReader oReader) { CCategory1 oItem = new CCategory1(); if (oReader["cat1_id"] != null) oItem.Category1ID = Int32.Parse(oReader["cat1_id"].ToString()); if (oReader["cat1_name"] != null) oItem.Category1Name = oReader["cat1_name"].ToString(); //if (oReader["cat1_order"] != null) // oItem.Category1Order = Int32.Parse(oReader["cat1_order"].ToString()); if (oReader["parent_cat_id"] != null) oItem.ParentCatID = Int32.Parse(oReader["parent_cat_id"].ToString()); return oItem; }
private bool CheckCatOrder(CCategory1 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; }
/// <summary> /// This function updates the order number of the category 1 /// </summary> /// <param name="inUser"></param> /// <param name="inUser2"></param> /// <param name="inUpFlag"></param> /// <returns></returns> public CResult UpdateCategory1Order(CCategory1 inUser, CCategory1 inUser2, bool inUpFlag) { try { if (inUpFlag) { //making up m_oResult = RMS.DataAccess.Database.Instance.Category1.UpdateCategory1OrderUP(inUser, inUser2); } else { //Making down m_oResult = RMS.DataAccess.Database.Instance.Category1.UpdateCategory1OrderDown(inUser, inUser2); } } catch (Exception ex) { System.Console.WriteLine("Exception occur at re-ordering of the items : " + 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 re-ordering of the items", LogLevel.Error, "CItemManager"); } return m_oResult; }
public void Category1Update(CCategory1 inCategory1) { }
private void dgvFoodTypeList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == 4) { Int32 foodTypeID = Convert.ToInt32("0" + dgvFoodTypeList.Rows[e.RowIndex].Cells[0].Value); string foodTypeName = Convert.ToString(dgvFoodTypeList.Rows[e.RowIndex].Cells[1].Value); EditFoodTypeCtl objFoodType = new EditFoodTypeCtl(foodTypeID, foodTypeName); objFoodType.Parent = this.ParentForm; UserControlManager.UserControls.Push(this); Panel pnl = (Panel)this.ParentForm.Controls["pnlContext"]; string s = pnl.Name; objFoodType.ParentForm.Controls[s].Controls.Clear(); objFoodType.ParentForm.Controls[s].Controls.Add(objFoodType); } else if (e.ColumnIndex == 5) { if (MessageBox.Show("Are you sure you want to delete the selected food type?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int foodTypeID = 0; bool bTempBool = Int32.TryParse(dgvFoodTypeList.Rows[e.RowIndex].Cells[0].Value.ToString(), out foodTypeID); if (bTempBool) { CCategory1 objFoodType = new CCategory1(); objFoodType.Category1ID = foodTypeID; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.DeleteCat1(objFoodType); if (oResult.IsSuccess) { dgvFoodTypeList.Rows.RemoveAt(e.RowIndex); } } } } } catch (Exception exp) { throw exp; } }
public void Category1Insert(CCategory1 inCategory1) { }
public void Category1Delete(CCategory1 inCategory1) { }
private void btnSave_Click(object sender, EventArgs e) { CResult oValidResult = ValidateForm(); if (oValidResult.IsSuccess) { int iTempCat = Int32.Parse(cmbParentCategory.SelectedValue.ToString()); String sTempStr = txtFoodType.Text.Trim(); CCategory1 objCategory = new CCategory1(); objCategory.CurrentUserId = RMSGlobal.LogInUserName; objCategory.LoginDateTime = RMSGlobal.GetCurrentDateTime(); objCategory.Category1Name = sTempStr; objCategory.ParentCatID = iTempCat; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.AddCategory1(objCategory); if (oResult.IsSuccess) { lblSaveStatus.Text = "Category1 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 btnDown_Click(object sender, EventArgs e) { try { if (m_selectedIndex >= 0 && dgvFoodTypeList.Rows.Count > m_selectedIndex) { int currentCategoryID = Int32.Parse(dgvFoodTypeList.Rows[m_selectedIndex].Cells[0].Value.ToString()); int currentCategoryOrder = Int32.Parse(dgvFoodTypeList.Rows[m_selectedIndex].Cells[3].Value.ToString()); CCategory1 oCat = new CCategory1(); oCat.Category1ID = currentCategoryID; oCat.Category1OrderNumber = currentCategoryOrder; if ((m_selectedIndex + 1) > 0 && dgvFoodTypeList.Rows.Count > (m_selectedIndex + 1)) { int antiCategoryID = Int32.Parse(dgvFoodTypeList.Rows[(m_selectedIndex + 1)].Cells[0].Value.ToString()); int antiCategoryOrder = Int32.Parse(dgvFoodTypeList.Rows[(m_selectedIndex + 1)].Cells[3].Value.ToString()); int iTempIndex = m_selectedIndex + 1; CCategory1 oCat1 = new CCategory1(); oCat1.Category1ID = antiCategoryID; oCat1.Category1OrderNumber = antiCategoryOrder; CCategoryManager oCatManager = new CCategoryManager(); CResult oResult = oCatManager.UpdateCategory1Order(oCat, oCat1, false); if (oResult.IsSuccess) { if (m_bGridFlag) { Int32 foodTypeID = Convert.ToInt32(cmbParentCategory.SelectedValue); FillCategory1ByID(foodTypeID); dgvFoodTypeList.Rows[0].Selected = false; dgvFoodTypeList.Rows[iTempIndex].Selected = true; m_selectedIndex = iTempIndex; if (m_selectedIndex > 12) { dgvFoodTypeList.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12; } } else { Int32 foodTypeID = Convert.ToInt32(cmbParentCategory.SelectedValue); FillCategory1ByID(foodTypeID); dgvFoodTypeList.Rows[0].Selected = false; dgvFoodTypeList.Rows[iTempIndex].Selected = true; m_selectedIndex = iTempIndex; if (m_selectedIndex > 12) { dgvFoodTypeList.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12; } } } } } } catch (Exception exp) { MessageBox.Show(exp.Message + "Error Occured. Please contact to your administrator.", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public CResult GetCategory1(CCategory1 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()) inCat = ReaderToCategory1(oReader); } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return oResult; }