Exemple #1
0
        public void UpOrders(BlUser user, string condition)
        {
            DataTable   orders    = null;
            int         index     = NewOrOld.SelectedIndex;
            BlOrderUser orderUser = new BlOrderUser(user.Password);
            int         status    = int.Parse(Status.Items[Status.SelectedIndex].Value);

            if (status != -1)
            {
                condition += $" AND (Orders.OrderStutus={status})";
            }
            if (ViewState["minDate"] != null)
            {
                condition += ViewState["minDate"].ToString();
            }
            if (ViewState["maxDate"] != null)
            {
                condition += ViewState["maxDate"].ToString();
            }
            switch (NewOrOld.Items[index].Value)//get order table by selected option
            {
            case "N":
                int numOfColums = OrderTable.Columns.Count;
                if (numOfColums > 0)
                {
                    OrderTable.Columns[numOfColums - 1].Visible = true;
                }
                try
                {
                    orders = orderUser.GetOrders(true, condition);
                }
                catch (Exception e)
                {
                    ErMSG.Text = "fail" + e.Message;
                }

                break;

            default:
                OrderTable.Columns[OrderTable.Columns.Count - 1].Visible = false;
                try
                {
                    orders = orderUser.GetOrders(false, condition);
                }
                catch (Exception e)
                {
                    ErMSG.Text = "fail " + e.Message;
                }
                break;
            }
            //int userType = user.Type;//get user type
            //int length = OrderTable.Rows.Count;
            //switch (userType)//convert button values by status and user type
            //{

            //    case 3:
            //    {
            //        for (int i = 0; i < length; i++)
            //        {
            //            GridViewRow row = OrderTable.Rows[i];
            //            TableCell cell = row.Cells[1];
            //            if (cell.Text != "delivery take care your order") continue;
            //            Button myButton = null;
            //            myButton = (Button)row.Cells[row.Cells.Count - 1].Controls[0];
            //            myButton.Text = "Order Finished";
            //            myButton.CommandName = "finish";
            //        }

            //        break;
            //    }
            //    case 1:
            //    {

            //        for (int i = 0; i < length; i++)
            //        {
            //            GridViewRow row = OrderTable.Rows[i];
            //            TableCell cell = row.Cells[1];
            //            if (cell.Text != "shipping time selected") continue;
            //            var myButton = (Button)row.Cells[row.Cells.Count - 1].Controls[0];
            //            myButton.Text = "Ready time selected";
            //            myButton.CommandName = "";
            //        }

            //        break;
            //    }
            //}
            if (orders != null && orders.Rows.Count > 0)//if there is orders
            {
                //show table
                OrderTable.DataSource = orders;
                OrderTable.DataBind();
                ErMSG.Text         = "";
                OrderTable.Visible = true;
            }
            else
            {
                //hide table
                OrderTable.Visible = false;
                ErMSG.Text         = "there is no orders";
            }
            UpdateButtonsText(user.Type);
            updateUnValidArivelTime();
        }