Esempio n. 1
0
        public RMS.Common.ObjectModel.CResult AddParentCat(RMS.Common.ObjectModel.CParentCategory inUser)
        {
            CResult oResult = new CResult();

            try
            {
                bool bTempFlag = CheckParentCat(inUser);

                if (bTempFlag)
                {
                    oResult.Message = "Parent category exists with this name.";
                }
                else
                {
                    this.OpenConnection();
                    string sSql = String.Format(SqlQueries.GetQuery(Query.AddParentCategory), inUser.ParentCatName);

                    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);
        }
Esempio n. 2
0
        public RMS.Common.ObjectModel.CResult ParentCatDelete(RMS.Common.ObjectModel.CParentCategory oCat)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteParentCategory), oCat.ParentCatID);
                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);

                oResult.IsException = true;

                oResult.Message = ex.Message;
            }
            finally
            {
                this.CloseConnection();
            }

            return(oResult);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public CResult GetParentCategory(CParentCategory 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 = ReaderToCategory1(oReader);
                //}
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
Esempio n. 5
0
        public RMS.Common.ObjectModel.CResult ParentCatUpdate(RMS.Common.ObjectModel.CParentCategory oCat)
        {
            CResult oResult = new CResult();

            try
            {
                bool bTempFlag = CheckParentCatUpdate(oCat);

                if (bTempFlag)
                {
                    oResult.Message = "Parent category exists with this name.";
                }
                else
                {
                    this.OpenConnection();
                    string sSql = string.Format(SqlQueries.GetQuery(Query.UpdateParentCategory), oCat.ParentCatName, oCat.ParentCatID);
                    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);
        }
Esempio n. 6
0
        private CParentCategory ReaderToParentCategory(IDataReader inReader)
        {
            CParentCategory tempParentCategory = new CParentCategory();

            if (inReader["parent_cat_id"] != null)
                tempParentCategory.ParentCategoryID = int.Parse(inReader["parent_cat_id"].ToString());

            if (inReader["parent_cat_name"] != null)
                tempParentCategory.ParentCategoryName = inReader["parent_cat_name"].ToString();

            return tempParentCategory;
        }
Esempio n. 7
0
        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;
            }
        }
Esempio n. 8
0
        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;
            }
        }
Esempio n. 9
0
        public CResult AddParentCat(CParentCategory inUser)
        {
            CResult oResult = new CResult();

            try
            {
                bool bTempFlag = CheckParentCat(inUser);

                if (bTempFlag)
                {
                    oResult.Message = "Parent category exists with this name.";
                }
                else
                {
                    this.OpenConnection();
                    string sSql = String.Format(SqlQueries.GetQuery(Query.AddParentCategory), inUser.ParentCatName);

                    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;
        }
Esempio n. 10
0
        private void LoadParentCategory()
        {
            List<CParentCategory> tempParentCategoryList = new List<CParentCategory>();
            CParentCategoryDAO aCParentCategoryDao=new CParentCategoryDAO();
            tempParentCategoryList = aCParentCategoryDao.GetAllParentCategory();
            CParentCategory aCategory=new CParentCategory();
            aCategory.ParentCategoryName = "ALL";
            aCategory.ParentCategoryID = 0;
            tempParentCategoryList.Add(aCategory);

            cmbparentcategory.DataSource = tempParentCategoryList;
            cmbparentcategory.DisplayMember = "ParentCategoryName";
            cmbparentcategory.ValueMember = "ParentCategoryID";
        }
Esempio n. 11
0
        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;
            }
        }
Esempio n. 12
0
        public CResult UpdateParentCat(CParentCategory inUser)
        {
            try
            {
                m_oResult = RMS.DataAccess.Database.Instance.ParentCat.ParentCatUpdate(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;
        }
Esempio n. 13
0
        public CResult ParentCatDelete(CParentCategory oCat)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteParentCategory), oCat.ParentCatID);
                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;
        }
Esempio n. 14
0
 public void ParentCategoryInsert(CParentCategory inParentCategory)
 {
 }
Esempio n. 15
0
        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();

            if (oReader["parent_cat_order"] != null)
                oItem.Order = Int32.Parse(oReader["parent_cat_order"].ToString());

            return oItem;
        }
Esempio n. 16
0
        private bool CheckParentCat(CParentCategory inUser)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string sSql = String.Format(SqlQueries.GetQuery(Query.CheckDupParentCat), inUser.ParentCatName);

                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;
        }
Esempio n. 17
0
        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;
            }
        }
Esempio n. 18
0
 public void ParentCategoryDelete(CParentCategory inParentCategory)
 {
 }
Esempio n. 19
0
 public void ParentCategoryUpdate(CParentCategory inParentCategory)
 {
 }