private void FinishButton_Click(object sender, EventArgs e) { CResult objResultant = new CResult(); try { if (!CheckEmpty() && m_orderIndex == 1) { CMessageBox tempMessageBox = new CMessageBox("Error", "Please enter all the mandatory values."); tempMessageBox.ShowDialog(); return; } CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = new CCustomerInfo(); if (txtPhoneNumber.Text.Trim().Equals(String.Empty)) { CResult oResult5 = tempCustomerManager.CustomerInfoGetByName(txtCustomerName.Text.Trim()); if (oResult5.IsSuccess && oResult5.Data != null) { tempCustomerInfo = (CCustomerInfo)oResult5.Data; } } else { CResult oResult = tempCustomerManager.CustomerInfoGetByPhone(txtPhoneNumber.Text.Trim()); if (oResult.IsSuccess && oResult.Data != null) { tempCustomerInfo = (CCustomerInfo)oResult.Data; } } if (txtCustomerName.Text.Length == 0 && (m_orderIndex == 2 || m_orderIndex == 3)) { txtCustomerName.Text = m_order_name; } tempCustomerInfo.CustomerName = txtCustomerName.Text.Trim(); tempCustomerInfo.CustomerPhone = txtPhoneNumber.Text.Trim(); if (m_orderIndex == 1) //If only delivery type order is considered { tempCustomerInfo.CustomerPostalCode = txtPostalCode.Text.Trim(); tempCustomerInfo.FloorAptNumber = txtFloorAptNumber.Text.Trim(); tempCustomerInfo.HouseNumber = txtHouseNumber.Text.Trim(); tempCustomerInfo.StreetName = txtStreetName.Text.Trim() + "-" + txtStreet2.Text.Trim(); tempCustomerInfo.BuildingName = txtBuildingName.Text.Trim(); tempCustomerInfo.CustomerTown = txtTown.Text.Trim(); tempCustomerInfo.CustomerCountry = cmbCountry.Text; tempCustomerInfo.UserName = RMSGlobal.LoginUserName; tempCustomerInfo.TerminalId = RMSGlobal.Terminal_Id; Int64 currentdateTime = DateTime.Now.Ticks; tempCustomerInfo.InsertDate = currentdateTime; } if (tempCustomerInfo.CustomerID == 0) { CResult oResult6 = tempCustomerManager.InsertCustomerInfo(tempCustomerInfo); if (oResult6.IsSuccess && oResult6.Data != null) tempCustomerInfo = (CCustomerInfo)oResult6.Data; } else { tempCustomerManager.UpdateCustomerInfo(tempCustomerInfo); } #region "Older" if (m_customerEditStatus == false) { if (m_iOrderID == 0) { COrderManager tempOrderManager = new COrderManager(); COrderInfo tempOrderInfo = new COrderInfo(); tempOrderInfo.CustomerID = tempCustomerInfo.CustomerID; tempOrderInfo.OrderType = "TakeAway"; tempOrderInfo.OrderTime = System.DateTime.Now; tempOrderInfo.TableNumber = GetValidTableNumber("TakeAway"); CTableInfo tempTableInfo = new CTableInfo(); tempTableInfo.TableNumber = tempOrderInfo.TableNumber; tempTableInfo.TableType = "TakeAway"; tempOrderManager.InsertTableInfo(tempTableInfo); if (m_orderIndex==1) { tempOrderInfo.Status = "Delivery"; } else if (m_orderIndex ==2 ) { tempOrderInfo.Status = "Collection"; } else if (m_orderIndex == 3) { tempOrderInfo.Status = "Waiting"; } m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); tempOrderInfo.UserID = m_oCommonConstants.UserInfo.UserID; objResultant = tempOrderManager.InsertOrderInfo(tempOrderInfo); //New Order COrderInfo tempOrderInfoNew = (COrderInfo)objResultant.Data;//Taking the order ID m_iOrderID = tempOrderInfoNew.OrderID; #region " Inserting Order details info if items are selected from the previous orders" //Developed by baruri List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>(); if (m_htOrderInfo.Count > 0) //If item is selected from the previous order { tempOrderDetailsList = (List<COrderDetails>)m_htOrderInfo["orderdetail"]; } if (tempOrderDetailsList.Count > 0) //Insert details for the new order { for (int itemDetailIndex = 0; itemDetailIndex < tempOrderDetailsList.Count; itemDetailIndex++) { COrderDetails objOrderDetails = (COrderDetails)tempOrderDetailsList[itemDetailIndex]; objOrderDetails.OrderID = tempOrderInfo.OrderID; tempOrderManager.InsertOrderDetails(objOrderDetails); } m_htOrderInfo = new Hashtable();//Clearing the previous items from the order if there is any. } #endregion //insert delivery time if (tempOrderInfo.Status.Equals("Delivery")) { CDelivery tempDelivery = new CDelivery(); tempDelivery.DeliveryOrderID = tempOrderInfo.OrderID; string deliveryTime = Convert.ToInt32("0" + cmbHour.Text).ToString("00") + ":" + Convert.ToInt32("0" + cmbMinute.Text).ToString("00") + " " + cmbMeridiem.Text; tempDelivery.DeliveryTime = deliveryTime;// DeliveryTimeTextBox.Text.Trim(); tempOrderManager.InsertDeliveryInfo(tempDelivery); } //OLD Code //Form tempForm = CFormManager.Forms.Pop(); //tempForm.Show(); try { WaiterForm waiterForm = new WaiterForm(); waiterForm.UserList = userList; waiterForm.ShowDialog(); if (waiterForm.DialogResult == DialogResult.OK) { COrderWaiterDao orderwaiterDao = new COrderWaiterDao(); COrderwaiter orderwaiter = new COrderwaiter(); orderwaiter = orderwaiterDao.GetOrderwaiterByOrderID(tempOrderInfo.OrderID); if (orderwaiter != null && orderwaiter.ID > 0 && orderwaiter.WaiterID != waiterForm.UserInfoData.UserID) { orderwaiter.OrderID = tempOrderInfo.OrderID; orderwaiter.WaiterID = waiterForm.UserInfoData.UserID; orderwaiter.WaiterName = waiterForm.UserInfoData.UserName; orderwaiterDao.UpdateOrderwaiter(orderwaiter); } else if (orderwaiter.ID == 0) { orderwaiter.OrderID = tempOrderInfo.OrderID; orderwaiter.WaiterID = waiterForm.UserInfoData.UserID; orderwaiter.WaiterName = waiterForm.UserInfoData.UserName; orderwaiterDao.InsertOrderwaiter(orderwaiter); } } } catch (Exception ex) { } m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); CTableOrderForm tempForm = new CTableOrderForm(m_iOrderID, m_oCommonConstants.TakeAwayType, tempOrderInfo.TableNumber); tempForm.m_orderUserName = RMSGlobal.LoginUserName; tempForm.Show(); this.Close(); } else { COrderManager tempOrderManager = new COrderManager(); CResult oResult7 = tempOrderManager.OrderInfoByOrderID(m_iOrderID); COrderInfo tempOrderInfo = new COrderInfo(); if (oResult7.IsSuccess && oResult7.Data != null) { tempOrderInfo = (COrderInfo)oResult7.Data; } tempOrderInfo.OrderType = "TakeAway"; tempOrderInfo.Status = "TakeAway"; tempOrderInfo.GuestCount = 0; tempOrderInfo.TableName = ""; tempOrderInfo.CustomerID = tempCustomerInfo.CustomerID; tempOrderInfo.TableNumber = GetValidTableNumber("TakeAway"); CTableInfo tempTableInfo = new CTableInfo(); tempTableInfo.TableNumber = tempOrderInfo.TableNumber; tempTableInfo.TableType = "TakeAway"; tempOrderManager.InsertTableInfo(tempTableInfo); if (m_orderIndex == 1) { tempOrderInfo.Status = "Delivery"; } else if (m_orderIndex == 3) { tempOrderInfo.Status = "Waiting"; } else if (m_orderIndex == 2) { tempOrderInfo.Status = "Collection"; } tempOrderManager.UpdateOrderInfo(tempOrderInfo); //insert delivery time if (tempOrderInfo.Status.Equals("Delivery")) { CDelivery tempDelivery = new CDelivery(); tempDelivery.DeliveryOrderID = tempOrderInfo.OrderID; string deliveryTime = Convert.ToInt32("0" + cmbHour.Text).ToString("00") + ":" + Convert.ToInt32("0" + cmbMinute.Text).ToString("00") + " " + cmbMeridiem.Text; tempDelivery.DeliveryTime = deliveryTime;// DeliveryTimeTextBox.Text.Trim(); tempOrderManager.InsertDeliveryInfo(tempDelivery); } try { WaiterForm waiterForm = new WaiterForm(); waiterForm.UserList = userList; waiterForm.ShowDialog(); if (waiterForm.DialogResult == DialogResult.OK) { COrderWaiterDao orderwaiterDao = new COrderWaiterDao(); COrderwaiter orderwaiter = new COrderwaiter(); orderwaiter = orderwaiterDao.GetOrderwaiterByOrderID(tempOrderInfo.OrderID); if (orderwaiter != null && orderwaiter.ID > 0 && orderwaiter.WaiterID != waiterForm.UserInfoData.UserID) { orderwaiter.OrderID = tempOrderInfo.OrderID; orderwaiter.WaiterID = waiterForm.UserInfoData.UserID; orderwaiter.WaiterName = waiterForm.UserInfoData.UserName; orderwaiterDao.UpdateOrderwaiter(orderwaiter); } else if (orderwaiter.ID == 0) { orderwaiter.OrderID = tempOrderInfo.OrderID; orderwaiter.WaiterID = waiterForm.UserInfoData.UserID; orderwaiter.WaiterName = waiterForm.UserInfoData.UserName; orderwaiterDao.InsertOrderwaiter(orderwaiter); } } } catch (Exception ex) { } m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); CTableOrderForm tempForm = (CTableOrderForm)CFormManager.Forms.Pop(); tempForm.m_iType = m_oCommonConstants.TakeAwayType; tempForm.Show(); this.Close(); } } #endregion else //Edit order information.As here is reached from order details screen. { COrderInfo tempOrderInfo = new COrderInfo(); COrderManager tempOrderManager = new COrderManager(); CDelivery tempDelivery = null; tempOrderInfo.OrderID = m_iOrderID; tempOrderManager.DeleteDeliveryInfo(m_iOrderID);//Delete previous record from delivery information table if (m_orderIndex==2) { tempOrderInfo.Status = "Collection"; } else if (m_orderIndex==3) { tempOrderInfo.Status = "Waiting"; } else { tempOrderInfo.Status = "Delivery"; tempDelivery = new CDelivery(); tempDelivery.DeliveryOrderID = tempOrderInfo.OrderID; string deliveryTime = Convert.ToInt32("0" + cmbHour.Text).ToString("00") + ":" + Convert.ToInt32("0" + cmbMinute.Text).ToString("00") + " " + cmbMeridiem.Text; tempDelivery.DeliveryTime = deliveryTime;// tempOrderManager.InsertDeliveryInfo(tempDelivery);//Update delivery information } tempOrderManager.UpdateTakeawayOrderInfo(tempOrderInfo);//Update order information try { WaiterForm waiterForm = new WaiterForm(); waiterForm.UserList = userList; waiterForm.ShowDialog(); if (waiterForm.DialogResult == DialogResult.OK) { COrderWaiterDao orderwaiterDao = new COrderWaiterDao(); COrderwaiter orderwaiter = new COrderwaiter(); orderwaiter = orderwaiterDao.GetOrderwaiterByOrderID(tempOrderInfo.OrderID); if (orderwaiter != null && orderwaiter.ID > 0 && orderwaiter.WaiterID != waiterForm.UserInfoData.UserID) { orderwaiter.OrderID = tempOrderInfo.OrderID; orderwaiter.WaiterID = waiterForm.UserInfoData.UserID; orderwaiter.WaiterName = waiterForm.UserInfoData.UserName; orderwaiterDao.UpdateOrderwaiter(orderwaiter); } else if (orderwaiter.ID == 0) { orderwaiter.OrderID = tempOrderInfo.OrderID; orderwaiter.WaiterID = waiterForm.UserInfoData.UserID; orderwaiter.WaiterName = waiterForm.UserInfoData.UserName; orderwaiterDao.InsertOrderwaiter(orderwaiter); } } } catch (Exception ex) { } m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); CTableOrderForm tempForm = (CTableOrderForm)CFormManager.Forms.Pop(); tempForm.m_iType = m_oCommonConstants.TakeAwayType; tempForm.Show(); this.Close(); } m_phoneNumber = String.Empty; } catch (Exception exp) { Console.Write(exp.Message); } }
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(); }
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 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 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) { } }