public int LastAddedInvestlNo()
        {
            OrderGateway gateway = new OrderGateway();

            DBManager     manager    = new DBManager();
            SqlConnection connection = manager.Connection();


            string     selectQuery = "SELECT Order_No From Orders";
            SqlCommand cmd         = new SqlCommand(selectQuery, connection);

            connection.Open();
            SqlDataReader reader  = cmd.ExecuteReader();
            List <int>    totalId = new List <int>();

            while (reader.Read())
            {
                int aId = Convert.ToInt16(reader[0]);


                totalId.Add(aId);
            }
            if (totalId.Count <= 0)
            {
                return(0);
            }
            else
            {
                int x = totalId.Max();

                return(x);
            }
        }
        public Order GetOrderByUseIdAndDate(int userId, string date)
        {
            OrderGateway orderGateway = new OrderGateway();


            return(orderGateway.GetOrderByUseIdAndDate(userId, date));
        }
        //save an Order
        private void orderAcceptButton_Click(object sender, EventArgs e)
        {
            try
            {
                OrderGateway gateway = new OrderGateway();
                Order        anOrder = new Order();
                anOrder.CustomerName  = customerNameTextBox.Text;
                anOrder.CustomerPhone = customerMobileTextBox.Text;
                anOrder.BookName      = bookNameTextBox.Text;
                anOrder.WriterName    = writerNameTextBox.Text;
                anOrder.Edition       = bookEditionTextBox.Text;
                anOrder.BuyUnitPrice  = Convert.ToDouble(buyingUnitPriceTextBox.Text);
                string quantiy = bookQuantityTextBOx.Text;
                anOrder.Quantity  = Convert.ToInt16(quantiy);
                anOrder.UnitPrice = Convert.ToDouble(bookUnitPriceTextBOx.Text);
                anOrder.Advance   = Convert.ToDouble(advanceTextBox.Text);

                anOrder.SupplyDate = dateTimePicker1.Text;
                string st = gateway.SaveOrder(anOrder);
                MessageBox.Show(st, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearALLtextBox();
                LoadAllBook();

                serialTextBox.Text = LastAddedInvestlNo().ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Please fill every fields properly.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
        public Order GetOrder(Order order)
        {
            OrderGateway orderGateway = new OrderGateway();


            return(orderGateway.GetOrder(order));
        }
        public string PutOrder(Order order)
        {
            OrderGateway OrderGateway = new OrderGateway();

            int rowEffected = OrderGateway.PutOrder(order);

            if (rowEffected > 0)
            {
                return("Order is Successfully");
            }

            return("Order is Failed");
        }
        public string AddMealPriceForAllOrderByMonth(int month, int year, double mealPrice)
        {
            OrderGateway OrderGateway = new OrderGateway();

            int rowEffected = OrderGateway.AddMealPriceForAllOrderByMonth(month, year, mealPrice);

            if (rowEffected > 1)
            {
                return("Successfully Added Meal Price");
            }

            return("Failed to Add Meal Price");
        }
        public string UpdateOrder(Order order)
        {
            OrderGateway orderGateway = new OrderGateway();

            int rowEffected = orderGateway.UpdateOrder(order);

            if (rowEffected > 0)
            {
                return("Order Updated Successfully");
            }


            return("Order Updated Failed");
        }
        public double GetTotalMealOfMonth(int month, int year, int userId)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.GetTotalMealOfMonth(month, year, userId));
        }
        public double GetTotalMealBetweenDays(string fromDay, string toDay, int userId)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.GetTotalMealBetweenDays(fromDay, toDay, userId));
        }
        public double GetTotalMeal3CostAllUserByDay(string day)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.GetTotalMeal3CostAllUserByDay(day));
        }
        public double TotalMealOfMonth(int month, int year)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.TotalMealOfMonth(month, year));
        }
        public List <Order> GetAllOrderBetweenDates(string fromDate, string toDate, int userId)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.GetAllOrderBetweenDates(fromDate, toDate, userId));
        }
        public Order GetAllOrderByUserIdAndDate(string date, int userId)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.GetAllOrderByUserIdAndDate(date, userId));
        }
        public List <Order> TotalMealForMonthByUserList(int month, int year)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.TotalMealForMonthByUserList(month, year));
        }
        public Order GetOrder(string date, int userId)
        {
            OrderGateway orderGateway = new OrderGateway();

            return(orderGateway.GetOrder(date, userId));
        }
Exemple #16
0
 public OrderGateway GetOrderGateway()
 {
     return OrderGW != null ? OrderGW : OrderGW = new OrderGateway();
 }
Exemple #17
0
        //save an Order
        private void orderAcceptButton_Click(object sender, EventArgs e)
        {
            try
            {
                OrderGateway gateway = new OrderGateway();
                Order        anOrder = new Order();
                anOrder.CustomerName  = customerNameTextBox.Text;
                anOrder.CustomerPhone = customerMobileTextBox.Text;
                anOrder.BookName      = bookNameTextBox.Text;
                anOrder.WriterName    = writerNameTextBox.Text;
                anOrder.Edition       = bookEditionTextBox.Text;
                anOrder.TypeOfBook    = typeOfBookTextBox.Text;
                anOrder.BookPrint     = bookPrintTextbox.Text;
                anOrder.BuyUnitPrice  = Convert.ToDouble(buyingUnitPriceTextBox.Text);
                string quantiy = bookQuantityTextBOx.Text;
                anOrder.Quantity  = Convert.ToInt16(quantiy);
                anOrder.UnitPrice = Convert.ToDouble(bookUnitPriceTextBOx.Text);
                anOrder.Advance   = Convert.ToDouble(advanceTextBox.Text);

                anOrder.SupplyDate = dateTimePicker1.Text;


                string st = gateway.SaveOrder(anOrder);

                ////InvoiceUI invoice=new InvoiceUI(serialTextBox.Text,customerNameTextBox.Text,customerMobileTextBox.Text,bookNameTextBox.Text,writerNameTextBox.Text,bookEditionTextBox.Text,typeOfBookTextBox.Text,bookPrintTextbox.Text,bookQuantityTextBOx.Text,bookUnitPriceTextBOx.Text,advanceTextBox.Text,dueTextBox.Text,dateTimePicker1.Text);

                //invoice.ShowDialog();
                TempOrder aOrder = new TempOrder();
                aOrder.SerialNo     = serialTextBox.Text;
                aOrder.CustomerName = customerNameTextBox.Text;
                aOrder.MobileNo     = customerMobileTextBox.Text;
                aOrder.BookName     = bookNameTextBox.Text;
                aOrder.WriterName   = writerNameTextBox.Text;
                aOrder.Edition      = bookEditionTextBox.Text;
                aOrder.Type         = typeOfBookTextBox.Text;
                aOrder.Print        = bookPrintTextbox.Text;
                aOrder.Quantity     = Convert.ToInt16(bookQuantityTextBOx.Text);
                aOrder.Unitprice    = Convert.ToDouble(bookUnitPriceTextBOx.Text);
                aOrder.Total        =
                    (Convert.ToInt16(bookQuantityTextBOx.Text) * Convert.ToDouble(bookUnitPriceTextBOx.Text));
                aOrder.Advance = Convert.ToDouble(advanceTextBox.Text);
                aOrder.Due     = Convert.ToDouble(dueTextBox.Text);

                aOrder.SupplyDate = dateTimePicker1.Text;
                aOrder.MemoNumber = memoNumver;
                TempOrderGateway gateway1 = new TempOrderGateway();
                gateway1.SaveTempOrer(aOrder);

                MessageBox.Show(st, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);



                ClearALLtextBox();
                LoadAllBook();

                serialTextBox.Text = LastAddedInvestlNo().ToString();
                CustomerNamteSuggestion();
                AtocompleteTextBox();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);

                //MessageBox.Show("Please fill every fields properly.", "Error", MessageBoxButtons.OK,
                //        MessageBoxIcon.Error);
            }
        }