public CResult Cat3Delete(CCategory3 oCat) { CResult oResult = new CResult(); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.DeleteCategory3), oCat.Category3ID); 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 RMS.Common.ObjectModel.CResult Cat3Delete(RMS.Common.ObjectModel.CCategory3 oCat) { CResult oResult = new CResult(); try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.DeleteCategory3), oCat.Category3ID); this.ExecuteNonQuery(sqlCommand); 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 AddCat3(CCategory3 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; }
public CResult AddCategory3(CCategory3 inUser) { try { m_oResult = RMS.DataAccess.Database.Instance.Category3.AddCat3(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 AddItemVoidReport() { COrderManager tempOrderManager = new COrderManager(); CResult oResult = tempOrderManager.OrderInfoByOrderID(m_orderID); COrderInfo tempOrderInfo = new COrderInfo(); if (oResult.IsSuccess && oResult.Data != null) { tempOrderInfo = (COrderInfo)oResult.Data; } ItemVoid aItemVoid=new ItemVoid(); aItemVoid.OrderId = (int)m_orderID; aItemVoid.Creator_Id = tempOrderInfo.UserID; aItemVoid.RemoverId = RMS.RMSGlobal.m_iLoginUserID; ReasonForm aReasonForm = new ReasonForm(); aReasonForm.ShowDialog(); aItemVoid.Reason = aReasonForm.reason; aItemVoid.VoidDate = DateTime.Now; foreach (ListViewItem lsvItem in lsvRemovable.Items) { try { aItemVoid.Quantity = Convert.ToDouble(lsvItem.SubItems[1].Text); aItemVoid.ItemName = lsvItem.SubItems[0].Text; int id = Convert.ToInt32(lsvItem.SubItems[3].Text); CCategory3 aCategory3 = new CCategory3(); CCategory3DAO aCategory3Dao = new CCategory3DAO(); aCategory3 = aCategory3Dao.GetAllCategory3ByCategory3ID(id); aItemVoid.Amount = aItemVoid.Quantity * aCategory3.Category3TablePrice; OrderVoidDAO aOrderVoidDao = new OrderVoidDAO(); aOrderVoidDao.InsertItemForVoid(aItemVoid); } catch (Exception) { } } }
private CCategory3 ReaderToCategory3(IDataReader inReader) { CCategory3 tempCategory3 = new CCategory3(); if (inReader["cat3_id"] != null) tempCategory3.Category3ID = int.Parse(inReader["cat3_id"].ToString()); if (inReader["cat3_name"] != null) tempCategory3.Category3Name = inReader["cat3_name"].ToString(); if (inReader["cat3_order"] != null) tempCategory3.Category3Order = int.Parse(inReader["cat3_order"].ToString()); if (inReader["cat2_id"] != null) tempCategory3.Category2ID = int.Parse(inReader["cat2_id"].ToString()); if (inReader["description"] != null) tempCategory3.Category3Description = inReader["description"].ToString(); if (inReader["table_price"] != null) tempCategory3.Category3TablePrice = Double.Parse(inReader["table_price"].ToString()); if (inReader["tw_price"] != null) tempCategory3.Category3TakeAwayPrice = Double.Parse(inReader["tw_price"].ToString()); if (inReader["bar_price"] != null) tempCategory3.Category3BarPrice = Double.Parse(inReader["bar_price"].ToString()); if (inReader["status"] != null) tempCategory3.Category3OrderStatus= int.Parse(inReader["status"].ToString()); if (inReader["view_table"] != null) tempCategory3.Category3ViewTable = int.Parse(inReader["view_table"].ToString()); if (inReader["view_bar"] != null) tempCategory3.Category3ViewBar = int.Parse(inReader["view_bar"].ToString()); if (inReader["view_takeaway"] != null) tempCategory3.Category3ViewTakeAway = int.Parse(inReader["view_takeaway"].ToString()); return tempCategory3; }
private bool CheckCat3ForUpdate(CCategory3 p_objCategory3) { CResult oResult = new CResult(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory3Latest), p_objCategory3.Category3Name, p_objCategory3.Category2ID, p_objCategory3.Category3Description, p_objCategory3.Category3TablePrice, p_objCategory3.Category3TakeAwayPrice, p_objCategory3.Category3BarPrice, p_objCategory3.Category3OrderStatus, 0, p_objCategory3.Category3ViewTable, p_objCategory3.Category3ViewBar, p_objCategory3.Category3ViewTakeAway, p_objCategory3.MIRank, RMS.RMSGlobal.LoginUserName, DateTime.Now.Ticks, p_objCategory3.MInitialQuantity, p_objCategory3.MUnlimitStatus, //p_objCategory3.MRetailPrice, //p_objCategory3.MWholeSalePrice, //p_objCategory3.MLastPurchasePrice, p_objCategory3.Category3TablePrice, p_objCategory3.Category3TakeAwayPrice, p_objCategory3.Category3BarPrice, p_objCategory3.MUnitsInStock, p_objCategory3.MReorderLevel, p_objCategory3.MQtyPerSaleUint, p_objCategory3.MQtyPerPurchaseUnit, p_objCategory3.MStandardUoM, p_objCategory3.MSalesUoM, p_objCategory3.MPurchaseUoM, Convert.ToByte(p_objCategory3.MNonTaxableGood), Convert.ToByte(p_objCategory3.MNonStockable), p_objCategory3.MSupplierId, p_objCategory3.MBarCode, p_objCategory3.ItemSellingIn, // Convert.ToByte(p_objCategory3.MVatIncluded), p_objCategory3.Category3ID); // new //string sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateCategory3Latest), // //p_objCategory3.Category3Name, // //p_objCategory3.Category2ID, // //p_objCategory3.Category3Description, // //p_objCategory3.Category3TablePrice, // //p_objCategory3.Category3TakeAwayPrice, // //p_objCategory3.Category3BarPrice, // //p_objCategory3.Category3OrderStatus, // //0, // //p_objCategory3.Category3ViewTable, // //p_objCategory3.Category3ViewBar, // //p_objCategory3.Category3ViewTakeAway, // p_objCategory3.MIRank, // RMS.RMSGlobal.LoginUserName, // DateTime.Now.Ticks, // p_objCategory3.MInitialQuantity, // p_objCategory3.MUnlimitStatus, // //p_objCategory3.MRetailPrice, // //p_objCategory3.MWholeSalePrice, // //p_objCategory3.MLastPurchasePrice, // // p_objCategory3.Category3TablePrice, // //p_objCategory3.Category3TakeAwayPrice, // //p_objCategory3.Category3BarPrice, // p_objCategory3.MUnitsInStock, // //p_objCategory3.MReorderLevel, // //p_objCategory3.MQtyPerSaleUint, // //p_objCategory3.MQtyPerPurchaseUnit, // //p_objCategory3.MStandardUoM, // //p_objCategory3.MSalesUoM, // //p_objCategory3.MPurchaseUoM, // //Convert.ToByte(p_objCategory3.MNonTaxableGood), // ////Convert.ToByte(p_objCategory3.MNonStockable), // //p_objCategory3.MSupplierId, // //p_objCategory3.MBarCode, // p_objCategory3.ItemSellingIn, // //Convert.ToByte(p_objCategory3.MVatIncluded), // p_objCategory3.Category3ID); IDataReader oReader = this.ExecuteReader(sqlCommand); 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"); } finally { this.CloseConnection(); } return false; }
public CResult RawMatinStockInsert(CCategory3 inCategory3, int inCatOrder, float AddQty, string Unit) { CResult objResult = new CResult(); try { bool bTempFlag = CheckCat3ForUpdate(inCategory3); if (bTempFlag) { objResult.Message = "Category exists with this name."; } else { // string sqlCommand = ""; List<CCat3Rank> oTempList = new List<CCat3Rank>(); List<CCat3Rank> oTempList2 = new List<CCat3Rank>(); int iTempCat2Order = 0; CResult oResult4 = GetCategory2Order(inCategory3.Category2ID); if (oResult4.IsSuccess && oResult4.Data != null) { iTempCat2Order = (int)oResult4.Data; } else { return objResult; } CResult oResult2 = GetOrderCandidate(inCategory3); if (oResult2.IsSuccess && oResult2.Data != null) { oTempList = (List<CCat3Rank>)oResult2.Data; } CResult oResult3 = GetOrderCandidateLower(inCategory3, 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 == inCategory3.Category3ID) { iTempInt2 = inCategory3.Category3Order; UpdateCat3Rank(oTempCat3Rank, iTempCat2Order, iTempInt2); List<CCat4Rank> oTempCat4List = oTempCat3Rank.ChildCat4List; if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, inCategory3.Category3Order); } } else { iTempInt2 = inCategory3.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, RMS.RMSGlobal.LoginUserName, DateTime.Now.Ticks); // this.ExecuteNonQuery(sqlCommand); } } inCategory3.Category3Name = inCategory3.Category3Name.Replace("''", "'"); inCategory3.Category3Name = inCategory3.Category3Name.Replace("'", "''"); inCategory3.Category3Description = inCategory3.Category3Description.Replace("''", "'"); inCategory3.Category3Description = inCategory3.Category3Description.Replace("'", "''"); // sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateCategory3), inCategory3.Category3Name, inCategory3.Category2ID, inCategory3.Category3Description, inCategory3.Category3TablePrice, inCategory3.Category3TakeAwayPrice, inCategory3.Category3BarPrice, inCategory3.Category3OrderStatus, inCategory3.Category3Order, inCategory3.Category3ViewTable, inCategory3.Category3ViewBar, inCategory3.Category3ViewTakeAway, inCategory3.Category3ID, RMS.RMSGlobal.LoginUserName, DateTime.Now.Ticks, inCategory3.MInitialQuantity, inCategory3.MUnlimitStatus, inCategory3.ItemSellingIn); // sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateCategory3), inCategory3.Category3Name, inCategory3.Category2ID, inCategory3.Category3Description, inCategory3.Category3OrderStatus, inCategory3.Category3Order, inCategory3.Category3ViewTable, inCategory3.Category3ViewBar, inCategory3.Category3ViewTakeAway, inCategory3.Category3ID, RMS.RMSGlobal.LoginUserName, DateTime.Now.Ticks, inCategory3.MInitialQuantity, inCategory3.MUnlimitStatus, inCategory3.ItemSellingIn); // this.ExecuteNonQuery(sqlCommand); sqlCommand = ""; iTempInt3 = 1; for (counter = 0; counter < oTempList2.Count; counter++) { CCat3Rank oTempCat3Rank = oTempList2[counter]; if (oTempCat3Rank.Category3ID == inCategory3.Category3ID) { iTempInt2 = inCategory3.Category3Order; UpdateCat3Rank(oTempCat3Rank, iTempCat2Order, inCategory3.Category3Order); List<CCat4Rank> oTempCat4List = oTempCat3Rank.ChildCat4List; if (oTempCat4List.Count > 0) { UpdateChildCat4Rank(oTempCat4List, iTempCat2Order, inCategory3.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, RMS.RMSGlobal.LoginUserName, DateTime.Now.Ticks); // if (inCategory3.MProductType == "RawMaterial") // { // sqlCommand = String.Format(SqlQueries.GetQuery(Query.InsertRawMatinStock), iTempInt2, oTempCat3Rank.Category3ID, inCategory3.Category3Name, inCategory3.Category3Description, inCategory3.Category2ID, inCategory3.MStandardUoM, inCategory3.MUnitsInStock, RMS.RMSGlobal.LoginUserName, DateTime.Now.Ticks); // this.ExecuteNonQuery(sqlCommand); // } } } if (inCategory3.MProductType == "Raw Material") { float PrevQty = inCategory3.MUnitsInStock - AddQty; sqlCommand = String.Format(SqlQueries.GetQuery(Query.InsertRawMatinStock), inCategory3.Category3ID, inCategory3.Category2ID, inCategory3.Category3Name, inCategory3.Category3Description, DateTime.Now.Ticks, Unit, inCategory3.MUnitsInStock, DateTime.Now, AddQty, PrevQty); this.ExecuteNonQuery(sqlCommand); } // 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; }
private CCategory3 ReaderToCategory3(IDataReader oReader) { CCategory3 oItem = new CCategory3(); if (oReader["cat3_id"] != null) oItem.Category3ID = Int32.Parse(oReader["cat3_id"].ToString()); if (oReader["cat3_name"] != null) oItem.Category3Name = oReader["cat3_name"].ToString(); if (oReader["cat2_id"] != null) oItem.Category2ID = Int32.Parse(oReader["cat2_id"].ToString()); if (oReader["description"] != null) oItem.Category3Description = oReader["description"].ToString(); if (oReader["table_price"] != null) oItem.Category3TablePrice = Double.Parse(oReader["table_price"].ToString()); if (oReader["tw_price"] != null) oItem.Category3TakeAwayPrice = Double.Parse(oReader["tw_price"].ToString()); if (oReader["bar_price"] != null) oItem.Category3BarPrice = Double.Parse(oReader["bar_price"].ToString()); if (oReader["status"] != null) oItem.Category3OrderStatus = Int32.Parse(oReader["status"].ToString()); if (oReader["cat3_order"] != null) oItem.Category3Order = Int32.Parse(oReader["cat3_order"].ToString()); if (oReader["view_table"] != null) oItem.Category3ViewTable = Int32.Parse(oReader["view_table"].ToString()); if (oReader["view_bar"] != null) oItem.Category3ViewBar = Int32.Parse(oReader["view_bar"].ToString()); if (oReader["view_takeaway"] != null) oItem.Category3ViewTakeAway = Int32.Parse(oReader["view_takeaway"].ToString()); if (oReader["food_item_stock_quantity"] != null) oItem.InitialItemQuantity = Int32.Parse("0"+oReader["food_item_stock_quantity"]); if (oReader["unlimited_status"] != null) oItem.UnlimitStatus = Convert.ToInt32(oReader["unlimited_status"]); if (oReader["selling_in"] != null) oItem.ItemSellingIn = Convert.ToString(oReader["selling_in"]); //Vat if (oReader["vat_Rate"] != null) oItem.vatRate = Double.Parse(oReader["vat_Rate"].ToString()); if (oReader["vat_included"] != null) oItem.vatIncluded = Convert.ToBoolean(oReader["vat_included"].ToString()); try { if (oReader["productType"] != null) { oItem.ProductType = oReader["productType"].ToString(); } } catch { } //print_area try { if (oReader["print_area"] != null) { oItem.PrintArea = oReader["print_area"].ToString(); } } catch { } try { if (oReader["uom"] != null) { oItem.UoM = oReader["uom"].ToString(); } } catch { } if (oReader["cat3_rank"] != null) { String sTempStr = oReader["cat3_rank"].ToString(); if (!sTempStr.Equals(String.Empty)) { oItem.Rank = Int64.Parse(sTempStr); } } try { oItem.TableCost = Convert.ToDouble(oReader["tablecost"]); } catch (Exception) { } try { oItem.TakeAwayCost = Convert.ToDouble(oReader["takeawaycost"]); } catch (Exception) { } try { oItem.BarCost= Convert.ToDouble(oReader["barcost"]); } catch (Exception) { } return oItem; }
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); }
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); }
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; }
private void LoadExistingData() { CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.GetCategory3(m_foodItemID); CCategory3 objFoodItem = new CCategory3(); if (oResult.IsSuccess && oResult.Data != null) { objFoodItem = (CCategory3)oResult.Data; txtProductName.Text = objFoodItem.Category3Name; txtOrder.Text = objFoodItem.Category3Order.ToString(); m_iCat3Order = objFoodItem.Category3Order; txtDescription.Text = objFoodItem.Category3Description; txtTablePrice.Text = objFoodItem.Category3TablePrice.ToString("F02"); txtTakeawayPrice.Text = objFoodItem.Category3TakeAwayPrice.ToString("F02"); txtBarPrice.Text = objFoodItem.Category3BarPrice.ToString("F02"); cmbSellingIn.Text = objFoodItem.ItemSellingIn; txtVateRate.Text = objFoodItem.vatRate.ToString(); selectarealabel.Text = objFoodItem.PrintArea; tblCost.Text = objFoodItem.TableCost.ToString("F02"); takeawayCost.Text = objFoodItem.TakeAwayCost.ToString("F02"); barCost.Text = objFoodItem.BarCost.ToString("F02"); try { chkVateIncluded.Checked = objFoodItem.vatIncluded; } catch { } if (objFoodItem.UnlimitStatus==1) { txtInitialQuantity.Clear(); chkUnlimited.Checked = true; } else { txtInitialQuantity.Text = objFoodItem.InitialItemQuantity.ToString(); } m_iRank = objFoodItem.Rank; if (objFoodItem.Category3ViewTable == 1) chkTable.Checked = true; if (objFoodItem.Category3ViewBar == 1) chkBar.Checked = true; if (objFoodItem.Category3ViewTakeAway == 1) chkTakeAway.Checked = true; } oResult = oManager.GetCategoryAncestors(m_foodItemID, 3); CCategoryAncestor oCatAnc = (CCategoryAncestor)oResult.Data; if (oResult.IsSuccess && oResult.Data != null) { int tmpCat3ID = oCatAnc.Category3ID; int tmpCat2ID = oCatAnc.Category2ID; int tmpCat1ID = oCatAnc.Category1ID; int tmpParentCatID = oCatAnc.ParentCategoryID; if (objFoodItem.Category3OrderStatus == 1) { m_activeStatus = true; rdoActive.Checked = true; } else if (objFoodItem.Category3OrderStatus == 0) { rdoInActive.Checked = true; m_activeStatus = false; } cmbParent.SelectedValue = tmpParentCatID; cmbFoodType.SelectedValue = tmpCat1ID; cmbCategory.SelectedValue = tmpCat2ID; } }
private CCategory3 ReaderToCategory3(IDataReader oReader) { CCategory3 oItem = new CCategory3(); if (oReader["cat3_id"] != null) oItem.Category3ID = Int32.Parse(oReader["cat3_id"].ToString()); if (oReader["cat3_name"] != null) oItem.Category3Name = oReader["cat3_name"].ToString(); if (oReader["cat2_id"] != null) oItem.Category2ID = Int32.Parse(oReader["cat2_id"].ToString()); if (oReader["description"] != null) oItem.Category3Description = oReader["description"].ToString(); if (oReader["table_price"] != null) oItem.Category3TablePrice = Double.Parse(oReader["table_price"].ToString()); if (oReader["tw_price"] != null) oItem.Category3TakeAwayPrice = Double.Parse(oReader["tw_price"].ToString()); if (oReader["bar_price"] != null) oItem.Category3BarPrice = Double.Parse(oReader["bar_price"].ToString()); if (oReader["status"] != null) oItem.Category3OrderStatus = Int32.Parse(oReader["status"].ToString()); if (oReader["cat3_order"] != null) oItem.Category3Order = Int32.Parse(oReader["cat3_order"].ToString()); if (oReader["view_table"] != null) oItem.Category3ViewTable = Int32.Parse(oReader["view_table"].ToString()); if (oReader["view_bar"] != null) oItem.Category3ViewBar = Int32.Parse(oReader["view_bar"].ToString()); if (oReader["view_takeaway"] != null) oItem.Category3Order = Int32.Parse(oReader["view_takeaway"].ToString()); if (oReader["cat3_rank"] != null) oItem.Rank = Int64.Parse(oReader["cat3_rank"].ToString()); return oItem; }
/// <summary> /// Saving the food item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { CResult objResult = ValidateForm(); if (objResult.IsSuccess) { CCategory3 productItem = new CCategory3(); productItem = objFoodItemUpdate; // productItem.Category2ID = Int32.Parse(cmbCategory.SelectedValue.ToString()); // productItem.Category3Name = txtProductName.Text.Trim(); // productItem.Category3Description = txtDescription.Text.Trim(); //productItem.Category3TablePrice = objFoodItemUpdate.Category3TablePrice; //productItem.Category3TakeAwayPrice = objFoodItemUpdate.Category3TakeAwayPrice; //productItem.Category3BarPrice = objFoodItemUpdate.Category3BarPrice; /* start: price */ if (!txtRetailPrice.Text.Trim().Equals(String.Empty)) { // productItem.MRetailPrice = Double.Parse(txtRetailPrice.Text.Trim()); productItem.Category3TablePrice = Double.Parse(txtRetailPrice.Text.Trim()); } if (!txtWholeSalePrice.Text.Trim().Equals(String.Empty)) { //productItem.MWholeSalePrice = Double.Parse(txtWholeSalePrice.Text.Trim()); productItem.Category3TakeAwayPrice = Double.Parse(txtWholeSalePrice.Text.Trim()); } if (!txtLastPurchasePrice.Text.Trim().Equals(String.Empty)) { // productItem.MLastPurchasePrice = Double.Parse(txtLastPurchasePrice.Text.Trim()); productItem.Category3BarPrice = Double.Parse(txtLastPurchasePrice.Text.Trim()); } // is input price vat inluded // if (chbVatIncluded.Checked) if (cmbboxVatIncluded.SelectedIndex == 0) { // double vat = Program.vat / 100; /* productItem.Category3TablePrice = Convert.ToDouble( (productItem.Category3TablePrice/(1+vat)).ToString("F02")); productItem.RetailPrice = Convert.ToDouble((productItem.RetailPrice / (1 + vat)).ToString("F02")); productItem.Category3TakeAwayPrice = Convert.ToDouble((productItem.Category3TakeAwayPrice/(1+vat)).ToString("F02")); productItem.WholeSalePrice =Convert.ToDouble(( productItem.WholeSalePrice / (1 + vat)).ToString("F02")); productItem.Category3BarPrice =Convert.ToDouble(( productItem.Category3BarPrice / (1 + vat)).ToString("F02")); productItem.LastPurchasePrice = Convert.ToDouble((productItem.LastPurchasePrice / (1 + vat)).ToString("F02")); */ #if VATFIXED // int i = 0; #else //productItem.Category3TablePrice = (Double)Convert.ToDecimal((productItem.Category3TablePrice / (1 + vat))); //productItem.MRetailPrice = (Double)Convert.ToDecimal((productItem.MRetailPrice / (1 + vat))); //productItem.Category3TakeAwayPrice = (Double)Convert.ToDecimal((productItem.Category3TakeAwayPrice / (1 + vat))); //productItem.MWholeSalePrice = (Double)Convert.ToDecimal((productItem.MWholeSalePrice / (1 + vat))); //productItem.Category3BarPrice = (Double)Convert.ToDecimal((productItem.Category3BarPrice / (1 + vat))); //productItem.MLastPurchasePrice = (Double)Convert.ToDecimal((productItem.MLastPurchasePrice / (1 + vat))); #endif //productItem.Category3TablePrice = (Double) Convert.ToDecimal((productItem.Category3TablePrice / (1 + vat))); //productItem.RetailPrice = (Double)Convert.ToDecimal((productItem.RetailPrice / (1 + vat))); //productItem.Category3TakeAwayPrice = (Double)Convert.ToDecimal((productItem.Category3TakeAwayPrice / (1 + vat))); //productItem.WholeSalePrice = (Double)Convert.ToDecimal((productItem.WholeSalePrice / (1 + vat))); //productItem.Category3BarPrice = (Double)Convert.ToDecimal((productItem.Category3BarPrice / (1 + vat))); //productItem.LastPurchasePrice = (Double)Convert.ToDecimal((productItem.LastPurchasePrice / (1 + vat))); } /* end: price */ // active or inactive //if (rdoActive.Checked) //{ // productItem.Category3OrderStatus = 1; //} //else if (rdoInactive.Checked) //{ // productItem.Category3OrderStatus = 0; //} // stockable if (chkunstockable.Checked) { productItem.MInitialQuantity = 0; productItem.MUnlimitStatus = 1; } else { if (cmbSellingIn.SelectedItem.ToString() == "Per Piece" || cmbSellingIn.SelectedItem.ToString() == "") { productItem.MInitialQuantity = Convert.ToInt32("0" + txtInitialQuantity.Text); } else { productItem.MInitialQuantity = Convert.ToInt32("0" + txtInitialQuantity.Text); } productItem.MUnlimitStatus = 0; } // Item selling : "Per Piece" - Whether the item sold in quantity or weight productItem.ItemSellingIn = cmbSellingIn.SelectedItem.ToString(); productItem.MBarCode = txtBoxBarcode.Text; productItem.MUnitsInStock = int.Parse(txtInitialQuantity.Text); if (cmbSellingIn.SelectedItem.ToString() == "Per Piece" || cmbSellingIn.SelectedItem.ToString() == "") { productItem.MUnitsInStock = Convert.ToInt32("0" + txtInitialQuantity.Text); } else { productItem.MUnitsInStock = Convert.ToInt32("0" + txtInitialQuantity.Text); } //non stocablke productItem.MNonStockable = chkunstockable.Checked; productItem.MNonTaxableGood = chkNontaxable.Checked; productItem.MReorderLevel = int.Parse(txtReorderLevel.Text); //start: UoM //if (!cmbStanUoM.SelectedValue.ToString().Equals(string.Empty)) //{ // productItem.MStandardUoM = cmbStanUoM.SelectedValue.ToString(); //} //if (!cmbSalesUoM.SelectedValue.ToString().Equals(string.Empty)) //{ // productItem.MSalesUoM = cmbSalesUoM.SelectedValue.ToString(); // productItem.MQtyPerSaleUint = int.Parse(txtBoxUnitPerSaleUnit.Text); //} //else //{ // productItem.MSalesUoM = cmbStanUoM.SelectedValue.ToString(); // productItem.MQtyPerSaleUint = 1; //} //if (!cmbPurUoM.SelectedValue.ToString().Equals(string.Empty)) //{ // productItem.MPurchaseUoM = cmbPurUoM.SelectedValue.ToString(); // productItem.MQtyPerPurchaseUnit = int.Parse(txtBoxUnitPerPurchaseUnit.Text); //} //else //{ // productItem.MPurchaseUoM = cmbStanUoM.SelectedValue.ToString(); // productItem.MQtyPerPurchaseUnit = 1; //} if (cmbboxVatIncluded.Visible) { productItem.MVatIncluded = !Convert.ToBoolean(cmbboxVatIncluded.SelectedIndex); } else { productItem.MVatIncluded = false; } if (rdbRaw.Checked) { productItem.MProductType = rdbRaw.Text; } else if (rdbFinished.Checked) { productItem.MProductType = rdbFinished.Text; } CCategory3DAO cCategory3Dao = new CCategory3DAO(); CResult oResult2 = new CResult(); if (m_iCat3ID > 0) { // update new category3 productItem.Category3ID = m_iCat3ID; oResult2 = cCategory3Dao.Category3Update(productItem, 0); } else { // add new category3 oResult2 = cCategory3Dao.Category3Insert(productItem); } // end: add/update cat3 if (oResult2.IsSuccess) { lblSaveStatus.Text = " The product has been Updated successfully."; lblSaveStatus.Visible = true; currentStock = Convert.ToDouble(txtInitialQuantity.Text); } else { lblSaveStatus.Text = "The product can not be Updated. Please try again. "; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = objResult.Message; lblSaveStatus.Visible = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private bool CheckCatOrder(CCategory3 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> /// Saving the food item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { CResult objResult = ValidateForm(); if (objResult.IsSuccess) { CCategory3 objFoodItem = new CCategory3(); objFoodItem.Category2ID = Int32.Parse(cmbCategory.SelectedValue.ToString()); objFoodItem.Category3Name = txtProductName.Text.Trim(); objFoodItem.Category3Description = txtDescription.Text.Trim(); if (chkTable.Checked) { objFoodItem.Category3ViewTable = 1; } if (chkBar.Checked) { objFoodItem.Category3ViewBar = 1; } if (chkTakeAway.Checked) { objFoodItem.Category3ViewTakeAway = 1; } if (!txtTablePrice.Text.Trim().Equals(String.Empty)) { objFoodItem.Category3TablePrice = Double.Parse(txtTablePrice.Text.Trim()); } if (!txtTakeawayPrice.Text.Trim().Equals(String.Empty)) { objFoodItem.Category3TakeAwayPrice = Double.Parse(txtTakeawayPrice.Text.Trim()); } if (!txtBarPrice.Text.Trim().Equals(String.Empty)) { objFoodItem.Category3BarPrice = Double.Parse(txtBarPrice.Text.Trim()); } if (rdoActive.Checked) { objFoodItem.Category3OrderStatus = 1; } else if (rdoInactive.Checked) { objFoodItem.Category3OrderStatus = 0; } if (chkUnlimited.Checked) { objFoodItem.InitialItemQuantity = 0; objFoodItem.UnlimitStatus = 1; } else { objFoodItem.InitialItemQuantity = Convert.ToInt32("0"+txtInitialQuantity.Text); objFoodItem.UnlimitStatus = 0; } objFoodItem.ItemSellingIn = cmbSellingIn.Text; //Whether the item sold in quantity or weight try { objFoodItem.vatRate = Convert.ToDouble(txtVateRate.Text.ToString()); } catch { objFoodItem.vatRate = 0.00; } if (chkVateIncluded.Checked) { objFoodItem.vatIncluded = true; } else { objFoodItem.vatIncluded = false; } objFoodItem.ProductType = ProductType; try { objFoodItem.UoM = cmbSellingIn.Text; } catch { } CCategoryManager oManager = new CCategoryManager(); CResult oResult2 = oManager.AddCategory3(objFoodItem); if (oResult2.IsSuccess) { lblSaveStatus.Text = " The product has been saved successfully."; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = "The product can not be added. Please try again. "; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = objResult.Message; lblSaveStatus.Visible = true; } }
public CResult GetCategory3(CCategory3 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 = ReaderToCategory3(oReader); // } //} //catch (Exception ex) //{ // Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); // oResult.IsException = true; //} //finally //{ // this.CloseConnection(); //} return oResult; }
public CResult UpdateCategory3Order(CCategory3 inUser, CCategory3 inUser2, bool inUpFlag) { try { if (inUpFlag) { //up m_oResult = RMS.DataAccess.Database.Instance.Category3.Cat3UpdateOrderUp(inUser, inUser2); } else { //down m_oResult = RMS.DataAccess.Database.Instance.Category3.Cat3UpdateOrderDown(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 CCategory3 ReaderToCategory3(IDataReader oReader) { CCategory3 oItem = new CCategory3(); if (oReader["cat3_id"] != null) oItem.Category3ID = Int32.Parse(oReader["cat3_id"].ToString()); if (oReader["cat3_name"] != null) oItem.Category3Name = oReader["cat3_name"].ToString(); if (oReader["cat2_id"] != null) oItem.Category2ID = Int32.Parse(oReader["cat2_id"].ToString()); if (oReader["description"] != null) oItem.Category3Description = oReader["description"].ToString(); if (oReader["table_price"] != null) oItem.Category3TablePrice = Double.Parse(oReader["table_price"].ToString()); if (oReader["tw_price"] != null) oItem.Category3TakeAwayPrice = Double.Parse(oReader["tw_price"].ToString()); if (oReader["bar_price"] != null) oItem.Category3BarPrice = Double.Parse(oReader["bar_price"].ToString()); if (oReader["status"] != null) oItem.Category3OrderStatus = Int32.Parse(oReader["status"].ToString()); if (oReader["cat3_order"] != null) oItem.Category3Order = Int32.Parse(oReader["cat3_order"].ToString()); if (oReader["view_table"] != null) oItem.Category3ViewTable = Int32.Parse(oReader["view_table"].ToString()); if (oReader["view_bar"] != null) oItem.Category3ViewBar = Int32.Parse(oReader["view_bar"].ToString()); if (oReader["view_takeaway"] != null) oItem.Category3ViewTakeAway = Int32.Parse(oReader["view_takeaway"].ToString()); if (oReader["food_item_stock_quantity"] != null) oItem.InitialItemQuantity = Int32.Parse("0"+oReader["food_item_stock_quantity"]); if (oReader["unlimited_status"] != null) oItem.UnlimitStatus = Convert.ToInt32(oReader["unlimited_status"]); if (oReader["selling_in"] != null) oItem.ItemSellingIn = Convert.ToString(oReader["selling_in"]); if (oReader["cat3_rank"] != null) { String sTempStr = oReader["cat3_rank"].ToString(); if (!sTempStr.Equals(String.Empty)) { oItem.Rank = Int64.Parse(sTempStr); } } return oItem; }
/// <summary> /// Show existing Data /// </summary> private void showExistingData() { CCategory3DAO cCategory3Dao = new CCategory3DAO(); objFoodItemUpdate = new CCategory3(); objFoodItemUpdate = cCategory3Dao.GetAllCategory3ByCategory3ID(m_iCat3ID); CCategoryAncestorDAO cCategoryAncestorDao = new CCategoryAncestorDAO(); CResult oResult = cCategoryAncestorDao.GetCategoryAnchestors(m_iCat3ID, 3); CCategoryAncestor oCatAnc = (CCategoryAncestor)oResult.Data; //if (oResult.IsSuccess && oResult.Data != null) //{ if (objFoodItemUpdate != null) { //objFoodItemUpdate = (CCategory3)oResult.Data; txtProductName.Text = objFoodItemUpdate.Category3Name; //txtBoxBarcode.Text = objFoodItemUpdate.MBarCode; txtInitialQuantity.Text = objFoodItemUpdate.MInitialQuantity.ToString(); if (objFoodItemUpdate.MUnlimitStatus == 1) { //txtInitialQuantity.Clear(); chkunstockable.Checked = true; } else { chkunstockable.Checked = false; //txtInitialQuantity.Text = objFoodItem.InitialItemQuantity.ToString(); } txtReorderLevel.Text = objFoodItemUpdate.MReorderLevel.ToString(); // txtRetailPrice.Text = objFoodItemUpdate.MRetailPrice.ToString("F02"); txtRetailPrice.Text = objFoodItemUpdate.Category3TablePrice.ToString("F02"); txtDescription.Text = objFoodItemUpdate.Category3Description; txtInitialQuantity.Text = objFoodItemUpdate.MUnitsInStock.ToString(); currentStock = objFoodItemUpdate.MUnitsInStock; chkNontaxable.Checked = objFoodItemUpdate.MNonTaxableGood; if (objFoodItemUpdate.MVatIncluded) { #if VATFIXED cmbboxVatIncluded.SelectedIndex = 0; txtRetailPrice.Text = objFoodItemUpdate.RetailPrice.ToString("F02"); txtLastPurchasePrice.Text = objFoodItemUpdate.LastPurchasePrice.ToString("F02"); txtWholeSalePrice.Text = objFoodItemUpdate.WholeSalePrice.ToString("F02"); #else // chbVatIncluded.Checked = true; // double vat = 1 + Program.vat / 100; //txtRetailPrice.Text = (objFoodItemUpdate.MRetailPrice * vat).ToString("F02"); //txtLastPurchasePrice.Text = (objFoodItemUpdate.MLastPurchasePrice * vat).ToString("F02"); //txtWholeSalePrice.Text = (objFoodItemUpdate.MWholeSalePrice * vat).ToString("F02"); //txtRetailPrice.Text = (objFoodItemUpdate.Category3TablePrice * vat).ToString("F02"); //txtLastPurchasePrice.Text = (objFoodItemUpdate.Category3TakeAwayPrice * vat).ToString("F02"); //txtWholeSalePrice.Text = (objFoodItemUpdate.Category3BarPrice * vat).ToString("F02"); txtRetailPrice.Text = objFoodItemUpdate.Category3TablePrice.ToString("F02"); txtLastPurchasePrice.Text = objFoodItemUpdate.Category3TakeAwayPrice.ToString("F02"); txtWholeSalePrice.Text = objFoodItemUpdate.Category3BarPrice.ToString("F02"); cmbboxVatIncluded.SelectedIndex = 0; #endif } else { // chbVatIncluded.Checked = false; //txtRetailPrice.Text = objFoodItemUpdate.MRetailPrice.ToString("F02"); //txtLastPurchasePrice.Text = objFoodItemUpdate.MLastPurchasePrice.ToString("F02"); //txtWholeSalePrice.Text = objFoodItemUpdate.MWholeSalePrice.ToString("F02"); txtRetailPrice.Text = objFoodItemUpdate.Category3TablePrice.ToString("F02"); txtLastPurchasePrice.Text = objFoodItemUpdate.Category3TakeAwayPrice.ToString("F02"); txtWholeSalePrice.Text = objFoodItemUpdate.Category3BarPrice.ToString("F02"); cmbboxVatIncluded.SelectedIndex = 1; } if (objFoodItemUpdate.Category3OrderStatus > 0) rdoActive.Checked = true; else rdoInactive.Checked = true; //if (objFoodItem.ItemSellingIn == "Per Piece") cmbSellingIn.SelectedText = "Per Piece"; //else if (objFoodItem.ItemSellingIn == "Per Weight") cmbSellingIn.SelectedText = "Per Weight"; try { cmbSellingIn.SelectedIndex = cmbSellingIn.FindString(objFoodItemUpdate.ItemSellingIn); cmbStanUoM.SelectedIndex = cmbStanUoM.FindString(objFoodItemUpdate.MStandardUoM); cmbSalesUoM.SelectedIndex = cmbSalesUoM.FindString(objFoodItemUpdate.MSalesUoM); cmbPurUoM.SelectedIndex = cmbPurUoM.FindString(objFoodItemUpdate.MPurchaseUoM); //cmbParent.SelectedValue = oCatAnc.ParentCategoryID; //cmbFoodType.SelectedValue = oCatAnc.Category2ID; //cmbCategory.SelectedValue = objFoodItemUpdate.Category3ID; } catch (Exception ex) { } } if (oResult.IsSuccess && oResult.Data != null) { int tmpCat3ID = oCatAnc.Category3ID; int tmpCat2ID = oCatAnc.Category2ID; int tmpCat1ID = oCatAnc.Category1ID; int tmpParentCatID = oCatAnc.ParentCategoryID; if (objFoodItemUpdate.Category3OrderStatus == 1) { //m_activeStatus = true; rdoActive.Checked = true; } else if (objFoodItemUpdate.Category3OrderStatus == 0) { //rdoInActive.Checked = true; //m_activeStatus = false; } // cmbParent.SelectedValue = tmpParentCatID; // cmbFoodType.SelectedValue = tmpCat2ID; // cmbCategory.SelectedValue = tmpCat3ID; } }
private void dgvFoodItem_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } try { if (e.ColumnIndex == 6) { Int32 itemID = Convert.ToInt32("0" + dgvFoodItem.Rows[e.RowIndex].Cells[0].Value); UpdateFoodItemCtl objUpdate = new UpdateFoodItemCtl(itemID); 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 == 7) { if (MessageBox.Show("Are you sure you want to delete the selected category?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int itemID = 0; bool bTempBool = Int32.TryParse(dgvFoodItem.Rows[e.RowIndex].Cells[0].Value.ToString(), out itemID); if (bTempBool) { CCategory3 oCat = new CCategory3(); oCat.Category3ID = itemID; CCategoryManager oManager = new CCategoryManager(); CResult oResult = oManager.DeleteCat3(oCat); if (oResult.IsSuccess) { dgvFoodItem.Rows.RemoveAt(e.RowIndex); } } } } } catch (Exception exp) { throw exp; } }
private void btnSave_Click(object sender, EventArgs e) { CResult oResult = ValidateForm(); if (oResult.IsSuccess) { CCategory3 objFoodItem = new CCategory3(); String tempName = txtProductName.Text; int tempCat3Order = int.Parse(txtOrder.Text); String tempDescription = txtDescription.Text; objFoodItem.PrintArea = printareacomboBox.Text; if (!txtTablePrice.Text.Trim().Equals(String.Empty)) { objFoodItem.Category3TablePrice = Double.Parse(txtTablePrice.Text.Trim()); } if (!txtBarPrice.Text.Trim().Equals(String.Empty)) { objFoodItem.Category3BarPrice = Double.Parse(txtBarPrice.Text.Trim()); } if (!txtTakeawayPrice.Text.Trim().Equals(String.Empty)) { objFoodItem.Category3TakeAwayPrice = Double.Parse(txtTakeawayPrice.Text.Trim()); } if (!tblCost.Text.Trim().Equals(String.Empty)) { objFoodItem.TableCost = Double.Parse(tblCost.Text.Trim()); } if (!takeawayCost.Text.Trim().Equals(String.Empty)) { objFoodItem.TakeAwayCost = Double.Parse(takeawayCost.Text.Trim()); } if (!barCost.Text.Trim().Equals(String.Empty)) { objFoodItem.BarCost = Double.Parse(barCost.Text.Trim()); } int tempViewTable = chkTable.Checked == true ? 1 : 0; int tempViewBar = chkBar.Checked == true ? 1 : 0; int tempViewTW = chkTakeAway.Checked == true ? 1 : 0; objFoodItem.Category3Name = tempName; objFoodItem.Category3Order = tempCat3Order; objFoodItem.Category3Description = tempDescription; objFoodItem.Category3ViewTable = tempViewTable; objFoodItem.Category3ViewBar = tempViewBar; objFoodItem.Category3ViewTakeAway = tempViewTW; objFoodItem.Category3ID = m_foodItemID; if (chkUnlimited.Checked) { objFoodItem.InitialItemQuantity =0; objFoodItem.UnlimitStatus = 1; } else { objFoodItem.InitialItemQuantity = Convert.ToInt32("0" + txtInitialQuantity.Text); objFoodItem.UnlimitStatus = 0; } objFoodItem.ItemSellingIn = cmbSellingIn.Text; objFoodItem.Category2ID = Int32.Parse(cmbCategory.SelectedValue.ToString()); if (m_activeStatus==true) { objFoodItem.Category3OrderStatus = 1; } else if (m_activeStatus) { objFoodItem.Category3OrderStatus = 0; } //Vat included or not and amount of vat try { objFoodItem.vatRate = Convert.ToDouble(txtVateRate.Text.ToString()); } catch { objFoodItem.vatRate = 0.00; } if (chkVateIncluded.Checked) { objFoodItem.vatIncluded = true; } else { objFoodItem.vatIncluded = false; } CCategoryManager oManager = new CCategoryManager(); CResult oResult2 = oManager.UpdateCategory3(objFoodItem, m_iCat3Order); if (oResult2.IsSuccess) { lblSaveStatus.Text = "Food item has been updated successfully. "; lblSaveStatus.Visible = true; } else { lblSaveStatus.Text = oResult2.Message; lblSaveStatus.Visible = true; } } else { lblSaveStatus.Text = oResult.Message; lblSaveStatus.Visible = true; } }
public void Category3Insert(CCategory3 inCategory3) { }
private CResult GetOrderCandidateSingle(CCategory3 oCat) { CResult oResult = new CResult(); try { List<int> iTempList = new List<int>(); this.OpenConnection(); CCat3Rank oTempCat2Rank = new CCat3Rank(); oTempCat2Rank.Category3ID = oCat.Category3ID; CResult oResult3 = GetChildCat4ByCat3(oCat.Category3ID); if (oResult3.IsSuccess && oResult3.Data != null) { List<CCat4Rank> oTempChildList2 = (List<CCat4Rank>)oResult3.Data; oTempCat2Rank.ChildCat4List = oTempChildList2; } oResult.Data = oTempCat2Rank; oResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in ItemGetById()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return oResult; }
private CCategory3 ReaderToCategory3(IDataReader inReader) { CCategory3 tempCategory3 = new CCategory3(); if (inReader["cat3_id"] != null) tempCategory3.Category3ID = int.Parse(inReader["cat3_id"].ToString()); if (inReader["cat3_name"] != null) tempCategory3.Category3Name = inReader["cat3_name"].ToString(); if (inReader["cat3_order"] != null) tempCategory3.Category3Order = int.Parse(inReader["cat3_order"].ToString()); if (inReader["cat2_id"] != null) tempCategory3.Category2ID = int.Parse(inReader["cat2_id"].ToString()); if (inReader["description"] != null) tempCategory3.Category3Description = inReader["description"].ToString(); if (inReader["table_price"] != null) tempCategory3.Category3TablePrice = Double.Parse(inReader["table_price"].ToString()); if (inReader["tw_price"] != null) tempCategory3.Category3TakeAwayPrice = Double.Parse(inReader["tw_price"].ToString()); if (inReader["bar_price"] != null) tempCategory3.Category3BarPrice = Double.Parse(inReader["bar_price"].ToString()); if (inReader["status"] != null) tempCategory3.Category3OrderStatus= int.Parse(inReader["status"].ToString()); if (inReader["view_table"] != null) tempCategory3.Category3ViewTable = int.Parse(inReader["view_table"].ToString()); if (inReader["view_bar"] != null) tempCategory3.Category3ViewBar = int.Parse(inReader["view_bar"].ToString()); if (inReader["view_takeaway"] != null) tempCategory3.Category3ViewTakeAway = int.Parse(inReader["view_takeaway"].ToString()); try { if (inReader["maximum_attributes"] != null) tempCategory3.Category3MaximumAttributes = int.Parse(inReader["maximum_attributes"].ToString()); } catch (Exception ex) { tempCategory3.Category3MaximumAttributes = 0; } try { if (inReader["selectable_attributes"] != null) tempCategory3.Category3SelectableAttributes = int.Parse(inReader["selectable_attributes"].ToString()); } catch (Exception ex) { tempCategory3.Category3SelectableAttributes = 0; } try { if (inReader["includedPrice"] != null) tempCategory3.IncludedPrice = int.Parse(inReader["includedPrice"].ToString()); } catch (Exception ex) { tempCategory3.IncludedPrice = 0; } try { if (inReader["defaultPrice"] != null) tempCategory3.DefaultCount = int.Parse(inReader["defaultPrice"].ToString()); } catch (Exception ex) { tempCategory3.DefaultCount = 0; } try { if (inReader["productType"] != null) tempCategory3.MProductType = inReader["productType"].ToString(); } catch (Exception ex) { tempCategory3.DefaultCount = 0; } try { if (inReader["RetailPrice"] != null && inReader["RetailPrice"].ToString() != "") // tempCategory3.MRetailPrice = Convert.ToDouble(inReader["RetailPrice"].ToString()); tempCategory3.Category3TablePrice = Convert.ToDouble(inReader["RetailPrice"].ToString()); } catch(Exception) { } try{if (inReader["WholeSalePrice"] != null && inReader["WholeSalePrice"].ToString() != "") // tempCategory3.MWholeSalePrice = Convert.ToDouble(inReader["WholeSalePrice"].ToString()); tempCategory3.Category3TakeAwayPrice = Convert.ToDouble(inReader["WholeSalePrice"].ToString()); } catch(Exception) { } try{if (inReader["LastPurchasePrice"] != null && inReader["LastPurchasePrice"].ToString() != "") // tempCategory3.MLastPurchasePrice = Convert.ToDouble(inReader["LastPurchasePrice"].ToString()); tempCategory3.Category3BarPrice = Convert.ToDouble(inReader["LastPurchasePrice"].ToString()); } catch(Exception) { } try{if (inReader["UnitsInStock"] != null && inReader["UnitsInStock"].ToString() != "") tempCategory3.MUnitsInStock = Convert.ToInt32(inReader["UnitsInStock"].ToString());} catch(Exception) { } try{if (inReader["ReorderLevel"] != null && inReader["ReorderLevel"].ToString() != "") tempCategory3.MReorderLevel = Convert.ToInt32(inReader["ReorderLevel"].ToString());} catch(Exception) { } try{if (inReader["QTYPerSaleUint"] != null && inReader["QTYPerSaleUint"].ToString() != "") tempCategory3.MQtyPerSaleUint = Convert.ToInt32(inReader["QTYPerSaleUint"].ToString());} catch(Exception) { } try{if (inReader["QTYPerPurchaseUnit"] != null && inReader["QTYPerPurchaseUnit"].ToString() != "") tempCategory3.MQtyPerPurchaseUnit = Convert.ToInt32(inReader["QTYPerPurchaseUnit"].ToString());} catch(Exception) { } try{if (inReader["StandardUoM"] != null && inReader["StandardUoM"].ToString() != "") tempCategory3.MStandardUoM = inReader["StandardUoM"].ToString();} catch(Exception) { } try{if (inReader["SalesUoM"] != null && inReader["SalesUoM"].ToString() != "") tempCategory3.MSalesUoM = inReader["SalesUoM"].ToString();} catch(Exception) { } try{if (inReader["PurchaseUoM"] != null && inReader["PurchaseUoM"].ToString() != "") tempCategory3.MPurchaseUoM = inReader["PurchaseUoM"].ToString();} catch(Exception) { } try{if (inReader["NonTaxableGood"] != null && inReader["NonTaxableGood"].ToString() != "") tempCategory3.MNonTaxableGood = Convert.ToBoolean(inReader["NonTaxableGood"].ToString());} catch(Exception) { } try{if (inReader["NonStockable"] != null && inReader["NonStockable"].ToString() != "") tempCategory3.MNonStockable = Convert.ToBoolean(inReader["NonStockable"].ToString());} catch(Exception) { } try{if (inReader["SupplierID"] != null && inReader["SupplierID"].ToString() != "") tempCategory3.MSupplierId = Convert.ToInt32(inReader["SupplierID"].ToString());} catch(Exception) { } try{ if (inReader["Barcode"] != null && inReader["Barcode"].ToString() != "") tempCategory3.MBarCode = Convert.ToString(inReader["Barcode"].ToString());} catch(Exception){} try { tempCategory3.TableCost = Convert.ToDouble(inReader["tablecost"]); } catch (Exception) { } try { tempCategory3.TakeAwayCost = Convert.ToDouble(inReader["takeawaycost"]); } catch (Exception) { } try { tempCategory3.BarCost = Convert.ToDouble(inReader["barcost"]); } catch (Exception) { } try { tempCategory3.VatRate = Convert.ToDouble(inReader["vat_Rate"]); } catch (Exception) { } try { if (inReader["unlimited_status"] != null) tempCategory3.MUnlimitStatus = Convert.ToInt32(inReader["unlimited_status"]); } catch (Exception) { } return tempCategory3; }
private bool CheckCatOrder3ForUpdate(CCategory3 inUser) { CResult oResult = new CResult(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.CheckCat3OrderForUpdate), inUser.Category3Order, inUser.Category2ID, inUser.Category3ID); IDataReader oReader = this.ExecuteReader(sqlCommand); 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"); } finally { this.CloseConnection(); } return false; }
public void Category3Delete(CCategory3 inCategory3) { }
private void btnDown_Click(object sender, EventArgs e) { try { if (m_selectedIndex >= 0 && dgvFoodItem.Rows.Count > m_selectedIndex) { int iTempInt = Int32.Parse(dgvFoodItem.Rows[m_selectedIndex].Cells[0].Value.ToString()); int iTempInt3 = Int32.Parse(dgvFoodItem.Rows[m_selectedIndex].Cells[2].Value.ToString()); CCategory3 oCat = new CCategory3(); oCat.Category3ID = iTempInt; oCat.Category3Order = iTempInt3; if ((m_selectedIndex + 1) > 0 && dgvFoodItem.Rows.Count > (m_selectedIndex + 1)) { int iTempInt2 = Int32.Parse(dgvFoodItem.Rows[(m_selectedIndex + 1)].Cells[0].Value.ToString()); int iTempInt4 = Int32.Parse(dgvFoodItem.Rows[(m_selectedIndex + 1)].Cells[2].Value.ToString()); int iTempIndex = m_selectedIndex + 1; CCategory3 oCat2 = new CCategory3(); oCat2.Category3ID = iTempInt2; oCat2.Category3Order = iTempInt4; if (cmbCategory.SelectedValue != null) { int iTempInt10 = Int32.Parse(cmbCategory.SelectedValue.ToString()); oCat2.Category2ID = iTempInt10; oCat.Category2ID = iTempInt10; } CCategoryManager oCatManager = new CCategoryManager(); CResult oResult = oCatManager.UpdateCategory3Order(oCat, oCat2, false); if (oResult.IsSuccess) { if (m_bGridFlag) { Int32 categoryID = Convert.ToInt32(cmbCategory.SelectedValue); FillFoodItem(categoryID); dgvFoodItem.Rows[0].Selected = false; dgvFoodItem.Rows[iTempIndex].Selected = true; m_selectedIndex = iTempIndex; if (m_selectedIndex > 12) { dgvFoodItem.FirstDisplayedScrollingRowIndex = m_selectedIndex - 12; } } else { Int32 categoryID = Convert.ToInt32(cmbCategory.SelectedValue); FillFoodItem(categoryID); dgvFoodItem.Rows[0].Selected = false; dgvFoodItem.Rows[iTempIndex].Selected = true; m_selectedIndex = iTempIndex; if (m_selectedIndex > 12) { dgvFoodItem.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 Category3Insert(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.MIRank, RMS.RMSGlobal.LoginUserName, DateTime.Now.Ticks, p_objCategory3.MInitialQuantity, p_objCategory3.MUnlimitStatus, //p_objCategory3.MRetailPrice, //p_objCategory3.MWholeSalePrice, //p_objCategory3.MLastPurchasePrice, p_objCategory3.Category3TablePrice, p_objCategory3.Category3TakeAwayPrice, p_objCategory3.Category3BarPrice, p_objCategory3.MUnitsInStock, p_objCategory3.MReorderLevel, p_objCategory3.MQtyPerSaleUint, p_objCategory3.MQtyPerPurchaseUnit, p_objCategory3.MStandardUoM, p_objCategory3.MSalesUoM, p_objCategory3.MPurchaseUoM, Convert.ToByte(p_objCategory3.MNonTaxableGood), Convert.ToByte(p_objCategory3.MNonStockable), p_objCategory3.MSupplierId, p_objCategory3.MBarCode, p_objCategory3.ItemSellingIn, Convert.ToByte(p_objCategory3.MVatIncluded), p_objCategory3.MProductType ); 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; }
public void Category3Update(CCategory3 inCategory3) { }
public List<CCategory3> GetCategory3ByCategory2ID(int cat2ID) { List<CCategory3> cCategory3List = new List<CCategory3>(); CCategory3 tempCategory3 = new CCategory3(); try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.GetCategory3ByCategory2ID), cat2ID); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { while (oReader.Read()) { tempCategory3 = new CCategory3(); tempCategory3 = ReaderToCategory3(oReader); if (tempCategory3 != null) { cCategory3List.Add(tempCategory3); } } } } catch (Exception ex) { System.Console.WriteLine("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex.Message + " in GetCategory3byCategoryType(string categoryType)", LogLevel.Error, "Database"); if (ex.GetType().Equals(typeof(SqlException))) { SqlException oSQLEx = ex as SqlException; if (oSQLEx.Number != 7619) throw new Exception("Exception occured at GetCategory3byCategoryType(string categoryType)", ex); } else { throw new Exception("Exception occured at GetCategory3byCategoryType(string categoryType)", ex); } } finally { this.CloseConnection(); } return cCategory3List; }
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); }
public void AddPurchaseStore(CCategory3 objFoodItem, string name) { try { this.OpenConnection(); string sqlComm = String.Format(SqlQueries.GetQuery(Query.AddPurchaseStore), objFoodItem.Category3Name, objFoodItem.UoM,objFoodItem.Category3ID,name); this.ExecuteNonQuery(sqlComm); } catch (Exception) { } finally { this.CloseConnection(); } }