/// <summary> /// Adding the online products with the current orders.Added by Baruri /// </summary> /// <param name="inOrderInfo"></param> /// <returns></returns> public void AddNewOnlineProducts(COrderDetails p_orderDetails) { try { COrderInfo tempOrderInfo = new COrderInfo(); Database.Instance.OrderDetails.AddNewOnlineProducts(p_orderDetails); m_oResult.IsSuccess = true; m_oResult.Message = "Data Inserted Successfully"; } catch (Exception ex) { System.Console.WriteLine("Exception occuer at InsertOrderInfo() : " + ex.Message); m_oResult.IsException = true; m_oResult.Action = EERRORNAME.EXCEPTION_OCCURE; m_oResult.Message = ex.Message; Logger.Write("Exception : " + ex + " in InsertOrderInfo()", LogLevel.Error, "COrderManager"); } }
/// <summary> /// Getting the online order details.Added By Baruri /// </summary> /// <param name="inOrderID"></param> /// <returns></returns> public CResult GetOnlineOrderDetailsByOrderID(long inOrderID) { CResult tempResult = new CResult(); COrderDetails tempOrderDetails = new COrderDetails(); List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.OnlineOrderDetailsByOrderID), inOrderID.ToString()); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { while (oReader.Read()) { tempOrderDetails = this.ReaderToOnlineOrderDetails(oReader); tempOrderDetailsList.Add(tempOrderDetails); } } tempResult.Data = tempOrderDetailsList; tempResult.IsSuccess = true; } catch (Exception ex) { Console.Write("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex + " in OrderDetailsGetByOrderDetailID()", LogLevel.Error, "Database"); if (ex.GetType().Equals(typeof(SqlException))) { SqlException oSQLEx = ex as SqlException; if (oSQLEx.Number != 7619) throw new Exception("Exception occured at OrderDetailsGetByOrderDetailID()", ex); } else { throw new Exception("Exception occure at OrderDetailsGetByOrderDetailID()", ex); } } finally { this.CloseConnection(); } return tempResult; }
/// <summary> /// Added by Baruri at 10.01.2009 /// </summary> /// <param name="p_onlineOrderDetails"></param> public void AddNewLocalProducts(COrderDetails p_orderDetails) { try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.AddNewLocalProducts), p_orderDetails.OrderQuantity, p_orderDetails.OrderAmount, p_orderDetails.ProductID, p_orderDetails.OrderID, p_orderDetails.OrderDetailsID, p_orderDetails.VatTotal,p_orderDetails.Amount_with_vat); this.ExecuteNonQuery(sqlCommand); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in AddNewOnlineProducts()", LogLevel.Error, "Database"); throw new Exception("Exception occure at AddNewOnlineProducts()", ex); } finally { this.CloseConnection(); } }
private COrderDetails ReaderToOrderDetails(IDataReader inReader) { COrderDetails tempOrderDetails = new COrderDetails(); if (inReader["order_detail_id"] != null) tempOrderDetails.OrderDetailsID = int.Parse(inReader["order_detail_id"].ToString()); if (inReader["order_id"] != null) tempOrderDetails.OrderID = int.Parse(inReader["order_id"].ToString()); if (inReader["product_id"] != null) tempOrderDetails.ProductID = Int32.Parse(inReader["product_id"].ToString()); if (inReader["quantity"] != null) tempOrderDetails.OrderQuantity = Int32.Parse(inReader["quantity"].ToString()); if (inReader["amount"] != null) tempOrderDetails.OrderAmount = Double.Parse(inReader["amount"].ToString()); if (inReader["remarks"] != null) tempOrderDetails.OrderRemarks = inReader["remarks"].ToString(); if (inReader["food_type"] != null) tempOrderDetails.OrderFoodType = inReader["food_type"].ToString(); if (inReader["cat_level"] != null) tempOrderDetails.CategoryLevel = Int32.Parse(inReader["cat_level"].ToString()); return tempOrderDetails; }
public COrderDetails OrderDetailsInsert(COrderDetails inOrderDetails) { COrderDetails tempOrderDetails = inOrderDetails; inOrderDetails.OrderRemarks = inOrderDetails.OrderRemarks.Replace("''", "'"); inOrderDetails.OrderRemarks = inOrderDetails.OrderRemarks.Replace("'", "''"); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.OrderDetailsInsert), inOrderDetails.OrderID, inOrderDetails.ProductID, inOrderDetails.OrderQuantity, inOrderDetails.OrderAmount, inOrderDetails.OrderRemarks, inOrderDetails.OrderFoodType, inOrderDetails.CategoryLevel); this.ExecuteNonQuery(sSql); sSql = SqlQueries.GetQuery(Query.ScopeIdentity); IDataReader oReader = this.ExecuteReader(sSql); if (oReader != null) { bool bIsRead = oReader.Read(); if (bIsRead) { tempOrderDetails.OrderDetailsID = Int64.Parse(oReader[0].ToString()); } } } catch (Exception ex) { Logger.Write("Exception : " + ex + " in OrderDetailsInsert()", LogLevel.Error, "Database"); throw new Exception("Exception occure at OrderDetailsInsert()", ex); } finally { this.CloseConnection(); } return tempOrderDetails; }
/// <summary> /// Added By Baruri /// </summary> /// <param name="inOrderDetails"></param> public void UpdateOnlineOrderDetails(COrderDetails inOrderDetails) { try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateOnlineOrdersDetails), inOrderDetails.OrderQuantity, inOrderDetails.OrderAmount, inOrderDetails.OnlineItemSequenceNumber); this.ExecuteNonQuery(sqlCommand); } catch (Exception ex) { Console.Write("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex + " in OrderDetailsUpdate()", LogLevel.Error, "Database"); throw new Exception("Exception occure at OrderDetailsUpdate()", ex); } finally { this.CloseConnection(); } }
public void UpdateKitchenQuantity(COrderDetails orderDetails) { bool success = false; try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateKitchenQuantity), orderDetails.OrderID, orderDetails.ProductID, orderDetails.OrderQuantity - orderDetails.KitchenQuantity); this.ExecuteNonQuery(sqlCommand); success = true; } catch (Exception ex) { throw new Exception("Error Occuring", ex); } finally { this.CloseConnection(); } // return success; }
/// <summary> /// Insert online ordered items /// </summary> /// <param name="inOrderDetails"></param> /// <returns></returns> public COrderDetails InsertOnlineOrderDetails(COrderDetails inOrderDetails) { COrderDetails tempOrderDetails = inOrderDetails; inOrderDetails.OrderRemarks = inOrderDetails.OrderRemarks.Replace("''", "'"); inOrderDetails.OrderRemarks = inOrderDetails.OrderRemarks.Replace("'", "''"); try { this.OpenConnection(); string sqlCommandName = String.Empty; sqlCommandName =string.Format(SqlQueries.GetQuery(Query.SelectOnlineOrderDetailsDetailsByIDFromOrderTable), inOrderDetails.OrderID); IDataReader oReader = this.ExecuteReader(sqlCommandName); while (oReader.Read()) { sqlCommandName = string.Format(SqlQueries.GetQuery(Query.SelectOnlineOrderDetailsDetailsByIDFromOnlineOrderTable), Convert.ToInt64("0" + oReader["online_orderid"])); } oReader.Close(); oReader = this.ExecuteReader(sqlCommandName); if (oReader != null) { bool bIsRead = oReader.Read(); if (bIsRead) { sqlCommandName = string.Format(SqlQueries.GetQuery(Query.InsertOnlineOrderDetails), Convert.ToInt64("0" + oReader["order_id"]), Convert.ToInt64("0" + oReader["customer_id"]), Convert.ToString(oReader["user_id"]), Convert.ToString(oReader["order_type"]), Convert.ToInt64("0" + oReader["order_time"]), Convert.ToString(oReader["status"]), Convert.ToInt32("0" + oReader["guest_count"]), Convert.ToInt64("0" + oReader["table_number"]), Convert.ToString(oReader["table_name"]), Convert.ToInt32("0" + oReader["terminal_id"]), Convert.ToInt64("0" + oReader["online_orderid"]), Convert.ToString(oReader["webstatus"]), Convert.ToString(oReader["webstatusnote"]), Convert.ToInt32("0" + oReader["OnlineStatus"]), inOrderDetails.OrderQuantity, inOrderDetails.OrderAmount, "", Convert.ToString(inOrderDetails.OrderFoodType), Convert.ToString(oReader["pcat_name"]), Convert.ToString(oReader["cat1_name"]), Convert.ToString(oReader["cat2_name"]), inOrderDetails.ItemName); } } oReader.Close(); this.ExecuteNonQuery(sqlCommandName); sqlCommandName = SqlQueries.GetQuery(Query.GetOnlineItemOrderMaxNumber); oReader = this.ExecuteReader(sqlCommandName); while (oReader.Read()) { tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + oReader["item_order_number"].ToString()); } oReader.Close(); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in InsertOnlineOrderDetails()", LogLevel.Error, "Database"); throw new Exception("Exception occure at InsertOnlineOrderDetails()", ex); } finally { this.CloseConnection(); } return tempOrderDetails; }
private void g_RemoveButton_Click(object sender, EventArgs e) { try { if (m_iDataGridViewCurrentRowIndex == -1) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage."); tempMessageBox.ShowDialog(); return; } if (m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString().Equals("")) { return; } int totalQuantity = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString()); // int printedQuantity = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString()); int printedQuantity = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[8].Value.ToString()); //If printed items are equal to total quantity or greater if (totalQuantity <= printedQuantity) { CMessageBox tempMessageBox = new CMessageBox("Printed", "Current item(s) has already been sent to kitchen."); tempMessageBox.ShowDialog(); return; } COrderManager tempOrderManager1 = new COrderManager(); CResult oResult1 = tempOrderManager1.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString())); COrderDetails aDetails = new COrderDetails(); if (oResult1.IsSuccess && oResult1.Data != null) { aDetails = (COrderDetails)oResult1.Data; } if (aDetails.GuestPrintQuantity >= totalQuantity) { CMessageBox tempMessageBox = new CMessageBox("Printed", " All ready Guest Bill Printed so that impossible of item decrease"); tempMessageBox.ShowDialog(); return; } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".ToUpper().Replace(" ", "")) //If the order is not online order { COrderManager tempOrderManager = new COrderManager(); //int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString()); ////Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString()); ////For Vat and Unit vat //Double itemTotalVat = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString()); //Double unitVat = itemTotalVat / qty; //itemTotalVat = itemTotalVat - unitVat; //Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value.ToString()); //Double unitPrice = amount / qty; int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString()); //Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString()); //For Vat and Unit vat Double itemTotalVat = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString()); Double unitVat = itemTotalVat / qty; // itemTotalVat = itemTotalVat - unitVat; Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value.ToString()); Double unitPrice = amount / qty; if (qty == 1) { tempOrderManager.DeleteOrderDetails(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString())); m_dDataGridView.Rows.RemoveAt(m_iDataGridViewCurrentRowIndex); } else { qty = qty - 1; if (qty < 1) { qty = 0; } COrderDetails tempOrderDetails = new COrderDetails(); // CResult oResult = tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString())); CResult oResult = tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value.ToString())); if (oResult.IsSuccess && oResult.Data != null) { tempOrderDetails = (COrderDetails)oResult.Data; } //tempOrderDetails.OrderQuantity = qty; //tempOrderDetails.OrderAmount = qty * unitPrice; //tempOrderDetails.PrintedQuantity = tempOrderDetails.PrintedQuantity - 1; //Add by deb tempOrderDetails.OrderQuantity = qty; tempOrderDetails.OrderAmount = qty * unitPrice; tempOrderDetails.VatTotal = unitVat * qty; if (tempOrderDetails.PrintedQuantity <= 0) { tempOrderDetails.PrintedQuantity = 0; } //tempOrderDetails.OrderDetailsID = Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString()); tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; tempOrderManager.UpdateOrderDetails(tempOrderDetails); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = qty; //m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value = tempOrderDetails.PrintedQuantity; // m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(qty * unitPrice)).ToString("F02"); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[8].Value = tempOrderDetails.PrintedQuantity; m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value = ((double)(qty * unitPrice)).ToString("F02"); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(unitVat * qty)).ToString("F02"); } } else //Proceed for online order { if (this.TotalItems() < 2) { MessageBox.Show("You can not remove all the items from online", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } COrderManager tempOrderManager = new COrderManager(); int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString()); Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString()); Double unitPrice = amount / qty; if (qty == 1) { tempOrderManager.DeleteOnlineOrderDetails(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value.ToString())); //Taking the order sequence number.Here named category ranking m_dDataGridView.Rows.RemoveAt(m_iDataGridViewCurrentRowIndex); } else { qty = qty - 1; if (qty < 1) { qty = 0; } COrderDetails tempOrderDetails = new COrderDetails(); tempOrderDetails.OrderQuantity = qty; tempOrderDetails.OrderAmount = qty * unitPrice; tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value); tempOrderDetails.OrderDetailsID = Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString()); tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = qty; ///For printed items int printedItems = Convert.ToInt32(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value) - 1; if (printedItems < 1) { printedItems = 0; } m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value = printedItems; m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(qty * unitPrice)).ToString("F02"); } } m_dDataGridView.Update(); TotalAmountCalculation(); m_dDataGridView.ClearSelection(); } catch (Exception exp) { MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } this.SetPrintedItemBackColor(); //set the back color }
private void g_MiscButton_Click(object sender, EventArgs e) { try { CKeyBoardForm tempKeyBoardForm = new CKeyBoardForm("Misc Item", "Enter Item Name or Description", true); tempKeyBoardForm.ShowDialog(); if (CKeyBoardForm.Content.Equals("Cancel")) return; if (CKeyBoardForm.Content.Equals("")) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Item Name cannot be Empty"); tempMessageBox.ShowDialog(); return; } CPriceCalculatorForm tempCalculatorForm = new CPriceCalculatorForm("Misc Item", "Enter Price"); tempCalculatorForm.ShowDialog(); if (CPriceCalculatorForm.inputResult.Equals("Cancel")) return; if (CPriceCalculatorForm.inputResult.Equals("0.000")) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Price cannot be zero."); tempMessageBox.ShowDialog(); return; } double price = Double.Parse(CPriceCalculatorForm.inputResult); //change by mithu CPriceCalculatorForm tempCalculatorForm1 = new CPriceCalculatorForm("Misc Item", "Enter vat"); tempCalculatorForm1.ShowDialog(); if (CPriceCalculatorForm.inputResult.Equals("Cancel")) return; if (CPriceCalculatorForm.inputResult.Equals("0.000")) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Vat cannot be zero."); tempMessageBox.ShowDialog(); return; } double addmisvat=Double.Parse(CPriceCalculatorForm.inputResult); try { CCalculatorForm tempQtyCalculatorForm = new CCalculatorForm("Order Quantity", "Item Quantity"); tempQtyCalculatorForm.ShowDialog(); if (CCalculatorForm.inputResult.Equals("Cancel")) return; string str = CCalculatorForm.inputResult; str = (str == "") ? "1" : str; if (Int32.Parse(str) == 0) { CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); tempMessageBox.ShowDialog(); return; } int tempOrderedQty = Int32.Parse(str); m_iSavedOrderedQty = tempOrderedQty; } catch (Exception exp) { MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); DataGridView tempDataGridView = null; if (CKeyBoardForm.m_foodType == true) //If miscelleneous item is food { tempDataGridView = g_FoodDataGridView; } else { tempDataGridView = g_BeverageDataGridView; } int tempResult = FindExistingItem(tempDataGridView, CKeyBoardForm.Content); if (tempResult != -1) { //update Order_details table int tempRowIndex = tempResult; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = 0; tempOrderDetails.CategoryLevel = 0; tempOrderDetails.OrderRemarks = CKeyBoardForm.Content; tempOrderDetails.Product_Name = CKeyBoardForm.Content; tempOrderDetails.OrderQuantity = Int32.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()); tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity*price; tempOrderDetails.VatTotal = (addmisvat*tempOrderDetails.OrderAmount)/100.0; tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; tempOrderDetails.OrderFoodType = "Food"; tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempDataGridView.Rows[tempRowIndex].Cells[2].Value = tempOrderDetails.VatTotal.ToString("F02"); tempDataGridView.Rows[tempRowIndex].Cells[3].Value = tempOrderDetails.OrderAmount.ToString("F02"); tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = 0; tempOrderDetails.CategoryLevel = 0; tempOrderDetails.OrderRemarks = CKeyBoardForm.Content; tempOrderDetails.Product_Name = CKeyBoardForm.Content; tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity*price; tempOrderDetails.VatTotal = (addmisvat * tempOrderDetails.OrderAmount) / 100.0; tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; if (CKeyBoardForm.m_foodType == true) { tempOrderDetails.OrderFoodType = "Food"; } else { tempOrderDetails.OrderFoodType = "Nonfood"; } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data; string[] tempDataGridViewRow = new string[] { CKeyBoardForm.Content, m_iSavedOrderedQty.ToString(), tempOrderDetails.VatTotal.ToString("F02"), tempOrderDetails.OrderAmount.ToString("F02"), "0", "0", Int64.MaxValue-1+"", tempOrderDetails.OrderDetailsID.ToString(),"0" //0 for printed item quantity }; tempDataGridView.Rows.Add(tempDataGridViewRow); } else { tempOrderDetails.ItemName = CKeyBoardForm.Content; tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data; string[] tempDataGridViewRow = new string[] { CKeyBoardForm.Content, m_iSavedOrderedQty.ToString(), tempOrderDetails.VatTotal.ToString("F02"), tempOrderDetails.OrderAmount.ToString("F02"), "0", "0", tempOrderDetails.OnlineItemSequenceNumber.ToString(), tempOrderDetails.OrderDetailsID.ToString(),"0" //0 for printed item quantity }; tempDataGridView.Rows.Add(tempDataGridViewRow); } } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //Rank is applicable only for local order only { this.ConvertRank(); } tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); tempDataGridView.Update(); TotalAmountCalculation(); m_iSavedOrderedQty = 1; g_FoodDataGridView.ClearSelection(); g_BeverageDataGridView.ClearSelection(); } catch (Exception exp) { Console.Write(exp.Message); } }
private void functionalButton1_Click_2(object sender, EventArgs e) { CResult aCResult = new CResult(); CUserInfoDAO aUserInfoDao = new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo.UserID = RMSGlobal.m_iLoginUserID; aCResult = aUserInfoDao.GetUser(aUserInfo); aUserInfo = (CUserInfo)aCResult.Data; if (aUserInfo.Type != 0) { MessageBox.Show("You are not correct person to give Item Complementory Opportunity"); return; } CDiscountForm tempDiscountForm = new CDiscountForm(); tempDiscountForm.ShowDialog(); if (CDiscountForm.discountType.Equals("Cancel")) return; double discountAmount = Convert.ToDouble(CDiscountForm.discountAmount); string discountType = CDiscountForm.discountType; COrderDetailsDAO aOrderInfoDao = new COrderDetailsDAO(); foreach (DataGridViewRow row in g_FoodDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementoryfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["Order_details_id"].Value); aCOrderDetails = aOrderInfoDao.OrderDetailsGetByOrderDetailID(aCOrderDetails.OrderDetailsID); double totalAmount = aCOrderDetails.UnitPrice*aCOrderDetails.OrderQuantity; double discount=0; if (discountType == "Fixed") { discount = discountAmount; } else { discount = (totalAmount*discountAmount)/100.0; } aCOrderDetails.DiscountAmount = discount; string result = aOrderInfoDao.UpdateItemWiseDiscountForItem(aCOrderDetails); } } foreach (DataGridViewRow row in g_BeverageDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementorynonfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["dataGridViewTextBoxColumn5"].Value); aCOrderDetails = aOrderInfoDao.OrderDetailsGetByOrderDetailID(aCOrderDetails.OrderDetailsID); double totalAmount = aCOrderDetails.UnitPrice * aCOrderDetails.OrderQuantity; double discount = 0; if (discountType == "Fixed") { discount = discountAmount; } else { discount = (totalAmount * discountAmount) / 100.0; } aCOrderDetails.DiscountAmount = discount; string result = aOrderInfoDao.UpdateItemWiseDiscountForItem(aCOrderDetails); } } CResult oResult1 = aOrderInfoDao.OrderDetailsGetByOrderID(orderID); List<COrderDetails> aOrderDetailses = oResult1.Data as List<COrderDetails>; double totalItemDiscount = 0; if (aOrderDetailses != null) { totalItemDiscount = aOrderDetailses.Sum(a => a.DiscountAmount); } COrderManager tempOrderManager = new COrderManager(); COrderDiscount tempOrderDiscount = new COrderDiscount(); CResult oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID); if (oResult.IsSuccess && oResult.Data != null) { tempOrderDiscount = (COrderDiscount)oResult.Data; tempOrderDiscount.TotalItemDiscount = totalItemDiscount; tempOrderManager.UpdateOrderDiscount(tempOrderDiscount); } else { //insert tempOrderDiscount.OrderID = orderID; tempOrderDiscount.TotalItemDiscount = totalItemDiscount; tempOrderManager.InsertOrderDiscount(tempOrderDiscount); } LoadOrderDetails(); }
private void Category3Button_Click(object sender, EventArgs e) { try { CCategoryButton tempCategory3Button = (CCategoryButton)sender; int tempCategory3ID = tempCategory3Button.CategoryID; if (m_bItemDescriptionClicked) { string tempItemDescription = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0]["description"].ToString(); CMessageBox tempMessageBox = new CMessageBox("Item Description", tempItemDescription); tempMessageBox.ShowDialog(); m_bItemDescriptionClicked = false; return; } int tempFoodType = int.Parse(Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0].GetParentRow(Program.initDataSet.Relations["category2_to_category3"])["cat2_type"].ToString()); DataGridView tempDataGridView = new DataGridView(); tempDataGridView = g_FoodDataGridView; DataRow[] tempDataRowArray = Program.initDataSet.Tables["Category4"].Select("cat3_id = " + tempCategory3ID.ToString()); category4ButtonList.Clear(); if (tempDataRowArray.Length != 0) { foreach (DataRow tempDataRow in tempDataRowArray) { CCategoryButton tempCategoryButton = new CCategoryButton(); tempCategoryButton.CategoryID = int.Parse(tempDataRow["cat4_id"].ToString()); tempCategoryButton.CategoryOrder = int.Parse(tempDataRow["cat4_order"].ToString()); tempCategoryButton.CategoryLevel = 4; tempCategoryButton.Text = tempDataRow["cat4_name"].ToString(); tempCategoryButton.BackColor = tempCategory3Button.BackColor; category4ButtonList.Add(tempCategoryButton); } CCategory4Form tempCategory4Form = new CCategory4Form(tempCategory3ID, category4ButtonList, tempCategory3Button.Text); tempCategory4Form.ShowDialog(); CCategoryButton tempCategory4Button = CCategory4Form.m_cbResult; if (tempCategory4Button == null) return; else //insert into table and datagridview { NewOrder(); DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempCategory4Button.CategoryID.ToString()); if (temp2DataRowArray.Length != 0) { //category4 + categpry3 string ItemName = temp2DataRowArray[0]["cat4_name"].ToString() + " " + tempCategory3Button.Text; string tableTypePrice = string.Empty; tableTypePrice = temp2DataRowArray[0]["bar_price"].ToString(); int tempSearchResult = DataGridViewSearch(tempDataGridView, ItemName); COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); if (tempSearchResult != -1) { int tempRowIndex = tempSearchResult; int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); //update Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString()); tempOrderDetails.ProductID = tempCategory4Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel; tempOrderDetails.OrderQuantity = qty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory4Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel; tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); CResult oResult = tempOrderManager.InsertOrderDetails(tempOrderDetails); if (oResult.IsSuccess && oResult.Data != null) { tempOrderDetails = (COrderDetails)oResult.Data; } string[] tempDataGridViewRow = new string[] { ItemName, m_iSavedOrderedQty.ToString(), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory4Button.CategoryID.ToString(), "4", temp2DataRowArray[0]["cat4_rank"].ToString(), tempOrderDetails.OrderDetailsID.ToString() }; tempDataGridView.Rows.Add(tempDataGridViewRow); } ConvertRank(); tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); tempDataGridView.Update(); TotalAmountCalculation(); } } } else //There is no category4 { NewOrder(); DataGridViewRow tempDataGridViewRow = new DataGridViewRow(); tempDataGridViewRow.CreateCells(tempDataGridView); DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3Button.CategoryID.ToString()); if (temp2DataRowArray.Length != 0) { string tableTypePrice = string.Empty; tableTypePrice = temp2DataRowArray[0]["bar_price"].ToString(); COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); int tempResult = DataGridViewSearch(tempDataGridView, temp2DataRowArray[0]["cat3_name"].ToString()); if (tempResult != -1) { //update Order_details table int tempRowIndex = tempResult; int qty=int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString()); tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory3Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel; tempOrderDetails.OrderQuantity = qty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory3Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel; tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; CResult oResult = tempOrderManager.InsertOrderDetails(tempOrderDetails); if (oResult.IsSuccess && oResult.Data != null) { tempOrderDetails = (COrderDetails)oResult.Data; } string[] temp2DataGridViewRow = new string[] { temp2DataRowArray[0]["cat3_name"].ToString(), m_iSavedOrderedQty.ToString(), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory3Button.CategoryID.ToString(), "3", temp2DataRowArray[0]["cat3_rank"].ToString(), tempOrderDetails.OrderDetailsID.ToString() }; tempDataGridView.Rows.Add(temp2DataGridViewRow); } ConvertRank(); tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); tempDataGridView.Update(); TotalAmountCalculation(); } } m_iSavedOrderedQty = 1; g_FoodDataGridView.ClearSelection(); } catch (Exception exp) { throw exp; } }
private void btnReorder_Click(object sender, EventArgs e) { if (m_iDataGridViewCurrentRowIndex == -1) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage."); tempMessageBox.ShowDialog(); return; } if (m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value == null || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() == String.Empty) { return; } COrderDetails objOrderDetails = new COrderDetails(); Int64 itemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value); int quantity = Convert.ToInt32("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value); double amount = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value); amount = (amount / quantity) * (quantity + 1); //Calculate the total amount quantity++; //Increasing the quantity of items Int64 productID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value); objOrderDetails.ProductID = productID; objOrderDetails.OrderAmount = amount; objOrderDetails.OrderQuantity = quantity; objOrderDetails.OrderID = orderID; COrderManager objOrderManager = new COrderManager(); objOrderManager.AddNewLocalProducts(objOrderDetails); //Increasing Items's quantity for local orders m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = quantity; m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = amount.ToString("F02"); m_dDataGridView.Update(); TotalAmountCalculation(); m_dDataGridView.ClearSelection(); }
private void g_RemoveButton_Click(object sender, EventArgs e) { try { if (m_iDataGridViewCurrentRowIndex == -1) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage."); tempMessageBox.ShowDialog(); return; } COrderManager tempOrderManager = new COrderManager(); int qty = Int32.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString()); Double amount = Double.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString()); Double unitPrice = amount / qty; if (qty == 1) { tempOrderManager.DeleteOrderDetails(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString())); m_dDataGridView.Rows.RemoveAt(m_iDataGridViewCurrentRowIndex); } else { qty = qty - 1; COrderDetails tempOrderDetails = new COrderDetails(); CResult oResult = tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString())); if (oResult.IsSuccess && oResult.Data != null) { tempOrderDetails = (COrderDetails)oResult.Data; } tempOrderDetails.OrderQuantity = qty; tempOrderDetails.OrderAmount = qty * unitPrice; tempOrderManager.UpdateOrderDetails(tempOrderDetails); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = qty; m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = ((double)(qty * unitPrice)).ToString("F02"); } m_dDataGridView.Update(); TotalAmountCalculation(); m_dDataGridView.ClearSelection(); } catch (Exception eee) { } }
private void g_MiscButton_Click(object sender, EventArgs e) { try { CKeyBoardForm tempKeyBoardForm = new CKeyBoardForm("Misc Item", "Enter Item Name or Description"); tempKeyBoardForm.ShowDialog(); if (CKeyBoardForm.Content.Equals("Cancel")) return; if (CKeyBoardForm.Content.Equals("")) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Item Name cannot be Empty"); tempMessageBox.ShowDialog(); return; } CPriceCalculatorForm tempCalculatorForm = new CPriceCalculatorForm("Misc Item", "Enter Price"); tempCalculatorForm.ShowDialog(); if (CPriceCalculatorForm.inputResult.Equals("Cancel")) return; if (CPriceCalculatorForm.inputResult.Equals("0.000")) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Price cannot be zero."); tempMessageBox.ShowDialog(); return; } NewOrder(); COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); DataGridView tempDataGridView = g_FoodDataGridView; int tempResult = DataGridViewSearch(tempDataGridView, CKeyBoardForm.Content); if (tempResult != -1) { //update Order_details table int tempRowIndex = tempResult; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString()); tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = 0; tempOrderDetails.CategoryLevel = 0; tempOrderDetails.OrderRemarks = CKeyBoardForm.Content; tempOrderDetails.OrderQuantity = Int32.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()); tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(CPriceCalculatorForm.inputResult); tempOrderDetails.OrderFoodType = "Nonfood"; tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = 0; tempOrderDetails.CategoryLevel = 0; tempOrderDetails.OrderRemarks = CKeyBoardForm.Content; tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(CPriceCalculatorForm.inputResult); tempOrderDetails.OrderFoodType = "Nonfood"; tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data; string[] tempDataGridViewRow = new string[] { CKeyBoardForm.Content, m_iSavedOrderedQty.ToString(), CPriceCalculatorForm.inputResult, "0", "0", (Int64.MaxValue-1)+"", tempOrderDetails.OrderDetailsID.ToString() }; tempDataGridView.Rows.Add(tempDataGridViewRow); } ConvertRank(); tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); tempDataGridView.Update(); TotalAmountCalculation(); m_iSavedOrderedQty = 1; g_FoodDataGridView.ClearSelection(); } catch (Exception eee) { } }
private COrderDetails ReaderToOrderDetails(IDataReader inReader) { // COrderDetails tempOrderDetails = new COrderDetails(); COrderDetails tempOrderDetails = new COrderDetails(); if (inReader["order_detail_id"] != null) tempOrderDetails.OrderDetailsID = int.Parse(inReader["order_detail_id"].ToString()); if (inReader["order_id"] != null) tempOrderDetails.OrderID = int.Parse(inReader["order_id"].ToString()); if (inReader["product_id"] != null) tempOrderDetails.ProductID = Int32.Parse(inReader["product_id"].ToString()); if (inReader["quantity"] != null) tempOrderDetails.OrderQuantity = Int32.Parse(inReader["quantity"].ToString()); if (inReader["amount"] != null) tempOrderDetails.OrderAmount = Double.Parse(inReader["amount"].ToString()); if (inReader["remarks"] != null) tempOrderDetails.OrderRemarks = inReader["remarks"].ToString(); if (inReader["food_type"] != null) tempOrderDetails.OrderFoodType = inReader["food_type"].ToString(); if (inReader["cat_level"] != null) tempOrderDetails.CategoryLevel = Int32.Parse(inReader["cat_level"].ToString()); try { //if (inReader["print_send"] != null) tempOrderDetails.PrintedQuantity = Int32.Parse(inReader["print_send"].ToString()); } catch { } try { //if (inReader["itemUnitPrice"] != null) tempOrderDetails.UnitPrice = Convert.ToDouble(inReader["itemUnitPrice"].ToString()); } catch (Exception ex) { } try { //if (inReader["amount_with_vat"] != null) { tempOrderDetails.Amount_with_vat = Convert.ToDouble(inReader["amount_with_vat"]); } } catch { } try { //if (inReader["vatTotal"] != null) { tempOrderDetails.VatTotal = Convert.ToDouble(inReader["vatTotal"]); } } catch { } try { //if (inReader["guest_print_qnty"] != null) { tempOrderDetails.GuestPrintQuantity = Convert.ToInt32(inReader["guest_print_qnty"]); } } catch { } try { //if (inReader["kitchen_quantity"] != null) { tempOrderDetails.KitchenQuantity = Convert.ToInt32(inReader["kitchen_quantity"]); } } catch { } try { //if (inReader["kitchen_quantity"] != null) { tempOrderDetails.DiscountAmount = Convert.ToDouble(inReader["item_discount"]); } } catch { } // tempOrderDetails.OrderAmount = tempOrderDetails.OrderAmount - tempOrderDetails.DiscountAmount; return tempOrderDetails; }
private void g_SeatButton_Click(object sender, EventArgs e) { if (m_iDataGridViewCurrentRowIndex == -1) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage."); tempMessageBox.ShowDialog(); return; } if (m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value == null || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value == null || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value == "" || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString() == "" || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value.ToString().Length < 1 || m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value.ToString().Length < 1) { return; } try { if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //If local order is considered { COrderDetails objOrderDetails = new COrderDetails(); Int64 itemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value); int quantity = Convert.ToInt32("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value); double vat = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value); double amount = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value); // double vateRate = vat / quantity; double totalVat = (vateRate) * (quantity + 1); objOrderDetails.VatTotal = totalVat; amount = (amount / quantity) * (quantity + 1); //Calculate the total amount quantity++; //Increasing the quantity of items Int64 productID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[4].Value); objOrderDetails.ProductID = productID; objOrderDetails.OrderAmount = amount; objOrderDetails.OrderQuantity = quantity; objOrderDetails.OrderID = orderID; objOrderDetails.Amount_with_vat = objOrderDetails.OrderAmount + objOrderDetails.VatTotal; objOrderDetails.OrderDetailsID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[7].Value); COrderManager objOrderManager = new COrderManager(); objOrderManager.AddNewLocalProducts(objOrderDetails); //Increasing Items's quantity for local orders m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = quantity; m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = totalVat.ToString("F02"); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value = amount.ToString("F02"); } else { COrderDetails objOrderDetails = new COrderDetails(); Int64 itemSequenceNumber = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value); int quantity = Convert.ToInt32("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value); double vat = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value); double amount = Convert.ToDouble("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value); double vateRate = amount / quantity; double totalVat = (vateRate) * (quantity + 1); objOrderDetails.VatTotal = totalVat; amount = (amount / quantity) * (quantity + 1); //Calculate the total amount quantity++; //Increasing the quantity of items objOrderDetails.OnlineItemSequenceNumber = itemSequenceNumber; objOrderDetails.OrderAmount = amount; objOrderDetails.OrderQuantity = quantity; objOrderDetails.OrderDetailsID = Convert.ToInt64("0" + m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value); COrderManager objOrderManager = new COrderManager(); objOrderManager.AddNewOnlineProducts(objOrderDetails); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[1].Value = quantity; m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[2].Value = totalVat.ToString("F02"); m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[3].Value = amount.ToString("F02"); } m_dDataGridView.Update(); TotalAmountCalculation(); m_dDataGridView.ClearSelection(); } catch (Exception exp) { throw exp; } this.SetPrintedItemBackColor(); //set the back color }
private void g_SpecialButton_Click(object sender, EventArgs e) { try { if (m_iDataGridViewCurrentRowIndex == -1) { CMessageBox tempMessageBox = new CMessageBox("Error!", "Please select ordered food or beverage."); tempMessageBox.ShowDialog(); return; } CSpecialModifyForm tempKeyBoardForm = new CSpecialModifyForm(); tempKeyBoardForm.ShowDialog(); string sResult = CSpecialModifyForm.Content; if (sResult.Equals("") || sResult.Equals("Cancel")) { return; } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //For local order { COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = (COrderDetails)tempOrderManager.OrderDetailsByOrderDetailID(Int64.Parse(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[6].Value.ToString())).Data; if (tempOrderDetails.OrderRemarks.Equals("")) { m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() + " (" + sResult + ")"; } else if (tempOrderDetails.CategoryLevel == 0) { m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() + sResult; } else { m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString().Substring(0, m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells["Item"].Value.ToString().LastIndexOf('(')) + " (" + sResult + ")"; } tempOrderDetails.OrderRemarks = sResult; tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); if (sResult.Length > 0) { m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value = m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[0].Value.ToString() + " (" + sResult + ")"; } tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64(m_dDataGridView.Rows[m_iDataGridViewCurrentRowIndex].Cells[5].Value); tempOrderDetails.OrderRemarks = sResult; tempOrderManager.UpdateOnlineItemSpecial(tempOrderDetails); this.LoadOrderDetails(); } m_dDataGridView.Update(); m_iDataGridViewCurrentRowIndex = -1; m_dDataGridView.ClearSelection(); } catch (Exception exp) { MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Added by Baruri /// </summary> /// <param name="p_onlineOrderDetails"></param> void IOrderDetailsDAO.AddNewOnlineProducts(COrderDetails p_onlineOrderDetails) { try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.AddNewOnlineOrderedItem), p_onlineOrderDetails.OrderQuantity, p_onlineOrderDetails.OrderAmount, p_onlineOrderDetails.OnlineItemSequenceNumber); this.ExecuteNonQuery(sqlCommand); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in AddNewOnlineProducts()", LogLevel.Error, "Database"); throw new Exception("Exception occure at AddNewOnlineProducts()", ex); } finally { this.CloseConnection(); } }
private void itemComplementoryButton_Click(object sender, EventArgs e) { CResult aCResult = new CResult(); CUserInfoDAO aUserInfoDao = new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo.UserID = RMSGlobal.m_iLoginUserID; aCResult = aUserInfoDao.GetUser(aUserInfo); aUserInfo = (CUserInfo)aCResult.Data; if (aUserInfo.Type != 0) { MessageBox.Show("You are not correct person to give Item Complementory Opportunity"); return; } COrderInfoDAO aOrderInfoDao=new COrderInfoDAO(); foreach (DataGridViewRow row in g_FoodDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementoryfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["Order_details_id"].Value); string result = aOrderInfoDao.UpdateItemComplementory(aCOrderDetails.OrderDetailsID); } } foreach (DataGridViewRow row in g_BeverageDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementorynonfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["dataGridViewTextBoxColumn5"].Value); string result = aOrderInfoDao.UpdateItemComplementory(aCOrderDetails.OrderDetailsID); } } LoadOrderDetails(); }
public string UpdateItemWiseDiscountForItem(COrderDetails aCOrderDetailses) { string result = ""; try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateItemWiseDiscount), aCOrderDetailses.OrderDetailsID, aCOrderDetailses.DiscountAmount); this.ExecuteNonQuery(sqlCommand); result = "Result Added Successfully"; } catch (Exception ex) { result = "failed try Again"; Console.Write("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex + " in UpdateItemWiseDiscount()", LogLevel.Error, "Database"); throw new Exception("Exception occure at UpdateItemWiseDiscount()", ex); } finally { this.CloseConnection(); } return result; }
//private void btnPLU_Click(object sender, EventArgs e) //{ // int priceTakeType; // Int32 productPLU = 0; // int returnVal = 0; // Int32 productQuantity = 0; // COrderManager objOrderManager = new COrderManager(); // if (m_iType == m_cCommonConstants.TableType) // { // priceTakeType = 1; // } // else if (m_iType == m_cCommonConstants.TakeAwayType) // { // priceTakeType = 2; // } // else // { // priceTakeType = 3; // } // CCalculatorForm tableNumberForm = new CCalculatorForm("Product PLU Information", "PLU of the Product"); // tableNumberForm.ShowDialog(); // if (CCalculatorForm.inputResult.Equals("Cancel")) // return; // if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0) // { // CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); // tempMessageBox.ShowDialog(); // return; // } // productPLU = Convert.ToInt32("0" + CCalculatorForm.inputResult); // CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU); // if (Convert.ToString(objProductName.Data) == "NO") // { // CMessageBox tempMessageBox = new CMessageBox("Error", "Invalid PLU.Please enter valid PLU"); // tempMessageBox.ShowDialog(); // return; // } // ProductQuantityForm quantityForm = new ProductQuantityForm(Convert.ToString(objProductName.Data)); // quantityForm.ShowDialog(); // if (ProductQuantityForm.m_productQuantity.Equals("Cancel")) // { // return; // } // if (ProductQuantityForm.m_productQuantity.Equals("") || Int32.Parse(ProductQuantityForm.m_productQuantity) == 0) // { // CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); // tempMessageBox.ShowDialog(); // return; // } // productQuantity = Convert.ToInt32("0" + ProductQuantityForm.m_productQuantity); // CResult oResult = objOrderManager.GetPluDataByProductPLU(productPLU, priceTakeType, orderID, productQuantity); // if (oResult.IsSuccess && oResult.Data != null) // { // returnVal = int.Parse(oResult.Data.ToString()); // //for vat includr option // String queryStr = SqlQueries.GetQuery(Query.LastPLUOrderDetails); // CDalConfig oTempDal = ConfigManager.GetConfig<CDalConfig>(); // String tempConnStr = oTempDal.ConnectionString; // // Create a new data adapter based on the specified query. // SqlDataAdapter dataAdapter = new SqlDataAdapter(queryStr, tempConnStr); // // Populate a new data table and bind it to the BindingSource. // DataTable table = new DataTable(); // //table.Locale = System.Globalization.CultureInfo.InvariantCulture; // dataAdapter.Fill(table); // int CategoryID = Convert.ToInt32(table.Rows[0]["product_id"].ToString()); // Double amount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); // int catLavel=Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); // //vat in cat Three // double vatRate = 0; // bool vat_included = false; // double vatAmountRate = 0; // if(catLavel==3) // { // DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + CategoryID.ToString()); // vatRate = 0; // vat_included = false; // vatAmountRate = 0; // try // { // vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); // vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); // if (vat_included) // { // vatAmountRate = (amount * vatRate) / 100; // // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); // } // else // { // vatAmountRate = 0.00; // } // } // catch (Exception ex) { } // } // if(catLavel==4) // { // DataRow[] temp3DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + CategoryID); // vatRate = 0; // vat_included = false; // vatAmountRate = 0; // try // { // vatRate = Convert.ToDouble(temp3DataRowArray[0]["vat_Rate"].ToString()); // vat_included = Convert.ToBoolean(temp3DataRowArray[0]["vat_included"].ToString()); // if (vat_included) // { // vatAmountRate = (amount * vatRate) / 100; // // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); // } // else // { // vatAmountRate = 0.00; // } // } // catch (Exception ex) { } // } // //string tableTypePrice = string.Empty; // //if (m_iType == m_cCommonConstants.TableType) // //{ // // tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); // //} // //else if (m_iType == m_cCommonConstants.TakeAwayType) // //{ // // tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); // //} // COrderManager tempOrderManager = new COrderManager(); // COrderDetails tempOrderDetails = new COrderDetails(); // if (returnVal == 1) // { // //update Order_details table // //int tempRowIndex = tempResult; // //int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; // //tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; // //tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); // tempOrderDetails.OrderDetailsID = Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); // tempOrderDetails.OrderID =Convert.ToInt32(table.Rows[0]["order_id"].ToString()); // tempOrderDetails.ProductID =Convert.ToInt32( table.Rows[0]["product_id"].ToString()); // tempOrderDetails.CategoryLevel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); // tempOrderDetails.UnitPrice = 0.00; // tempOrderDetails.OrderQuantity = Convert.ToInt32(table.Rows[0]["quantity"].ToString()); // tempOrderDetails.OrderAmount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); // tempOrderDetails.OrderFoodType = table.Rows[0]["food_type"].ToString(); // // tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[5].Value.ToString()); // // tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); // if (vat_included) // { // tempOrderDetails.VatTotal = vatAmountRate; // } // else // { // tempOrderDetails.VatTotal = 0.00; // } // //if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) // //{ // // tempOrderManager.UpdateOrderDetails(tempOrderDetails); // //} // //else // //{ // // tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails); // //} // try // { // tempOrderManager.UpdateOrderDetails(tempOrderDetails); // } // catch { } // } // //tempOrderDetails.VatTotal = vatAmountRate; // //tempOrderDetails.OrderDetailsID =Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); // //try // //{ // //tempOrderManager.UpdateOrderDetails(tempOrderDetails); // //} // //catch { } // } // if (returnVal == 0) // { // MessageBox.Show("Please enter valid plu product", RMSGlobal.MessageBoxTitle, // MessageBoxButtons.OK, MessageBoxIcon.Information); // } // else // { // COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO(); // orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType); // } // this.LoadOrderDetails(); // btnPLU_Click(sender, e); //} private void btnPLU_Click(object sender, EventArgs e) { int priceTakeType; Int32 productPLU = 0; int returnVal = 0; Int32 productQuantity = 0; COrderManager objOrderManager = new COrderManager(); if (m_iType == m_cCommonConstants.TableType) { priceTakeType = 1; } else if (m_iType == m_cCommonConstants.TakeAwayType) { priceTakeType = 2; } else { priceTakeType = 3; } CCalculatorForm tableNumberForm = new CCalculatorForm("Product PLU Information", "PLU of the Product"); tableNumberForm.ShowDialog(); if (CCalculatorForm.inputResult.Equals("Cancel")) return; if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0) { CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); tempMessageBox.ShowDialog(); return; } productPLU = Convert.ToInt32("0" + CCalculatorForm.inputResult); // Add for find updating order_detail int id = productPLU; long order = orderID; COrderDetailsDAO aDao = new COrderDetailsDAO(); List<COrderDetails> aList = aDao.OrderDetailsGetAll(); // CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU, priceTakeType); CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU); var check = (from orderdetail in aList where (orderdetail.OrderID == orderID && orderdetail.ProductID == objProductName.Productid) select orderdetail); if (Convert.ToString(objProductName.Data) == "NO") { CMessageBox tempMessageBox = new CMessageBox("Error", "Invalid PLU.Please enter valid PLU"); tempMessageBox.ShowDialog(); return; } ProductQuantityForm quantityForm = new ProductQuantityForm(Convert.ToString(objProductName.Data)); quantityForm.ShowDialog(); if (ProductQuantityForm.m_productQuantity.Equals("Cancel")) { return; } if (ProductQuantityForm.m_productQuantity.Equals("") || Int32.Parse(ProductQuantityForm.m_productQuantity) == 0) { CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); tempMessageBox.ShowDialog(); return; } productQuantity = Convert.ToInt32("0" + ProductQuantityForm.m_productQuantity); // Add for updating order_detail when orderwith same product if (check.Count() == 1) { COrderDetails aOrderDetails = new COrderDetails(); aOrderDetails = check.Single(); //double vat = aOrderDetails.Amount_with_vat - aOrderDetails.OrderAmount; //vat = (vat * 100) / aOrderDetails.OrderAmount; productQuantity += aOrderDetails.OrderQuantity; aOrderDetails.OrderQuantity = productQuantity; aOrderDetails.OrderAmount = aOrderDetails.UnitPrice * productQuantity; aOrderDetails.PrintedQuantity = aOrderDetails.PrintedQuantity; aOrderDetails.VatTotal = (objProductName.VateRate * aOrderDetails.OrderAmount) / 100.0; aOrderDetails.Amount_with_vat = aOrderDetails.OrderAmount + aOrderDetails.VatTotal; COrderDetailsDAO aCOrderDetailsDao = new COrderDetailsDAO(); aCOrderDetailsDao.OrderDetailsUpdate(aOrderDetails); //COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO(); //orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType); } if (check.Count() == 0) { CResult oResult = objOrderManager.GetPluDataByProductPLU(productPLU, priceTakeType, orderID, productQuantity); if (oResult.IsSuccess && oResult.Data != null) { returnVal = int.Parse(oResult.Data.ToString()); //for vat includr option String queryStr = SqlQueries.GetQuery(Query.LastPLUOrderDetails); CDalConfig oTempDal = ConfigManager.GetConfig<CDalConfig>(); String tempConnStr = oTempDal.ConnectionString; // Create a new data adapter based on the specified query. SqlDataAdapter dataAdapter = new SqlDataAdapter(queryStr, tempConnStr); // Populate a new data table and bind it to the BindingSource. DataTable table = new DataTable(); //table.Locale = System.Globalization.CultureInfo.InvariantCulture; dataAdapter.Fill(table); int CategoryID = Convert.ToInt32(table.Rows[0]["product_id"].ToString()); Double amount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); int catLavel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); //vat in cat Three double vatRate = 0; bool vat_included = false; double vatAmountRate = 0; if (catLavel == 3) { DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + CategoryID.ToString()); vatRate = 0; vat_included = false; vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (amount * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } } if (catLavel == 4) { DataRow[] temp3DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + CategoryID); vatRate = 0; vat_included = false; vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp3DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp3DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (amount * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } } //string tableTypePrice = string.Empty; //if (m_iType == m_cCommonConstants.TableType) //{ // tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); //} //else if (m_iType == m_cCommonConstants.TakeAwayType) //{ // tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); //} COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); if (returnVal == 1) { //update Order_details table //int tempRowIndex = tempResult; //int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; //tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; //tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); tempOrderDetails.OrderDetailsID = Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); tempOrderDetails.OrderID = Convert.ToInt32(table.Rows[0]["order_id"].ToString()); tempOrderDetails.ProductID = Convert.ToInt32(table.Rows[0]["product_id"].ToString()); tempOrderDetails.CategoryLevel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); tempOrderDetails.UnitPrice = 0.00; tempOrderDetails.OrderQuantity = Convert.ToInt32(table.Rows[0]["quantity"].ToString()); tempOrderDetails.OrderAmount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); tempOrderDetails.OrderFoodType = table.Rows[0]["food_type"].ToString(); // tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[5].Value.ToString()); // tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); if (vat_included) { tempOrderDetails.VatTotal = vatAmountRate; } else { tempOrderDetails.VatTotal = 0.00; } //if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //{ // tempOrderManager.UpdateOrderDetails(tempOrderDetails); //} //else //{ // tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails); //} try { tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; tempOrderManager.UpdateOrderDetails(tempOrderDetails); } catch { } } //tempOrderDetails.VatTotal = vatAmountRate; //tempOrderDetails.OrderDetailsID =Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); //try //{ //tempOrderManager.UpdateOrderDetails(tempOrderDetails); //} //catch { } } if (returnVal == 0) { MessageBox.Show("Please enter valid plu product", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO(); orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType); } } this.LoadOrderDetails(); btnPLU_Click(sender, e); }
/// <summary> /// Special modification for online items /// </summary> /// <param name="inOrderDetails"></param> public void UpdateOnlineItemSpecial(COrderDetails inOrderDetails) { try { this.OpenConnection(); string sqlCommandName = String.Empty; sqlCommandName = string.Format(SqlQueries.GetQuery(Query.UpdateOnlineItemSpecial), inOrderDetails.OrderRemarks, inOrderDetails.OnlineItemSequenceNumber); this.ExecuteNonQuery(sqlCommandName); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in UpdateOnlineItemSpecial()", LogLevel.Error, "Database"); throw new Exception("Exception occure at UpdateOnlineItemSpecial()", ex); } finally { this.CloseConnection(); } }
private void Category3Button_Click(object sender, EventArgs e) { //get item qty CCategoryButton tempCategory3Button = (CCategoryButton)sender; RMSGlobal.m_sellinginvalue = tempCategory3Button.SellingQuantityorWeight; //Used to identify the product whether sold in quantity or weight int tempCategory3ID = tempCategory3Button.CategoryID; if (m_bItemDescriptionClicked) { string tempItemDescription = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0]["description"].ToString(); if (!tempItemDescription.Equals("")) { CMessageBox tempMessageBox = new CMessageBox("Item Description", tempItemDescription); tempMessageBox.ShowDialog(); } else { CMessageBox tempMessageBox = new CMessageBox("Item Description", "No information available."); tempMessageBox.ShowDialog(); } m_bItemDescriptionClicked = false; return; } int tempFoodType = int.Parse(Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0].GetParentRow(Program.initDataSet.Relations["category2_to_category3"])["cat2_type"].ToString()); DataGridView tempDataGridView = new DataGridView(); if (tempFoodType == 0) { tempDataGridView = g_BeverageDataGridView; } else { tempDataGridView = g_FoodDataGridView; } DataRow[] tempDataRowArray = Program.initDataSet.Tables["Category4"].Select("cat3_id = " + tempCategory3ID.ToString()); category4ButtonList.Clear(); COrderInfoDAO aOrderInfoDao = new COrderInfoDAO(); COrderInfo aCOrderInfo = aOrderInfoDao.GetOrderInfoByOrderID(orderID); if (tempDataRowArray.Length != 0) { foreach (DataRow tempDataRow in tempDataRowArray) { if (Int32.Parse(tempDataRow["status"].ToString()) == 0) { continue; } CCategoryButton tempCategoryButton = new CCategoryButton(); tempCategoryButton.CategoryID = int.Parse(tempDataRow["cat4_id"].ToString()); tempCategoryButton.CategoryOrder = int.Parse(tempDataRow["cat4_order"].ToString()); tempCategoryButton.CategoryLevel = 4; tempCategoryButton.Text = tempDataRow["cat4_name"].ToString(); tempCategoryButton.BackColor = tempCategory3Button.BackColor; category4ButtonList.Add(tempCategoryButton); } keyboardForm.Hide(); CCategory4Form tempCategory4Form = new CCategory4Form(tempCategory3ID, category4ButtonList, tempCategory3Button.Text); tempCategory4Form.ShowDialog(); CCategoryButton tempCategory4Button = CCategory4Form.m_cbResult; m_iSavedOrderedQty = CCategory4Form.ItemQTY; if (tempCategory4Button == null) { return; } else //insert into table and datagridview { DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempCategory4Button.CategoryID.ToString()); if (temp2DataRowArray.Length != 0) { //category4 + categpry3 string ItemName = temp2DataRowArray[0]["cat4_name"].ToString() + " " + tempCategory3Button.Text; string tableTypePrice = string.Empty; if (m_iType == m_cCommonConstants.TableType) { tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); } else if (m_iType == m_cCommonConstants.TakeAwayType) { tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); } int tempSearchResult = FindExistingItem(tempDataGridView, ItemName); // vat_included double vatRate = 0; bool vat_included = false; double vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (Double.Parse(tableTypePrice) * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); if (tempSearchResult != -1) { int tempRowIndex = tempSearchResult; int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; tempDataGridView.Rows[tempRowIndex].Cells[3].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); //update Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); tempOrderDetails.ProductID = tempCategory4Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel; tempOrderDetails.OrderQuantity = qty; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.OnlineItemSequenceNumber = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString()); tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[8].Value.ToString()); if (aCOrderInfo.VatComplementory) vatRate =vatAmountRate= 0; if (vat_included) { // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate; tempOrderDetails.VatTotal = qty * vatAmountRate; tempDataGridView.Rows[tempRowIndex].Cells[2].Value = qty * vatAmountRate; } else { tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails);//for online orders } } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory4Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel; tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); // tempOrderDetails.Product_Name = temp2DataRowArray[0]["cat3_name"].ToString(); if (aCOrderInfo.VatComplementory) vatRate = 0; if (vat_included) { tempOrderDetails.VatTotal = 0; tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate; } else { tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); } tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; string category1ID = this.GetCategory1ID(tempOrderDetails.ProductID, tempOrderDetails.CategoryLevel); //Int32 cat1Order = this.GetCategory1OrderNumber(Convert.ToInt32(category1ID)); // Change by Mithu if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data; string[] tempDataGridViewRow = new string[] { ItemName, m_iSavedOrderedQty.ToString(), ((double)tempOrderDetails.VatTotal).ToString("F02"), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory4Button.CategoryID.ToString(), "4", temp2DataRowArray[0]["cat4_rank"].ToString(), tempOrderDetails.OrderDetailsID.ToString(), "0", tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(tempDataGridViewRow); } else //For online orders { tempOrderDetails.ItemName = ItemName; tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data; string[] tempDataGridViewRow = new string[] { ItemName, m_iSavedOrderedQty.ToString(), ((double)tempOrderDetails.VatTotal).ToString("F02"), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory4Button.CategoryID.ToString(), "4", tempOrderDetails.OnlineItemSequenceNumber.ToString(), tempOrderDetails.OrderDetailsID.ToString(),"0", tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(tempDataGridViewRow); } } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //If local orders are considered { this.ConvertRank(); } tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); tempDataGridView.Update(); TotalAmountCalculation(); } } } else //There is no category4 { keyboardForm.Hide(); try { CCalculatorForm tempCalculatorForm = new CCalculatorForm("Order Quantity", "Item Quantity"); tempCalculatorForm.ShowDialog(); if (CCalculatorForm.inputResult.Equals("Cancel")) return; string str = CCalculatorForm.inputResult; str = (str == "") ? "1" : str; if (Int32.Parse(str) == 0) { CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); tempMessageBox.ShowDialog(); return; } int tempOrderedQty = Int32.Parse(str); m_iSavedOrderedQty = tempOrderedQty; } catch (Exception exp) { MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } DataGridViewRow tempDataGridViewRow = new DataGridViewRow(); tempDataGridViewRow.CreateCells(tempDataGridView); DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3Button.CategoryID.ToString()); if (temp2DataRowArray.Length != 0) { string tableTypePrice = string.Empty; if (m_iType == m_cCommonConstants.TableType) { tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); } else if (m_iType == m_cCommonConstants.TakeAwayType) { tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); } // vat_included double vatRate = 0; bool vat_included = false; double vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (Double.Parse(tableTypePrice) * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); int tempResult = FindExistingItem(tempDataGridView, temp2DataRowArray[0]["cat3_name"].ToString()); if (tempResult != -1) { //update Order_details table int tempRowIndex = tempResult; int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; tempDataGridView.Rows[tempRowIndex].Cells[3].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory3Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); tempOrderDetails.OrderQuantity = qty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString()); tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[8].Value.ToString()); if (aCOrderInfo.VatComplementory) vatAmountRate = 0; if (vat_included) { tempOrderDetails.VatTotal = qty * vatAmountRate; tempDataGridView.Rows[tempRowIndex].Cells[2].Value = tempOrderDetails.VatTotal; } else { tempOrderDetails.VatTotal = 0.00; } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails); } } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory3Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempOrderDetails.Product_Name = temp2DataRowArray[0]["cat3_name"].ToString(); tempOrderDetails.UOM = temp2DataRowArray[0]["uom"].ToString(); tempOrderDetails.Product_Type = temp2DataRowArray[0]["productType"].ToString(); if (aCOrderInfo.VatComplementory) vatRate = vatAmountRate = 0; try { if (vat_included) { tempOrderDetails.VatTotal = 0; tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate; } else { tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); } } catch { } try { tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; } catch { } string category1ID = this.GetCategory1ID(tempOrderDetails.ProductID, tempOrderDetails.CategoryLevel); Int32 cat1Order = this.GetCategory1OrderNumber(Convert.ToInt32(category1ID)); if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data; string[] temp2DataGridViewRow = new string[] { temp2DataRowArray[0]["cat3_name"].ToString(), m_iSavedOrderedQty.ToString(), tempOrderDetails.VatTotal.ToString("F2"), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory3Button.CategoryID.ToString(), "3", temp2DataRowArray[0]["cat3_rank"].ToString(), tempOrderDetails.OrderDetailsID.ToString(),"0", tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(temp2DataGridViewRow); } else { tempOrderDetails.ItemName = temp2DataRowArray[0]["cat3_name"].ToString(); tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data; string[] temp2DataGridViewRow = new string[] {temp2DataRowArray[0]["cat3_name"].ToString(), m_iSavedOrderedQty.ToString(), tempOrderDetails.VatTotal.ToString(), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory3Button.CategoryID.ToString(), "3", tempOrderDetails.OnlineItemSequenceNumber.ToString(),//For online order sequence number is category rank. tempOrderDetails.OrderDetailsID.ToString(),"0", //0 For first time. tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(temp2DataGridViewRow); } } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { this.ConvertRank(); } tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); try { tempDataGridView.Update(); } catch { } TotalAmountCalculation(); } } g_FoodDataGridView.ClearSelection(); g_BeverageDataGridView.ClearSelection(); m_iSavedOrderedQty = 1; keyboardForm.Hide(); this.SetPrintedItemBackColor(); }
public COrderDetails OrderDetailsGetByOrderDetailID(Int64 inOrderDetailID) { COrderDetails tempOrderDetails = new COrderDetails(); try { this.OpenConnection(); string sSql = String.Format(SqlQueries.GetQuery(Query.OrderDetailsGetByOrderDetailID), inOrderDetailID.ToString()); IDataReader oReader = this.ExecuteReader(sSql); if (oReader != null) { while (oReader.Read()) { tempOrderDetails = ReaderToOrderDetails(oReader); } } } catch (Exception ex) { Console.Write("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex + " in OrderDetailsGetByOrderDetailID()", LogLevel.Error, "Database"); if (ex.GetType().Equals(typeof(SqlException))) { SqlException oSQLEx = ex as SqlException; if (oSQLEx.Number != 7619) throw new Exception("Exception occured at OrderDetailsGetByOrderDetailID()", ex); } else { throw new Exception("Exception occure at OrderDetailsGetByOrderDetailID()", ex); } } finally { this.CloseConnection(); } return tempOrderDetails; }
private void dgvCurrentOrders_SelectionChanged(object sender, EventArgs e) { m_orderID = Convert.ToInt64("0" + dgvCurrentOrders.CurrentRow.Cells[0].Value); m_onlineOrderID = Convert.ToInt64("0" + dgvCurrentOrders.CurrentRow.Cells[2].Value); lsvCurrent.Items.Clear(); lsvRemovable.Items.Clear(); if (m_onlineOrderID < 1) { COrderManager tempOrderManager = new COrderManager(); List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>(); CResult oResult = tempOrderManager.OrderDetailsByOrderID(m_orderID); if (oResult.IsSuccess && oResult.Data != null) tempOrderDetailsList = (List<COrderDetails>)oResult.Data; m_slOrderedItems = new SortedList(); for (int itemIndex = 0; itemIndex < tempOrderDetailsList.Count; itemIndex++) { Int64 tempProductID = tempOrderDetailsList[itemIndex].ProductID; int tempCategoryLevel = tempOrderDetailsList[itemIndex].CategoryLevel; string tempProductName = ""; if (tempCategoryLevel == 3) { DataRow[] tempDataRowArr = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempProductID); if (tempDataRowArr.Length > 0) //Added by Baruri .This was a bug previously when no row found. { tempProductName = tempDataRowArr[0]["cat3_name"].ToString(); } } else if (tempCategoryLevel == 4) { DataRow[] tempDataRowArr = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempProductID); int tempCat3_id = 0; if (tempDataRowArr.Length > 0) { tempCat3_id = Convert.ToInt32("0" + tempDataRowArr[0]["cat3_id"]); } tempProductName = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempProductID)[0]["cat4_name"].ToString(); tempDataRowArr = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCat3_id); if (tempDataRowArr.Length > 0)//If rows found { tempProductName += " " + tempDataRowArr[0]["cat3_name"].ToString(); } } else if (tempCategoryLevel == 0) { tempProductName = tempOrderDetailsList[itemIndex].OrderRemarks; } //if remarks exists append it... otherwise append nothing... string appendString = ""; if (tempCategoryLevel != 0) { appendString = (tempOrderDetailsList[itemIndex].OrderRemarks.Equals("")) ? ("") : (" (" + tempOrderDetailsList[itemIndex].OrderRemarks + ")"); } if (tempOrderDetailsList[itemIndex].PrintedQuantity > 0) { ListViewItem lsvItem = new ListViewItem(tempProductName + appendString); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].PrintedQuantity.ToString()); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].OrderAmount.ToString("F02")); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].ProductID.ToString()); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].OrderDetailsID.ToString()); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].OrderFoodType.ToString()); lsvCurrent.Items.Add(lsvItem); //For taking the track of the ordered items. COrderDetails objOrderedItems=new COrderDetails(); objOrderedItems.OrderDetailsID=tempOrderDetailsList[itemIndex].OrderDetailsID; objOrderedItems.OrderID=m_orderID; objOrderedItems.ProductID=tempOrderDetailsList[itemIndex].ProductID; objOrderedItems.OrderQuantity=tempOrderDetailsList[itemIndex].OrderQuantity; objOrderedItems.PrintedQuantity=tempOrderDetailsList[itemIndex].PrintedQuantity; objOrderedItems.OrderAmount = tempOrderDetailsList[itemIndex].OrderAmount; m_slOrderedItems.Add(objOrderedItems.OrderDetailsID, objOrderedItems); } } } else { //Loading the online orders information m_slOrderedItems = new SortedList(); COrderManager tempOrderManager = new COrderManager(); string remarks = ""; string itemName = ""; List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>(); CResult oResult = tempOrderManager.GetOnlineOrderDetailsByOrderID(m_orderID); if (oResult.IsSuccess && oResult.Data != null) tempOrderDetailsList = (List<COrderDetails>)oResult.Data; for (int itemIndex = 0; itemIndex < tempOrderDetailsList.Count; itemIndex++) { remarks = tempOrderDetailsList[itemIndex].OrderRemarks.ToString(); itemName = tempOrderDetailsList[itemIndex].ItemName.ToString(); if (remarks.Length > 0) { itemName = itemName + "(" + remarks + ")"; } if (tempOrderDetailsList[itemIndex].PrintedQuantity > 0) { ListViewItem lsvItem = new ListViewItem(itemName); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].PrintedQuantity.ToString()); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].OrderAmount.ToString("F02")); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].ProductID.ToString()); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].OnlineItemSequenceNumber.ToString()); lsvItem.SubItems.Add(tempOrderDetailsList[itemIndex].OrderFoodType.ToString()); lsvCurrent.Items.Add(lsvItem); //For taking the track of the ordered items. COrderDetails objOrderedItems = new COrderDetails(); objOrderedItems.OrderDetailsID = tempOrderDetailsList[itemIndex].OnlineItemSequenceNumber; //Here details id contains online ordered item sequence number objOrderedItems.OrderID = m_orderID; objOrderedItems.ProductID = tempOrderDetailsList[itemIndex].ProductID; objOrderedItems.OrderQuantity = tempOrderDetailsList[itemIndex].OrderQuantity; objOrderedItems.PrintedQuantity = tempOrderDetailsList[itemIndex].PrintedQuantity; objOrderedItems.OrderAmount = tempOrderDetailsList[itemIndex].OrderAmount; m_slOrderedItems.Add(objOrderedItems.OrderDetailsID, objOrderedItems); } } } }
public void OrderDetailsUpdate(COrderDetails inOrderDetails) { inOrderDetails.OrderRemarks = inOrderDetails.OrderRemarks.Replace("''", "'"); inOrderDetails.OrderRemarks = inOrderDetails.OrderRemarks.Replace("'", "''"); try { this.OpenConnection(); string sSql = string.Format(SqlQueries.GetQuery(Query.OrderDetailsUpdate), inOrderDetails.OrderID, inOrderDetails.ProductID, inOrderDetails.OrderQuantity, inOrderDetails.OrderAmount, inOrderDetails.OrderRemarks, inOrderDetails.OrderFoodType, inOrderDetails.CategoryLevel, inOrderDetails.OrderDetailsID); this.ExecuteNonQuery(sSql); } catch (Exception ex) { Console.Write("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex + " in OrderDetailsUpdate()", LogLevel.Error, "Database"); throw new Exception("Exception occure at OrderDetailsUpdate()", ex); } finally { this.CloseConnection(); } }
/// <summary> /// Added by Baruri /// </summary> /// <param name="inReader"></param> /// <returns></returns> private COrderDetails ReaderToOnlineOrderDetails(IDataReader inReader) { COrderDetails tempOrderDetails = new COrderDetails(); if (inReader["order_details_id"] != null) tempOrderDetails.OrderDetailsID = int.Parse(inReader["order_details_id"].ToString()); if (inReader["order_id"] != null) tempOrderDetails.OrderID = int.Parse(inReader["order_id"].ToString()); if (inReader["item_name"] != null) tempOrderDetails.ItemName = Convert.ToString(inReader["item_name"].ToString()); if (inReader["quantity"] != null) tempOrderDetails.OrderQuantity = Int32.Parse(inReader["quantity"].ToString()); if (inReader["amount"] != null) tempOrderDetails.OrderAmount = Double.Parse(inReader["amount"].ToString()); if (inReader["cat_rank"] != null) tempOrderDetails.Rank = Convert.ToInt64(inReader["cat_rank"].ToString()); if (inReader["cat_id"] != null) tempOrderDetails.CategoryID= Convert.ToInt64(inReader["cat_id"].ToString()); if (inReader["cat_level"] != null) tempOrderDetails.CategoryLevel = Int32.Parse(inReader["cat_level"].ToString()); if (inReader["printed_quantity"] != null) tempOrderDetails.PrintedQuantity = Int32.Parse(inReader["printed_quantity"].ToString()); if (inReader["food_type"] != null) tempOrderDetails.OrderFoodType = Convert.ToString(inReader["food_type"]); if (inReader["remarks"] != null) tempOrderDetails.OrderRemarks = Convert.ToString(inReader["remarks"]); if (inReader["item_order_number"] != null) tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0"+inReader["item_order_number"]); try { if (inReader["amount_with_vat"] != null) { tempOrderDetails.Amount_with_vat = Convert.ToDouble(inReader["amount_with_vat"]); } } catch { } try { if (inReader["vatTotal"] != null) { tempOrderDetails.VatTotal = Convert.ToDouble(inReader["vatTotal"]); } } catch { } try { if (inReader["guest_print_qnty"] != null) { tempOrderDetails.GuestPrintQuantity = Convert.ToInt32(inReader["guest_print_qnty"]); } } catch { } return tempOrderDetails; }
public CResult UpdateOrderDetails(COrderDetails inOrderDetails) { try { COrderDetails tempOrderDetails = new COrderDetails(); tempOrderDetails = inOrderDetails; Database.Instance.OrderDetails.OrderDetailsUpdate(inOrderDetails); m_oResult.IsSuccess = true; m_oResult.Message = "Data Updated Successfully"; } catch (Exception ex) { System.Console.WriteLine("Exception occuer at UpdateOrderDetails() : " + 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 UpdateOrderDetails()", LogLevel.Error, "COrderManager"); } return m_oResult; }
/// <summary> /// This function removes the item from the selected order taken from online /// </summary> /// <param name="inOrderDetailsID"></param> /// <returns></returns> public CResult DeleteOnlineOrderDetails(Int64 p_itemsOrderNumber) { try { COrderDetails tempOrderDetails = new COrderDetails(); Database.Instance.OrderDetails.DeleteOnlineOrderDetails(p_itemsOrderNumber); m_oResult.IsSuccess = true; m_oResult.Message = "Data Deleted Successfully"; } catch (Exception ex) { System.Console.WriteLine("Exception occuer at DeleteOrderDetails() : " + ex.Message); m_oResult.IsException = true; m_oResult.Action = EERRORNAME.EXCEPTION_OCCURE; m_oResult.Message = ex.Message; Logger.Write("Exception : " + ex + " in DeleteOrderDetails()", LogLevel.Error, "COrderDetailsManager"); } return m_oResult; }