public RMS.Common.ObjectModel.CResult GetParentCategory(RMS.Common.ObjectModel.CParentCategory inCat) { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = String.Format(SqlQueries.GetQuery(Query.GetParentCatByID), inCat.ParentCatID); IDataReader oReader = this.ExecuteReader(sSql); if (oReader != null) { if (oReader.Read()) { CParentCategory oCat = ReaderToParentCategory(oReader); oResult.Data = oCat; 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 CheckParentCatUpdate(CParentCategory inUser) { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = String.Format(SqlQueries.GetQuery(Query.CheckDupParentCatUpdate), inUser.ParentCatName, inUser.ParentCatID); IDataReader oReader = this.ExecuteReader(sSql); if (oReader != null) { if (oReader.Read()) { if (oReader["parent_cat_id"] != null) { int iTemp = Int32.Parse(oReader["parent_cat_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); }
private void dgvParentCategory_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == 2) { Int32 parentCatId = Convert.ToInt32("0" + dgvParentCategory.Rows[e.RowIndex].Cells[0].Value); string parentCatName = Convert.ToString(dgvParentCategory.Rows[e.RowIndex].Cells[1].Value); UpdateParentCtl objUpdate = new UpdateParentCtl(parentCatId, parentCatName); 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 == 3) { if (MessageBox.Show("Are you sure you want to delete the selected parent category?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int parentCatId = 0; bool bTempBool = Int32.TryParse(dgvParentCategory.Rows[e.RowIndex].Cells[0].Value.ToString(), out parentCatId); if (bTempBool) { CParentCategory oCat = new CParentCategory(); oCat.ParentCatID = parentCatId; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.DeleteParentCat(oCat); if (oResult.IsSuccess) { dgvParentCategory.Rows.RemoveAt(e.RowIndex); } } } } } catch (Exception exp) { throw exp; } }
public CResult DeleteParentCat(CParentCategory inUser) { try { m_oResult = RMS.DataAccess.Database.Instance.ParentCat.ParentCatDelete(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 oValidResult = ValidateForm(); if (oValidResult.IsSuccess) { String sTempStr = txtParentCategoryName.Text.Trim(); if (sTempStr.Equals(String.Empty)) { lblSaveStatus.Text = " Write the name of the category."; lblSaveStatus.Visible = true; } else { CParentCategory oTempParent = new CParentCategory(); oTempParent.ParentCatName = sTempStr; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.AddParentCat(oTempParent); if (oResult.IsSuccess) { lblSaveStatus.Text = " Parent category has been added successfully."; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } } } else { lblSaveStatus.Text = oValidResult.Message; lblSaveStatus.Visible = true; } }
private CParentCategory ReaderToParentCategory(IDataReader oReader) { CParentCategory oItem = new CParentCategory(); if (oReader["parent_cat_id"] != null) { oItem.ParentCatID = Int32.Parse(oReader["parent_cat_id"].ToString()); } if (oReader["parent_cat_name"] != null) { oItem.ParentCatName = oReader["parent_cat_name"].ToString(); } return(oItem); }
private void btnUpdate_Click(object sender, EventArgs e) { CResult oResult = ValidateForm(); if (oResult.IsSuccess) { CParentCategory objParentCat = new CParentCategory(); objParentCat.ParentCatName = txtParentCategoryName.Text.Trim(); objParentCat.ParentCatID = m_iParentCat; CCategoryManager oManager = new CCategoryManager(); CResult oResult2 = oManager.UpdateParentCat(objParentCat); if (oResult2.IsSuccess) { lblSaveStatus.Text = "Parent category information has been updated successfully. "; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult2.Message; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } }
private void btnSave_Click(object sender, EventArgs e) { //To Get parent catagory Order Number String queryStr = SqlQueries.GetQuery(Query.GetMaxParentCategoryNumber); CDalConfig oTempDal = ConfigManager.GetConfig <CDalConfig>(); String tempConnStr = oTempDal.ConnectionString; // Create a new data adapter based on the specified query. SqlDataAdapter dataAdapter = new SqlDataAdapter(queryStr, tempConnStr); // Populate a new data table and bind it to the BindingSource. DataTable table = new DataTable(); //table.Locale = System.Globalization.CultureInfo.InvariantCulture; dataAdapter.Fill(table); int lastMaxParentValue = Convert.ToInt32(table.Rows[0]["Column1"].ToString()); CResult oValidResult = ValidateForm(); if (oValidResult.IsSuccess) { String sTempStr = txtParentCategoryName.Text.Trim(); if (sTempStr.Equals(String.Empty)) { lblSaveStatus.Text = " Write the name of the category."; lblSaveStatus.Visible = true; } else { CParentCategory oTempParent = new CParentCategory(); oTempParent.ParentCatName = sTempStr; oTempParent.ParentCatID = lastMaxParentValue + 1; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.AddParentCat(oTempParent); if (oResult.IsSuccess) { lblSaveStatus.Text = " Parent category has been added successfully."; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } } } else { lblSaveStatus.Text = oValidResult.Message; lblSaveStatus.Visible = true; } }