示例#1
0
        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);
        }
示例#2
0
        /// <summary>
        /// Finding the maximum category 1 order number
        /// </summary>
        /// <returns></returns>
        private CResult GetMaxCatOrder()
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string      sqlCommand = SqlQueries.GetQuery(Query.GetMaxCat1Order);
                IDataReader oReader    = this.ExecuteReader(sqlCommand);
                if (oReader != null)
                {
                    if (oReader.Read())
                    {
                        if (oReader["max_cat1_order"] != null)
                        {
                            int iTempInt = Int32.Parse(oReader["max_cat1_order"].ToString());

                            oResult.Data = iTempInt;

                            oResult.IsSuccess = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return(oResult);
        }
示例#3
0
        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);
        }
示例#4
0
        private bool CheckCatOrder3(CCategory3 inUser)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string sSql = String.Format(SqlQueries.GetQuery(Query.CheckCat3Order), inUser.Category3Order, inUser.Category2ID);

                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {
                    if (oReader.Read())
                    {
                        if (oReader["cat3_id"] != null)
                        {
                            int iTemp = Int32.Parse(oReader["cat3_id"].ToString());

                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database");
                oResult.IsException = true;

                oResult.Message = ex.Message;
            }
            finally
            {
                this.CloseConnection();
            }
            return(false);
        }
示例#5
0
        private CResult GetCategory2Order(int inCat2ID)
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnection();
                string      sSql    = string.Format(SqlQueries.GetQuery(Query.GetCategory2Order), inCat2ID);
                IDataReader oReader = this.ExecuteReader(sSql);
                if (oReader != null)
                {
                    if (oReader.Read())
                    {
                        if (oReader["cat2_order"] != null)
                        {
                            int iTempInt = Int32.Parse(oReader["cat2_order"].ToString());

                            oResult.Data = iTempInt;

                            oResult.IsSuccess = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return(oResult);
        }
示例#6
0
        private CResult GetOrderCandidateLower(CCategory3 oCat, int inCatOrder)
        {
            CResult oResult = new CResult();

            try
            {
                List <int> iTempList = new List <int>();

                List <CCat3Rank> oTempCat3List = new List <CCat3Rank>();

                if (oCat.Category3Order <= inCatOrder)
                {
                    oResult.Data = oTempCat3List;

                    oResult.IsSuccess = true;
                }
                else
                {
                    this.OpenConnection();
                    string      sqlCommand = string.Format(SqlQueries.GetQuery(Query.GetCat3OrderCandidateLower), oCat.Category2ID, inCatOrder, oCat.Category3Order);
                    IDataReader oReader    = this.ExecuteReader(sqlCommand);
                    if (oReader != null)
                    {
                        while (oReader.Read())
                        {
                            if (oReader["cat3_id"] != null)
                            {
                                int iTempInt = Int32.Parse(oReader["cat3_id"].ToString());

                                iTempList.Add(iTempInt);
                            }
                        }

                        oReader.Close();

                        for (int counter = 0; counter < iTempList.Count; counter++)
                        {
                            int iTempCat2ID = iTempList[counter];

                            CCat3Rank oTempCat2Rank = new CCat3Rank();

                            oTempCat2Rank.Category3ID = iTempCat2ID;

                            CResult oResult3 = GetChildCat4ByCat3(iTempCat2ID);

                            if (oResult3.IsSuccess && oResult3.Data != null)
                            {
                                List <CCat4Rank> oTempChildList2 = (List <CCat4Rank>)oResult3.Data;

                                oTempCat2Rank.ChildCat4List = oTempChildList2;
                            }

                            oTempCat3List.Add(oTempCat2Rank);
                        }

                        oResult.Data = oTempCat3List;

                        oResult.IsSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database");

                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return(oResult);
        }
示例#7
0
        public RMS.Common.ObjectModel.CResult Cat3UpdateOrderUp(RMS.Common.ObjectModel.CCategory3 oCat, RMS.Common.ObjectModel.CCategory3 oCat2)
        {
            CResult oResult = new CResult();


            try
            {
                int iTempCat2Order = 0;

                CCat3Rank oTempList = new CCat3Rank();

                CCat3Rank oTempList2 = new CCat3Rank();

                CResult oResult4 = GetCategory2Order(oCat.Category2ID);

                if (oResult4.IsSuccess && oResult4.Data != null)
                {
                    iTempCat2Order = (int)oResult4.Data;
                }
                else
                {
                    return(oResult);
                }


                CResult oResult2 = GetOrderCandidateSingle(oCat);

                if (oResult2.IsSuccess && oResult2.Data != null)
                {
                    oTempList = (CCat3Rank)oResult2.Data;
                }


                CResult oResult3 = GetOrderCandidateSingle(oCat2);

                if (oResult3.IsSuccess && oResult3.Data != null)
                {
                    oTempList2 = (CCat3Rank)oResult3.Data;
                }

                int i = 0;

                this.OpenConnectionWithTransection();

                UpdateCat3Rank(oTempList, iTempCat2Order, oCat2.Category3Order);

                List <CCat4Rank> oTempCat4List = oTempList.ChildCat4List;

                if (oTempCat4List.Count > 0)
                {
                    UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, oCat2.Category3Order);
                }

                UpdateCat3Rank(oTempList2, iTempCat2Order, oCat.Category3Order);

                oTempCat4List = oTempList2.ChildCat4List;

                if (oTempCat4List.Count > 0)
                {
                    UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, oCat.Category3Order);
                }

                CCommonConstants oConstants = ConfigManager.GetConfig <CCommonConstants>();
                string           sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory3Order), oConstants.MaxOrderChange, oCat2.Category3ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                this.ExecuteNonQuery(sqlCommand);

                sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory3Order), oCat2.Category3Order, oCat.Category3ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                this.ExecuteNonQuery(sqlCommand);

                sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory3Order), oCat.Category3Order, oCat2.Category3ID, 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);
        }
示例#8
0
        public RMS.Common.ObjectModel.CResult Cat3Update(RMS.Common.ObjectModel.CCategory3 objFoodItem, int inCatOrder)
        {
            CResult objResult = new CResult();

            try
            {
                bool bTempFlag = CheckCat3ForUpdate(objFoodItem);

                if (bTempFlag)
                {
                    objResult.Message = "Category exists with this name.";
                }
                else
                {
                    List <CCat3Rank> oTempList = new List <CCat3Rank>();

                    List <CCat3Rank> oTempList2 = new List <CCat3Rank>();

                    int iTempCat2Order = 0;

                    CResult oResult4 = GetCategory2Order(objFoodItem.Category2ID);

                    if (oResult4.IsSuccess && oResult4.Data != null)
                    {
                        iTempCat2Order = (int)oResult4.Data;
                    }
                    else
                    {
                        return(objResult);
                    }



                    CResult oResult2 = GetOrderCandidate(objFoodItem);

                    if (oResult2.IsSuccess && oResult2.Data != null)
                    {
                        oTempList = (List <CCat3Rank>)oResult2.Data;
                    }

                    CResult oResult3 = GetOrderCandidateLower(objFoodItem, inCatOrder);

                    if (oResult3.IsSuccess && oResult3.Data != null)
                    {
                        oTempList2 = (List <CCat3Rank>)oResult3.Data;
                    }


                    this.OpenConnectionWithTransection();

                    string sqlCommand = "";

                    int iTempInt = 0;

                    int iTempInt2 = 0;

                    int iTempInt3 = 0;

                    int counter = 0;

                    for (counter = 0; counter < oTempList.Count; counter++)
                    {
                        CCat3Rank oTempCat3Rank = oTempList[counter];

                        if (oTempCat3Rank.Category3ID == objFoodItem.Category3ID)
                        {
                            iTempInt2 = objFoodItem.Category3Order;

                            UpdateCat3Rank(oTempCat3Rank, iTempCat2Order, iTempInt2);


                            List <CCat4Rank> oTempCat4List = oTempCat3Rank.ChildCat4List;

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, objFoodItem.Category3Order);
                            }
                        }
                        else
                        {
                            iTempInt2 = objFoodItem.Category3Order + 1 + iTempInt3;

                            iTempInt3 = iTempInt3 + 1;


                            UpdateCat3Rank(oTempCat3Rank, iTempCat2Order, iTempInt2);

                            List <CCat4Rank> oTempCat4List = oTempCat3Rank.ChildCat4List;

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, iTempInt2);
                            }

                            sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory3Order), iTempInt2, oTempCat3Rank.Category3ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                            this.ExecuteNonQuery(sqlCommand);
                        }
                    }

                    objFoodItem.Category3Name = objFoodItem.Category3Name.Replace("''", "'");
                    objFoodItem.Category3Name = objFoodItem.Category3Name.Replace("'", "''");

                    objFoodItem.Category3Description = objFoodItem.Category3Description.Replace("''", "'");
                    objFoodItem.Category3Description = objFoodItem.Category3Description.Replace("'", "''");


                    sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateCategory3), objFoodItem.Category3Name, objFoodItem.Category2ID, objFoodItem.Category3Description, objFoodItem.Category3TablePrice, objFoodItem.Category3TakeAwayPrice, objFoodItem.Category3BarPrice, objFoodItem.Category3OrderStatus, objFoodItem.Category3Order, objFoodItem.Category3ViewTable, objFoodItem.Category3ViewBar, objFoodItem.Category3ViewTakeAway, objFoodItem.Category3ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks, objFoodItem.InitialItemQuantity, objFoodItem.UnlimitStatus, objFoodItem.ItemSellingIn, objFoodItem.vatIncluded, objFoodItem.vatRate,
                                               objFoodItem.TableCost, objFoodItem.TakeAwayCost, objFoodItem.BarCost, objFoodItem.PrintArea);
                    this.ExecuteNonQuery(sqlCommand);

                    sqlCommand = "";

                    iTempInt3 = 1;


                    for (counter = 0; counter < oTempList2.Count; counter++)
                    {
                        CCat3Rank oTempCat3Rank = oTempList2[counter];

                        if (oTempCat3Rank.Category3ID == objFoodItem.Category3ID)
                        {
                            iTempInt2 = objFoodItem.Category3Order;

                            UpdateCat3Rank(oTempCat3Rank, iTempCat2Order, objFoodItem.Category3Order);

                            List <CCat4Rank> oTempCat4List = oTempCat3Rank.ChildCat4List;

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, objFoodItem.Category3Order);
                            }
                        }
                        else
                        {
                            iTempInt2 = inCatOrder + iTempInt3 - 1;

                            iTempInt3 = iTempInt3 + 1;

                            UpdateCat3Rank(oTempCat3Rank, iTempCat2Order, iTempInt2);

                            List <CCat4Rank> oTempCat4List = oTempCat3Rank.ChildCat4List;

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, iTempInt2);
                            }

                            sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory3Order), iTempInt2, oTempCat3Rank.Category3ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                            this.ExecuteNonQuery(sqlCommand);
                        }
                    }

                    this.CommitTransection();

                    objResult.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in Cat3Update()", LogLevel.Error, "Database");

                throw new Exception("Exception occure at Cat3Update()", ex);
            }
            finally
            {
                this.CloseConnection();
            }

            return(objResult);
        }
示例#9
0
        public RMS.Common.ObjectModel.CResult AddCat3(RMS.Common.ObjectModel.CCategory3 p_objCategory3)
        {
            CResult oResult = new CResult();

            try
            {
                bool bTempFlag = CheckCat3(p_objCategory3);

                if (bTempFlag)
                {
                    oResult.Message = "Category exists with this name.";
                }
                else
                {
                    CResult oResult2 = GetMaxCatOrder();

                    if (oResult2.IsSuccess && oResult2.Data != null)
                    {
                        int iTempOrder = (int)oResult2.Data;

                        iTempOrder = iTempOrder + 1;

                        p_objCategory3.Category3Name = p_objCategory3.Category3Name.Replace("''", "'");
                        p_objCategory3.Category3Name = p_objCategory3.Category3Name.Replace("'", "''");

                        p_objCategory3.Category3Description = p_objCategory3.Category3Description.Replace("''", "'");
                        p_objCategory3.Category3Description = p_objCategory3.Category3Description.Replace("'", "''");

                        this.OpenConnection();
                        string sqlCommand = String.Format(SqlQueries.GetQuery(Query.AddCategory3), p_objCategory3.Category3Name, p_objCategory3.Category2ID, p_objCategory3.Category3Description, p_objCategory3.Category3TablePrice, p_objCategory3.Category3TakeAwayPrice, p_objCategory3.Category3BarPrice, p_objCategory3.Category3OrderStatus, iTempOrder, p_objCategory3.Category3ViewTable, p_objCategory3.Category3ViewBar, p_objCategory3.Category3ViewTakeAway, p_objCategory3.Rank, RMSGlobal.LogInUserName, DateTime.Now.Ticks, p_objCategory3.InitialItemQuantity, p_objCategory3.UnlimitStatus, p_objCategory3.ItemSellingIn, p_objCategory3.vatIncluded, p_objCategory3.vatRate, p_objCategory3.ProductType, p_objCategory3.UoM,
                                                          p_objCategory3.TableCost, p_objCategory3.TakeAwayCost, p_objCategory3.BarCost, p_objCategory3.PrintArea);
                        this.ExecuteNonQuery(sqlCommand);


                        #region "Added By Baruri"

                        Int32 category3_Order = 0;
                        Int32 category2_id    = 0;
                        Int32 category2_order = 0;


                        this.OpenConnection();
                        sqlCommand = "select cat3_order,cat2_id from category3 where cat3_id=(select max(cat3_id) from category3)";
                        IDataReader objcategory3ID = this.ExecuteReader(sqlCommand);
                        if (objcategory3ID != null)
                        {
                            if (objcategory3ID.Read())
                            {
                                category3_Order = Convert.ToInt32(objcategory3ID["cat3_order"]);
                                category2_id    = Convert.ToInt32(objcategory3ID["cat2_id"]);
                            }
                        }

                        objcategory3ID.Close();

                        sqlCommand     = "select cat2_order from category2 where cat2_id=" + category2_id;
                        objcategory3ID = this.ExecuteReader(sqlCommand);

                        if (objcategory3ID != null)
                        {
                            if (objcategory3ID.Read())
                            {
                                category2_order = Convert.ToInt32(objcategory3ID["cat2_order"]);
                            }
                        }


                        CResult cresultCategoryRank = CalculateCat3Rank(category2_order, category3_Order);
                        Int64   cateRank            = Convert.ToInt64(cresultCategoryRank.Data);

                        objcategory3ID.Close();

                        sqlCommand = "update category3 set cat3_rank=" + cateRank + " where cat3_id=(select max(cat3_id) from category3)";
                        this.ExecuteNonQuery(sqlCommand);

                        this.CloseConnection();

                        #endregion


                        oResult.IsSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemInsert() in CUserInfoDAO class", LogLevel.Error, "Database");
            }
            finally
            {
                this.CloseConnection();
            }
            return(oResult);
        }
示例#10
0
        public CResult UpdateAllRank()
        {
            CResult oResult = new CResult();

            try
            {
                this.OpenConnectionWithTransection();
                string sSql = SqlQueries.GetQuery(Query.DeleteAllCat3Rank);
                this.ExecuteNonQuery(sSql);

                sSql = SqlQueries.GetQuery(Query.DeleteAllCat4Rank);
                this.ExecuteNonQuery(sSql);

                List <CCat3Rank> oTempCat3List = new List <CCat3Rank>();

                List <CCat4Rank> oTempCat4List = new List <CCat4Rank>();

                sSql = SqlQueries.GetQuery(Query.GetAllCat3Rank);

                IDataReader oReader = this.ExecuteReader(sSql);


                if (oReader != null)
                {
                    while (oReader.Read())
                    {
                        CCat3Rank oCat = ReaderToCat3Rank(oReader);

                        oTempCat3List.Add(oCat);
                    }
                }

                oReader.Close();


                sSql = SqlQueries.GetQuery(Query.GetAllCat4Rank);

                oReader = this.ExecuteReader(sSql);


                if (oReader != null)
                {
                    while (oReader.Read())
                    {
                        CCat4Rank oCat = ReaderToCat4Rank(oReader);

                        oTempCat4List.Add(oCat);
                    }
                }

                oReader.Close();

                int i = 0;

                for (i = 0; i < oTempCat3List.Count; i++)
                {
                    CCat3Rank oTempCat3Rank = oTempCat3List[i];

                    CResult oResult2 = CalculateCat3Rank(oTempCat3Rank.Category2Order, oTempCat3Rank.Category3Order);

                    if (oResult2.IsSuccess && oResult2.Data != null)
                    {
                        Int64 iTempRank = (Int64)oResult2.Data;

                        sSql = string.Format(SqlQueries.GetQuery(Query.UpdateCat3Rank), iTempRank, oTempCat3Rank.Category3ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);

                        this.ExecuteNonQuery(sSql);
                    }
                }


                for (i = 0; i < oTempCat4List.Count; i++)
                {
                    CCat4Rank oTempCat4Rank = oTempCat4List[i];

                    CResult oResult3 = CalculateCat4Rank(oTempCat4Rank.Category2Order, oTempCat4Rank.Category3Order, oTempCat4Rank.Category4Order);

                    if (oResult3.IsSuccess && oResult3.Data != null)
                    {
                        Int64 iTempRank = (Int64)oResult3.Data;

                        sSql = string.Format(SqlQueries.GetQuery(Query.UpdateCat4Rank), iTempRank, oTempCat4Rank.Category4ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);

                        this.ExecuteNonQuery(sSql);
                    }
                }

                this.CommitTransection();



                oResult.IsSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemDelete()", ex);

                this.RollBackTransection();
            }
            finally
            {
                this.CloseConnection();
            }

            return(oResult);
        }
示例#11
0
文件: CItemDAO.cs 项目: Jusharra/RMS
        public CResult SaveProductPLU(int productID, int categoryLabel, int productPLU)
        {
            Int32   categoryID     = 0;
            CResult objResult      = new CResult();
            int     resultantValue = -1;

            this.OpenConnection();
            string sqlCommand = "";

            this.OpenConnection();

            sqlCommand = string.Format(SqlQueries.GetQuery(Query.GetProduct3IDFromPLU), productPLU);
            IDataReader oReader = this.ExecuteReader(sqlCommand);

            if (oReader != null)
            {
                if (oReader.Read())
                {
                    if (oReader["cat3_id"] != null)
                    {
                        categoryID = Int32.Parse(oReader["cat3_id"].ToString());

                        objResult.Data = categoryID;

                        objResult.IsSuccess = true;
                    }
                }
            }

            oReader.Close();

            if (categoryID == 0)     //If after category 3 no item found.
            {
                sqlCommand = string.Format(SqlQueries.GetQuery(Query.GetProduct4IDFromPLU), productPLU);
                oReader    = this.ExecuteReader(sqlCommand);
                if (oReader != null)
                {
                    if (oReader.Read())
                    {
                        if (oReader["cat4_id"] != null)
                        {
                            categoryID = Int32.Parse(oReader["cat4_id"].ToString());

                            objResult.Data = categoryID;

                            objResult.IsSuccess = true;
                        }
                    }
                }
                oReader.Close();
            }


            if (categoryID == 0)//If no product for the PLU
            {
                if (categoryLabel == 3)
                {
                    sqlCommand = string.Format(SqlQueries.GetQuery(Query.SaveProduct3PLU), productPLU, productID);
                }
                else
                {
                    sqlCommand = string.Format(SqlQueries.GetQuery(Query.SaveProduct4PLU), productPLU, productID);
                }
                this.ExecuteNonQuery(sqlCommand);
            }
            else
            {
                resultantValue = 1;
                objResult.Data = resultantValue;
            }
            objResult.Data = resultantValue;
            return(objResult);
        }
示例#12
0
        public RMS.Common.ObjectModel.CResult GetTotalReport(long inStartTime, long inEndTime)
        {
            CResult        oTempResult   = new CResult();
            List <CReport> oReportList   = new List <CReport>();
            Int64          tempStartTime = inStartTime;
            float          tempResTotal  = 0;
            float          tempBarTotal  = 0;
            float          tempRoomTotal = 0;
            float          tempExeTotal  = 0;

            try
            {
                while (tempStartTime < inEndTime)
                {
                    CReport oReport     = new CReport();
                    Int64   tempEndTime = tempStartTime + 864000000000;
                    //if (tempEndTime > inEndTime)
                    //{
                    //    tempEndTime = inEndTime;
                    //}
                    //else ;

                    this.OpenConnection();

                    int         count   = 0;
                    String      sSql    = String.Format(SqlQueries.GetQuery(Query.GetOrderCountByDate), tempStartTime, tempEndTime);
                    IDataReader oReader = this.ExecuteReader(sSql);
                    if (oReader != null)
                    {
                        while (oReader.Read())
                        {
                            int.TryParse(oReader["total"].ToString(), out count);
                        }
                    }
                    oReader.Close();

                    if (count > 0)
                    {
                        sSql    = String.Format(SqlQueries.GetQuery(Query.GetTotalPaymentByDayNDept), tempStartTime, tempEndTime, "Resturent");
                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {
                            while (oReader.Read())
                            {
                                tempResTotal = 0;
                                float.TryParse(oReader["total"].ToString(), out tempResTotal);
                            }
                        }
                        oReader.Close();

                        sSql    = String.Format(SqlQueries.GetQuery(Query.GetTotalPaymentByDayNDept), tempStartTime, tempEndTime, "BarService");
                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {
                            while (oReader.Read())
                            {
                                tempBarTotal = 0;
                                float.TryParse(oReader["total"].ToString(), out tempBarTotal);
                            }
                        }
                        oReader.Close();

                        sSql    = String.Format(SqlQueries.GetQuery(Query.GetTotalPaymentByDayNDept), tempStartTime, tempEndTime, "WhiteRoom");
                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {
                            while (oReader.Read())
                            {
                                tempRoomTotal = 0;
                                float.TryParse(oReader["total"].ToString(), out tempRoomTotal);
                            }
                        }
                        oReader.Close();

                        sSql    = String.Format(SqlQueries.GetQuery(Query.GetTotalPaymentByDayNDept), tempStartTime, tempEndTime, "ExecutiveBar");
                        oReader = this.ExecuteReader(sSql);
                        if (oReader != null)
                        {
                            while (oReader.Read())
                            {
                                tempExeTotal = 0;
                                float.TryParse(oReader["total"].ToString(), out tempExeTotal);
                            }
                        }
                        oReader.Close();

                        oReport.Date                = tempStartTime;
                        oReport.ResturentPayment    = tempResTotal;
                        oReport.BarServicePayment   = tempBarTotal;
                        oReport.WhiteRoomPayment    = tempRoomTotal;
                        oReport.ExecutiveBarPayment = tempExeTotal;

                        oReport.TotalPayment = (tempResTotal + tempBarTotal + tempRoomTotal + tempExeTotal);
                        oReport.VATPayment   = (float)(oReport.TotalPayment * 17.5 / 100);

                        oReportList.Add(oReport);
                    }
                    tempStartTime += 864000000000;
                }
                oTempResult.Data      = oReportList;
                oTempResult.IsSuccess = true;
            }
            catch (Exception ex)
            {
                oTempResult.IsException = true;
                Logger.Write("Exception : " + ex + " in GetTotalReport()", LogLevel.Error, "Database");
                if (ex.GetType().Equals(typeof(SqlException)))
                {
                    SqlException oSQLEx = ex as SqlException;
                    if (oSQLEx.Number != 7619)
                    {
                        throw new Exception("Exception occured at GetTotalReport", ex);
                    }
                }
                else
                {
                    throw new Exception("Exception occure at GetTotalReport()", ex);
                }
            }
            finally
            {
                this.CloseConnection();
            }
            return(oTempResult);
        }
示例#13
0
        public RMS.Common.ObjectModel.CResult Cat2Update(RMS.Common.ObjectModel.CCategory2 p_objCat2, int p_catOrder)
        {
            CResult objResult = new CResult();

            try
            {
                bool blnTempFlag = CheckCat2ForUpdate(p_objCat2);

                if (blnTempFlag)
                {
                    objResult.Message = "Category exists with this name.";
                }
                else
                {
                    p_objCat2.Category2Name = p_objCat2.Category2Name.Replace("''", "'");
                    p_objCat2.Category2Name = p_objCat2.Category2Name.Replace("'", "''");

                    List <CCat2Rank> objRankTempList1 = new List <CCat2Rank>();

                    List <CCat2Rank> objRankTempList2 = new List <CCat2Rank>();

                    CResult objResult3 = GetOrderCandidateLower(p_objCat2, p_catOrder);

                    if (objResult3.IsSuccess && objResult3.Data != null)
                    {
                        objRankTempList2 = (List <CCat2Rank>)objResult3.Data;
                    }

                    CResult oResult2 = GetOrderCandidate(p_objCat2);

                    if (oResult2.IsSuccess && oResult2.Data != null)
                    {
                        objRankTempList1 = (List <CCat2Rank>)oResult2.Data;
                    }

                    this.OpenConnectionWithTransection();

                    string sqlCommand = "";

                    int iTempInt2 = 0;

                    int iTempInt3 = 0;

                    int counter = 0;

                    for (counter = 0; counter < objRankTempList1.Count; counter++)
                    {
                        CCat2Rank oTempCat2Rank = objRankTempList1[counter];

                        if (oTempCat2Rank.Category2ID == p_objCat2.Category2ID)
                        {
                            iTempInt2 = p_objCat2.Category2Order;


                            //iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }
                        }
                        else
                        {
                            iTempInt2 = p_objCat2.Category2Order + 1 + iTempInt3;


                            iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }

                            sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                            this.ExecuteNonQuery(sqlCommand);
                        }
                    }

                    sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2), p_objCat2.Category2Name, p_objCat2.Category1ID, p_objCat2.Category2Order, p_objCat2.Category2Type, p_objCat2.Category2Color, p_objCat2.Category2ViewTable, p_objCat2.Category2ViewBar, p_objCat2.Category2ViewTakeAway, p_objCat2.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                    this.ExecuteNonQuery(sqlCommand);

                    //this.CommitTransection();

                    sqlCommand = "";

                    iTempInt3 = 1;

                    for (counter = 0; counter < objRankTempList2.Count; counter++)
                    {
                        CCat2Rank oTempCat2Rank = objRankTempList2[counter];

                        if (oTempCat2Rank.Category2ID == p_objCat2.Category2ID)
                        {
                            iTempInt2 = p_objCat2.Category2Order;


                            //iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }
                        }
                        else
                        {
                            iTempInt2 = p_catOrder + iTempInt3 - 1;

                            iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }

                            sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                            this.ExecuteNonQuery(sqlCommand);
                        }
                    }

                    this.CommitTransection();

                    objResult.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database");
                this.RollBackTransection();
            }
            finally
            {
                this.CloseConnection();
            }
            return(objResult);
        }
示例#14
0
        public RMS.Common.ObjectModel.CResult Cat2UpdateOrderDown(RMS.Common.ObjectModel.CCategory2 oCat, RMS.Common.ObjectModel.CCategory2 oCat2)
        {
            CResult oResult = new CResult();

            try
            {
                CCommonConstants oConstants = ConfigManager.GetConfig <CCommonConstants>();

                CCat2Rank oTempList = new CCat2Rank();

                CCat2Rank oTempList2 = new CCat2Rank();


                CResult oResult2 = GetOrderCandidateSingle(oCat);

                if (oResult2.IsSuccess && oResult2.Data != null)
                {
                    oTempList = (CCat2Rank)oResult2.Data;
                }


                CResult oResult3 = GetOrderCandidateSingle(oCat2);

                if (oResult3.IsSuccess && oResult3.Data != null)
                {
                    oTempList2 = (CCat2Rank)oResult3.Data;
                }


                this.OpenConnectionWithTransection();

                //for (int i = 0; i < oTempList.Count; i++)
                //{
                //    CCat2Rank oTempCat2Rank = oTempList[i];

                List <CCat3Rank> oTempCat3List = oTempList.ChildCat3List;

                List <CCat4Rank> oTempCat4List = oTempList.ChildCat4List;

                if (oTempCat3List.Count > 0)
                {
                    UpdateChildCat3Rank(oTempCat3List, oCat2.Category2Order);
                }

                if (oTempCat4List.Count > 0)
                {
                    UpdateChildCat4Rank(oTempCat4List, oCat2.Category2Order);
                }

                // }

                //for (int k = 0; k < oTempList2.Count; k++)
                // {
                //CCat2Rank oTempCat2Rank = oTempList2[k];

                oTempCat3List = oTempList2.ChildCat3List;

                oTempCat4List = oTempList2.ChildCat4List;

                if (oTempCat3List.Count > 0)
                {
                    UpdateChildCat3Rank(oTempCat3List, oCat.Category2Order);
                }

                if (oTempCat4List.Count > 0)
                {
                    UpdateChildCat4Rank(oTempCat4List, oCat.Category2Order);
                }

                // }


                string sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), oConstants.MaxOrderChange, oCat.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                this.ExecuteNonQuery(sSql);

                sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), oCat.Category2Order, oCat2.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                this.ExecuteNonQuery(sSql);

                sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), oCat2.Category2Order, oCat.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                this.ExecuteNonQuery(sSql);

                oResult.IsSuccess = true;

                this.CommitTransection();
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemDelete()", ex);

                this.RollBackTransection();
            }
            finally
            {
                this.CloseConnection();
            }

            return(oResult);
        }
示例#15
0
        public RMS.Common.ObjectModel.CResult Cat2Update(RMS.Common.ObjectModel.CCategory2 oCat, int inCatOrder)
        {
            CResult oResult = new CResult();

            try
            {
                bool bTempFlag = CheckCat2ForUpdate(oCat);

                if (bTempFlag)
                {
                    oResult.Message = "Category exists with this name.";
                }
                else
                {
                    oCat.Category2Name = oCat.Category2Name.Replace("''", "'");
                    oCat.Category2Name = oCat.Category2Name.Replace("'", "''");

                    List <CCat2Rank> oTempList = new List <CCat2Rank>();

                    List <CCat2Rank> oTempList2 = new List <CCat2Rank>();


                    CResult oResult3 = GetOrderCandidateLower(oCat, inCatOrder);

                    if (oResult3.IsSuccess && oResult3.Data != null)
                    {
                        oTempList2 = (List <CCat2Rank>)oResult3.Data;
                    }

                    CResult oResult2 = GetOrderCandidate(oCat);

                    if (oResult2.IsSuccess && oResult2.Data != null)
                    {
                        oTempList = (List <CCat2Rank>)oResult2.Data;
                    }



                    this.OpenConnectionWithTransection();

                    string sSql = "";

                    int iTempInt = 0;

                    int iTempInt2 = 0;

                    int iTempInt3 = 0;

                    int i = 0;

                    for (i = 0; i < oTempList.Count; i++)
                    {
                        CCat2Rank oTempCat2Rank = oTempList[i];

                        if (oTempCat2Rank.Category2ID == oCat.Category2ID)
                        {
                            iTempInt2 = oCat.Category2Order;


                            //iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }
                        }
                        else
                        {
                            iTempInt2 = oCat.Category2Order + 1 + iTempInt3;


                            iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }

                            sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                            this.ExecuteNonQuery(sSql);
                        }
                    }

                    sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2), oCat.Category2Name, oCat.Category1ID, oCat.Category2Order, oCat.Category2Type, oCat.Category2Color, oCat.Category2ViewTable, oCat.Category2ViewBar, oCat.Category2ViewTakeAway, oCat.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                    this.ExecuteNonQuery(sSql);

                    //this.CommitTransection();

                    sSql = "";

                    iTempInt3 = 1;

                    for (i = 0; i < oTempList2.Count; i++)
                    {
                        CCat2Rank oTempCat2Rank = oTempList2[i];

                        if (oTempCat2Rank.Category2ID == oCat.Category2ID)
                        {
                            iTempInt2 = oCat.Category2Order;


                            //iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }
                        }
                        else
                        {
                            iTempInt2 = inCatOrder + iTempInt3 - 1;

                            iTempInt3 = iTempInt3 + 1;

                            List <CCat3Rank> oTempCat3List = oTempCat2Rank.ChildCat3List;

                            List <CCat4Rank> oTempCat4List = oTempCat2Rank.ChildCat4List;

                            if (oTempCat3List.Count > 0)
                            {
                                UpdateChildCat3Rank(oTempCat3List, iTempInt2);
                            }

                            if (oTempCat4List.Count > 0)
                            {
                                UpdateChildCat4Rank(oTempCat4List, iTempInt2);
                            }

                            sSql = String.Format(SqlQueries.GetQuery(Query.UpdateCategory2Order), iTempInt2, oTempCat2Rank.Category2ID, RMSGlobal.LogInUserName, DateTime.Now.Ticks);
                            this.ExecuteNonQuery(sSql);
                        }
                    }

                    this.CommitTransection();

                    oResult.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in ItemDelete()", LogLevel.Error, "Database");

                //throw new Exception("Exception occure at ItemDelete()", ex);

                this.RollBackTransection();
            }
            finally
            {
                this.CloseConnection();
            }

            return(oResult);
        }