示例#1
0
        protected void SearchOrderB_Click(object sender, EventArgs e)
        {
            BlOrderUser user = (BlOrderUser)Session["user"];
            //get input values
            string searchBys = SearchBy.Items[SearchBy.SelectedIndex].Value;
            string condition = "";
            string value     = serchedValue.Text;

            switch (searchBys)
            {
            //update condition by selected search value
            case "ArrivalTime":
                condition = $"AND (Orders.{searchBys}=#{value}#)";
                break;

            //case "OrderStutus" when int.TryParse(value, out var status):
            //    condition = $"AND (Orders.OrderStutus={status})";
            //    break;
            //case "OrderStutus":
            //    {
            //        Dictionary<int, string> status = new Dictionary<int, string> { { 1, "order sent" }, { 2, "shop take care your order" }, { 3, "shipping time selected" }, { 4, "delivery take care your order" }, { 5, "order shipped" } };
            //        condition = $"AND (Orders.OrderStutus={status.FirstOrDefault(x => x.Value == value).Key})";
            //        break;
            //    }
            case "FirstName" when user.Type != 3:
                condition = $"AND (Users_1.{searchBys}='{value}')";
                break;

            default:
                condition = $"AND (Shops.{searchBys}='{value}')";
                break;
            }
            UpOrders((BlUser)Session["user"], condition);//update table
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //////to del########################@@@@@@@@########%%%%%%%%%>>>>>>>>>>>>
            /*Session["user"] = new BlShopManager("12345678");*/   // BLShopMenager
            /*  Session["user"] = new Deliver("shlakot1"); */      //deliver eden
            /* Session["user"] = new Deliver("gigi1234"); */       //deliver 2 yakov

            Session["user"] = new BlOrderUser("hoohoo12");         //customer amit
            /*   Session["user"] = new BlOrderUser("lucky123"); */ //system Manager sagi
            if (Page.IsPostBack)
            {
                return;                 //if page already do page loud the headers is already changed
            }
            //set all headers Visible to false
            shopManager.Visible   = false;
            systemManager.Visible = false;
            delivery.Visible      = false;
            customer.Visible      = false;
            unconnected.Visible   = false;
            BlUser user = (BlUser)Session["user"];

            //to check if user verify email!!!!!!!!!!!!!!!!!!!!!!!!!!
            try
            {
                if (GlobalVariable.UnVerifyEmail != null && user != null)
                {
                    string verifyCode = GlobalVariable.UnVerifyEmail[user.UserId];
                    Response.Redirect("VerifyEmail.aspx");
                }
            }
            catch
            {
            }
            if (user != null)
            {
                int type = user.Type;
                switch (type)//choose the right header
                {
                case 1:
                    shopManager.Visible = true;
                    break;

                case 2:
                    systemManager.Visible = true;
                    break;

                case 3:
                    delivery.Visible = true;
                    break;

                default:
                    customer.Visible = true;
                    break;
                }
            }
            else//hide unconnected headers if there is a connected user
            {
                unconnected.Visible = true;
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BlUser      user      = (BlUser)Session["user"];
            BlOrderUser orderUser = null;

            try
            {
                orderUser = (BlOrderUser)Session["user"];
            }
            catch
            {
                Response.Redirect("HomePage.aspx");
                return;
            }

            //take care of all the options of user BlOrderUser/BlShopManager/null
            if (user is BlOrderUser User)
            {
                orderUser = User;
            }
            if (user is BlShopManager shopManager)
            {
                orderUser = shopManager;
            }

            if (user.Type == 2)//system manager
            {
                DataTable shopsTable = BLshopDB.ShopAndManagerTable();
                if (shopsTable != null && shopsTable.Rows.Count > 0)
                {
                    ShopTable.Visible    = true;
                    ShopTable.DataSource = shopsTable;
                    ShopTable.DataBind();
                }
                else
                {
                    ErShopTable.Text = "There is no shops"; //msg
                }
            }
            if (orderUser == null)
            {
                Response.Redirect("HomePage.aspx");
                return;
            }
            if (Page.IsPostBack)
            {
                return;
            }
            //get data
            DataTable customers  = orderUser.CustomersTable();
            DataTable deliveries = orderUser.DeliveriesTable();

            ErDelivery.Text = !BindTable(deliveries, DeliveriesTable) ? "fail show deliveries table" : ""; //error massage
            ErCustomer.Text = !BindTable(customers, CustomersTable) ? "fail show customers table" : "";    //error massage
            //set the labels information
            NumOfOrders.Text    = "Number of orders- " + orderUser.GetNumOfOrders();
            NumOfCustomers.Text = "Number of customers- " + customers.Rows.Count;
        }
示例#4
0
        public int GetNumberOfCustomers(string Password)
        {
            BlOrderUser user           = new BlOrderUser(Password);
            string      numOfCustomers = user.GetNumOfCustomers();
            int         ret;

            if (!int.TryParse(numOfCustomers, result: out ret))
            {
                ret = 0;
            }
            return(ret);
        }
示例#5
0
        public List <BlOrder> GetUserOldOrderList(string Password)
        {
            BlOrderUser    user       = new BlOrderUser(Password);
            DataTable      orders     = user.GetOrders(false, "");
            List <BlOrder> ordersList = new List <BlOrder>();

            foreach (DataRow row in orders.Rows)
            {
                ordersList.Add(new BlOrder(row));
            }
            return(ordersList);
        }
示例#6
0
        protected void LogInB_Click(object sender, EventArgs e)
        {
            //get input values
            string name = Name.Text;
            string pass = Pass.Text;

            if (name != "" && pass != "")
            {
                BlOrderUser user = null;
                try
                {
                    user = new BlOrderUser(pass, name);//create new user by pass
                }
                catch (Exception exception)
                {
                    massage.Text = "Fail to log in " + exception.Message;//ex massage
                    return;
                }
                bool isExist = Page.IsValid && user.Type != 0;//check if all validators are valid and user is exist
                if (isExist)
                {
                    user            = user.Type == 1 ? (BlOrderUser) new BlShopManager(pass) : user.Type == 4 ?   new Deliver(pass) : new BlOrderUser(pass);//choose the right constructor by type
                    Session["user"] = user;
                    //set animation
                    WhichAnimation.Value = "2";
                    //Page_Load(sender,e);
                    //Response.Redirect("LogIn.aspx");
                    //System.Threading.Thread.Sleep(3000);//sleep for 3 seconds


                    ////ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:MoveDrone(); ", true);
                    //ScriptManager.RegisterStartupScript( Page,GetType(), "Javascript", "javascript:MoveDrone();", true);
                    //Response.Redirect("LogIn.aspx");
                    /*    System.Threading.Thread.Sleep(3000);*/ //sleep for 3 seconds
                                                                 //Response.Redirect("HomePage.aspx");
                }
                else
                {
                    //set animation
                    WhichAnimation.Value = "3";
                    massage.Text         = "User name or password incorrect";//fail massage
                }
            }
            else
            {
                //set animation
                WhichAnimation.Value = "3";
                massage.Text         = "password field or name field is empty ";//fail massage
            }
        }
示例#7
0
        public bool Order(int shopId, int numOfFloor, List <BLOrderDetailsDB> orderDetails, string password, double lat, double lng)
        {
            BlOrderUser user  = new BlOrderUser(password);
            BlOrder     order = null;

            try
            {
                order = new BlOrder(user.UserId, "111111111", shopId, new DateTime(2000, 1, 1, 1, 1, 1), new DateTime(2000, 1, 1, 1, 1, 1), 1, lat, lng, numOfFloor, orderDetails);//add order
                return(user.UserId != "-1");
            }
            catch
            {
                return(false);
            }
        }
示例#8
0
        protected void verifyB_OnClick(object sender, EventArgs e)
        {
            if (!IsValid)
            {
                return;
            }
            if (verifyCode.Text == "")
            {
                MSG.Text = "invalid code please try again"; //error massage
                return;
            }
            BlOrderUser user = (BlOrderUser)Session["user"];

            if (user == null)
            {
                Response.Redirect("HomePage.aspx");//if unconnected cant find the Verify Code
                return;
            }

            string RealVerifyCode;

            try
            {
                //get Verify Code
                RealVerifyCode = ((Dictionary <string, string>)Application["UnVerifyEmail"])[user.UserId];
            }
            catch
            {
                Response.Redirect("HomePage.aspx");//if customer not have verify code he doesn't need to verify email
                return;
            }

            string TryVerifyCode = verifyCode.Text;

            if (RealVerifyCode == TryVerifyCode)
            {
                //remove from customer that unverified their email list
                GlobalVariable.UnVerifyEmail.Remove(user.UserId);
                MSG.Text = "register completed";//success massage
            }
            else
            {
                MSG.Text = "invalid code please try again";//error massage
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    OrderStartedSucces.InnerHtml = Request.QueryString.Get("text");
                }
                catch
                {
                    OrderStartedSucces.InnerHtml = "";
                }
            }
            //Session["user"] = new Deliver("shlakot1");
            //BlOrderUser user = (BlOrderUser)Session["user"]; /*(BLUser)Session["user"];*/
            //GlobalVariable.UnVerifyEmail.Add(user.UserId, "111111");
            BlOrderUser user = /*(BlOrderUser)Session["user"];*/ (BlOrderUser)Session["user"];

            //to check if user verify email!!!!!!!!!!!!!!!!!!!!!!!!!!
            //try
            //{
            //    Dictionary<string, string> VerifyEmail = ((Dictionary<string, string>) Application["UnVerifyEmail"]);
            //    if (VerifyEmail!=null)
            //    {
            //        string verifyCode = VerifyEmail[user.UserId];
            //        Response.Redirect("VerifyEmail.aspx");
            //        return;
            //    }
            //    else
            //    {
            //        errorMSG.Text = "VerifyEmail null";
            //    }

            //}
            //catch
            //{

            //}


            if (!(user is Deliver))
            {
                return;
            }
            //get the new orders of the deliver
            List <BlOrder> orders = user.GetOrdersListByTime();
            //set the road lists
            List <BlShop>             shops = new List <BlShop>();
            List <BlCustomersAddress> customersAddresses = new List <BlCustomersAddress>();

            //full road lists

            foreach (BlOrder order in orders)
            {
                shops.Add(BlShop.GetShopById(order.ShopId));
                Point customerAddress = order.Location != null ? new Point(order.Location) : new Point(BlUser.UserById(order.CustomerId).Location);
                customersAddresses.Add(new BlCustomersAddress(customerAddress, order.NumOfFloor, user.GetName()));
            }

            if (orders.Count == 0)
            {
                errorMSG.Text = "there is no orders"; return;
            }
            else
            {
                errorMSG.Text = "";
            }
            if (orders.Count > 1)//to change to orders.Count>1!!!!!!!!!!!!!####$$$$$$$$########@@@@@@@*********#########&&&&&&&&&&$$$$$$$$$$^^^^^^^^^^%%%%%%%%%**********
            {
                //List<BlShop> sameShops = BlShop.isHaveSameShop(shops);
                //bool isHaveSameShop = sameShops.Count > 0;
                //if (isHaveSameShop)
                //{

                //}
                bool isAllSameShop = BlShop.isAllSameShop(shops);
                //calculate shorter way to deliver
                GetBestWayLists(isAllSameShop, shops, customersAddresses, orders, (Deliver)user);
            }
            else
            {
                //update the Page vars
                Shops     = Json.Encode(shops);
                Customers = Json.Encode(customersAddresses);
                UpdateWayString(shops, customersAddresses);
                //update the global vars
                Deliver deliver = (Deliver)user;
                double  minutes = deliver.GetDistanceToCustomerHome(shops, customersAddresses);
                GlobalVariable.Distance = minutes;
            }
        }
示例#10
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();
        }
示例#11
0
        protected void OrderB_Click(object sender, EventArgs e)
        {
            //get input values
            int shopId     = int.Parse(Request.QueryString.Get("shopId"));
            int numOfFloor = 0;

            try
            {
                numOfFloor = int.Parse(NumOfFloor.Text);//try to get num of floor
            }
            catch
            {
                MSG.Text = "Please enter num Of Floor";//massage
                return;
            }
            string latLng          = this.LatLng.Value.ToString();
            double lat             = GetLat(latLng);
            double lng             = GetLng(latLng);
            BlUser user            = (BlUser)Session["user"];
            bool   IsNotNewAddress = lat == 1.0 && lng == 1.0 /*&& address == ""*/;

            if (IsNotNewAddress)//if IsNotNewAddress the address is the user address from DB
            {
                Point UserLocation = user.Location;
                lat = UserLocation.Lat;
                lng = UserLocation.Lng;
            }

            if (numOfFloor != 0 && Page.IsValid)//if the validator is valid and numOfFloor is valid add order
            {
                try
                {
                    //need to get order from session
                    BlOrder order = new BlOrder(user.UserId, "111111111", shopId, new DateTime(2000, 1, 1, 1, 1, 1), new DateTime(2000, 1, 1, 1, 1, 1), 1, lat, lng, numOfFloor, (List <BLOrderDetailsDB>)Session["OrderDetails"]);//add order
                    //update order details
                    bool success = order.OrderId != -1;
                    List <BLOrderDetailsDB> orderDetails = (List <BLOrderDetailsDB>)Session["orderDetails"];

                    //if (success)
                    //{
                    //    success = BLOrderDetailsDB.UpdateOrderDetails(orderDetails);
                    //}
                    MSG.Text = success ? "order successes!!" : "order failed :(";//fail/success massage
                    BlOrderUser customer = new BlOrderUser(order.CustomerId);
                    //get  description of the product list to send in email
                    string prodactsString = BLProduct.GetProductString(orderDetails);

                    bool isEmailSent = Register.sendEmail(customer.Email, " Fly pack order summery ",
                                                          $"Hi,{customer} your order received and we take care your order.here a summery of your  order- <br/>{prodactsString}<br/>Have a nice day,The Fly Pack Team");
                    if (!isEmailSent)
                    {
                        //take care if email dont send
                    }
                    BlOrderUser shopManager    = new BlOrderUser(order.CustomerId);
                    bool        isEmailSentToM = Register.sendEmail(shopManager.Email, " Fly pack a customer order from your shop!!",
                                                                    $"Hi,{shopManager} please update when your products will be ready to be delivered.here a summery of your  order- <br/>{prodactsString}<br/ Have a nice day,The Fly Pack Team");
                    if (!isEmailSentToM)
                    {
                        //take care if email dont send
                    }
                }
                catch (Exception exception)
                {
                    MSG.Text = "fail to add order because-" + exception.Message;//fail massage
                }
            }
            else
            {
                NumOfFloor.CssClass = NumOfFloorValidator.IsValid ? "TextBox" : "TextBoxUnValidValue";//convert the the bob style by the validator
            }
        }
示例#12
0
        public int GetNumberOfOrders(string Password)
        {
            BlOrderUser user = new BlOrderUser(Password);

            return(user.GetNumOfOrders());
        }
示例#13
0
        public DataTable GetUserNewOrderList(string Password)
        {
            BlOrderUser user = new BlOrderUser(Password);

            return(user.GetOrders(true, ""));
        }