Ejemplo n.º 1
0
        private void CancelDeliveryBtn_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = CustomMsgBox.Show("Are you sure you want to cancel the order\n if you cancel the order your " +
                                                          "rating will decrease by 0.2", 2);

            if (dialogResult == DialogResult.Yes)
            {
                Entities ent = new Entities();
                var      l   = (from fo in ent.ORDER_FOOD
                                where fo.ORDER_ID == ordID
                                select fo);
                foreach (var i in l)
                {
                    i.BOUGHT = "n";
                }
                var ord = (from o in ent.ORDERS
                           where o.ORDER_ID == ordID
                           select o).First();
                ord.STATUS = "pp";
                DELIVERY_PARTNER dp = (from p in ent.DELIVERY_PARTNER
                                       where p.USERNAME == Helper.currentUserName
                                       select p).FirstOrDefault();
                dp.RATING = Math.Min(0, dp.RATING - (decimal)(0.2));
                ent.TRIPs.Remove(ent.TRIPs.Where(te => te.ORDER_ID == ordID).First());
                ent.SaveChanges();
                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void OrderDeliveredBtn_Click(object sender, EventArgs e)
        {
            Entities ent = new Entities();
            ORDER    o   = ent.ORDERS.Where(x => x.ORDER_ID == ordID).FirstOrDefault();

            o.STATUS = "d";
            DELIVERY_PARTNER dp = ent.DELIVERY_PARTNER.Where(p => p.USERNAME == Helper.currentUserName).FirstOrDefault();
            TRIP             t = ent.TRIPs.Where(tr => tr.ORDER_ID == o.ORDER_ID).FirstOrDefault();
            decimal          mealcost = o.FOOD_PRICE, applicationfees = 5, totalcost;
            decimal          deliverycost = t.DISTANCE_OF_TRIP * Math.Max(dp.RATING, 1);

            if (dp.VEHICLE.ToLower() == "car")
            {
                deliverycost *= 8;
            }
            else if (dp.VEHICLE.ToLower() == "bike" || dp.VEHICLE.ToLower() == "scooter")
            {
                deliverycost *= 5;
            }
            else
            {
                deliverycost *= 3;
            }
            t.DELIVERYFEES = deliverycost;
            dp.RATING      = Math.Max(5, dp.RATING + (decimal)(0.01));
            totalcost      = deliverycost + applicationfees + mealcost;
            CustomMsgBox.Show("Delivery Fees = " + deliverycost.ToString() +
                              "\nMeal Cost = " + mealcost.ToString() +
                              "\nTotal Cost = " + totalcost.ToString());
            ent.SaveChanges();
            this.Close();
        }
Ejemplo n.º 3
0
        private void savePasswordBtn_Click(object sender, EventArgs e)
        {
            if (newPassword.Text == "" || oldPassword.Text == "" || confirmPassword.Text == "")
            {
                CustomMsgBox.Show("Please fill all fields.");
            }
            OracleCommand cmd = new OracleCommand();

            cmd.Connection  = con;
            cmd.CommandText = "select password from customer where username=:uname";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("uname", Helper.currentUserName);
            OracleDataReader rdr = cmd.ExecuteReader();

            if (rdr.Read())
            {
                cust_pass = rdr[0].ToString();
            }
            if (cust_pass == oldPassword.Text)
            {
                if (newPassword.Text == confirmPassword.Text)
                {
                    OracleCommand cmd2 = new OracleCommand();
                    cmd2.Connection  = con;
                    cmd2.CommandText = "update customer set password=:newpass where username=:uname";
                    cmd2.CommandType = CommandType.Text;
                    cmd2.Parameters.Add("newpass", newPassword.Text);
                    cmd2.Parameters.Add("uname", Helper.currentUserName);
                    int r = cmd2.ExecuteNonQuery();
                    if (r != -1)
                    {
                        CustomMsgBox.Show("Password is changed successfully.");
                        cust_pass            = newPassword.Text;
                        oldPassword.Text     = "";
                        newPassword.Text     = "";
                        confirmPassword.Text = "";
                        oldPassword.Hide();
                        newPassword.Hide();
                        confirmPassword.Hide();
                        savePasswordBtn.Hide();
                    }
                    else
                    {
                        CustomMsgBox.Show("Couldn't change your password. Please try again.");
                    }
                }
                else
                {
                    CustomMsgBox.Show("Please re-enter your new password.");
                    newPassword.Text     = "";
                    confirmPassword.Text = "";
                }
            }
            else
            {
                CustomMsgBox.Show("Wrong Password! Enter your password again.");
                oldPassword.Text = "";
            }
        }
 private void updateRatingBtn_Click(object sender, EventArgs e)
 {
     if (CustomMsgBox.Show("Are you sure you want to update this restaurant?", 2) == DialogResult.Yes)
     {
         RESTAURANT r = ent.RESTAURANTs.Where(x => x.RESTAURANT_NAME == RestaurantsNamesUpdate.Text && x.RESTAURANT_LOCATION == RestaurantLocationUpdate.Text).First();
         r.RATING       = Convert.ToInt32(RestaurantRatingUpdate.Text);
         r.CUISINE_TYPE = CusineTypeUpdate.Text;
         ent.SaveChanges();
         CustomMsgBox.Show("Restaurant Updated");
         updateRest();
     }
 }
 private void PendingOrdersBtn_Click(object sender, EventArgs e)
 {
     if (oid == 0)
     {
         OrdersDeliveryPartner p = new OrdersDeliveryPartner(1);
         p.Show();
         this.Hide();
         p.FormClosing += letsShow;
     }
     else
     {
         CustomMsgBox.Show("Please Finish your Current Order before you take any other order.");
     }
 }
Ejemplo n.º 6
0
 public static DialogResult Show(string txt, int type = 1)
 {
     mb = new CustomMsgBox();
     if (type == 1)
     {
         mb.OKBtn.Visible = mb.OKBtn.Enabled = true;
     }
     else
     {
         result           = DialogResult.No;
         mb.NoBtn.Visible = mb.NoBtn.Enabled = mb.YesBtn.Visible = mb.YesBtn.Enabled = true;
     }
     mb.MessageTxt.Text = txt;
     mb.ShowDialog();
     return(result);
 }
Ejemplo n.º 7
0
 private void OrdersDeliveryPartner_Load(object sender, EventArgs e)
 {
     if (type == pending)
     {
         try
         {
             adapter1 = new OracleDataAdapter("select o.* from orders o where status = 'pp'", new OracleConnection(Helper.constr));
             adapter2 = new OracleDataAdapter("select o.ORDER_ID, f.* from food f, order_food offf, orders o where o.ORDER_ID = offf.ORDER_ID and offf.RESTAURANT_NAME = f.RESTAURANT_NAME and offf.RESTAURANT_LOCATION = f.RESTAURANT_LOCATION and offf.FOOD_NAME= f.FOOD_NAME and o.status = 'pp'", new OracleConnection(Helper.constr));
             ds       = new DataSet();
             adapter1.Fill(ds, "order");
             adapter2.Fill(ds, "food");
             DataRelation r1 = new DataRelation("fk1", ds.Tables[0].Columns["order_id"], ds.Tables[1].Columns["order_id"]);
             ds.Relations.Add(r1);
             BindingSource bs_Master = new BindingSource(ds, "order");
             BindingSource bs_child1 = new BindingSource(bs_Master, "fk1");
             orders.DataSource = bs_Master;
             food.DataSource   = bs_child1;
         }
         catch
         {
             erg3 = true;
             CustomMsgBox.Show("There's no orders to show");
         }
     }
     else
     {
         try
         {
             adapter1 = new OracleDataAdapter("select o.* from orders o, trip t where t.DELIVERYPARTNER_USERNAME = '******' and t.ORDER_ID = o.ORDER_ID and o.status = 'd'", new OracleConnection(Helper.constr));
             adapter2 = new OracleDataAdapter("select o.ORDER_ID, f.* from food f, order_food offf, orders o, trip t where o.ORDER_ID = offf.ORDER_ID and t.order_id = o.order_id and offf.RESTAURANT_NAME = f.RESTAURANT_NAME and offf.RESTAURANT_LOCATION = f.RESTAURANT_LOCATION and offf.FOOD_NAME= f.FOOD_NAME and t.DELIVERYPARTNER_USERNAME = '******' and o.status = 'd'", new OracleConnection(Helper.constr));
             ds       = new DataSet();
             adapter1.Fill(ds, "order");
             adapter2.Fill(ds, "food");
             DataRelation r1 = new DataRelation("fk1", ds.Tables[0].Columns["order_id"], ds.Tables[1].Columns["order_id"]);
             ds.Relations.Add(r1);
             BindingSource bs_Master = new BindingSource(ds, "order");
             BindingSource bs_child1 = new BindingSource(bs_Master, "fk1");
             orders.DataSource = bs_Master;
             food.DataSource   = bs_child1;
         }
         catch
         {
             erg3 = true;
             CustomMsgBox.Show("There's no orders to show");
         }
     }
 }
 private void Remove_Click(object sender, EventArgs e)
 {
     if (CustomMsgBox.Show("Are you sure to delete this item", 2) == DialogResult.Yes)
     {
         con = new OracleConnection(Helper.constr);
         con.Open();
         OracleCommand cmd = new OracleCommand();
         cmd.Connection  = con;
         cmd.CommandText = "Delete_Cart_Item";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("id", Helper.currentOrderId);
         cmd.Parameters.Add("rest_name", RestName.Text);
         cmd.Parameters.Add("rest_loc", RestLoc.Text);
         cmd.Parameters.Add("food_name", FoodName.Text);
         cmd.ExecuteNonQuery();
         con.Close();
         this.Parent.Controls.Remove(this);
     }
 }
 private void FoodUpdateBtn_Click(object sender, EventArgs e)
 {
     if (CustomMsgBox.Show("Are you sure You want to Update this food to " + FoodRestNameUpdate.Text + " located at " + FoodRestLocUpdate.Text + "?", 2) == DialogResult.Yes)
     {
         FOOD f = new FOOD();
         f.DISCOUNT            = Convert.ToInt32(FoodDiscountUpdate.Text);
         f.FOODIMAGE           = Helper.getFileName(foodimgupdate);
         f.FOODTYPE            = FoodTypeUpdate.Text;
         f.FOOD_NAME           = FoodNameUpdate.Text;
         f.INGREDIANTS         = FoodIngUpdate.Text;
         f.PRICE               = Convert.ToDecimal(FoodPriceUpdate.Text);
         f.RATING              = FoodRatingUpdate.Value;
         f.RESTAURANT_LOCATION = FoodRestLocUpdate.Text;
         f.RESTAURANT_NAME     = FoodRestNameUpdate.Text;
         f.TOP_DISH            = (FoodTopDishUpdate.Checked ? "y" : "n");
         ent.FOODs.AddOrUpdate(f);
         ent.SaveChanges();
         CustomMsgBox.Show(FoodNameUpdate.Text + " Updated");
     }
 }
 private void addResBtn_Click(object sender, EventArgs e)
 {
     if (CustomMsgBox.Show("Are you sure you want to add this restaurant?", 2) == DialogResult.Yes)
     {
         if (ent.RESTAURANTs.Where(x => x.RESTAURANT_NAME == RestaurantsNamesAdd.Text && x.RESTAURANT_LOCATION == RestaurantLocationAdd.Text).Count() > 0)
         {
             CustomMsgBox.Show("This restaurant already exists");
             return;
         }
         RESTAURANT r = new RESTAURANT();
         r.RESTAURANT_NAME     = RestaurantsNamesAdd.Text;
         r.RESTAURANT_LOCATION = RestaurantLocationAdd.Text;
         r.RATING       = int.Parse(ratingRest.Text);
         r.CUISINE_TYPE = CusineTypeAdd.Text;
         ent.RESTAURANTs.Add(r);
         ent.SaveChanges();
         CustomMsgBox.Show("Restaurant added");
         updateRest();
     }
 }
Ejemplo n.º 11
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            OracleCommand cmd = new OracleCommand();

            cmd.Connection  = con;
            cmd.CommandText = "update customer set fname=:fn, lname=:ln, location=:loc, credit_no=:credit where username=:uname";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("fn", fName.Text);
            cmd.Parameters.Add("ln", lName.Text);
            cmd.Parameters.Add("loc", location.Text);
            cmd.Parameters.Add("credit", creditCard.Text);
            cmd.Parameters.Add("uname", Helper.currentUserName);
            int r = cmd.ExecuteNonQuery();

            if (r != -1)
            {
                CustomMsgBox.Show("Info is Updated successfully.");
                cust_fname  = fName.Text;
                cust_lname  = lName.Text;
                cust_loc    = location.Text;
                cust_credit = creditCard.Text;
            }
            else
            {
                CustomMsgBox.Show("Couldn't update your information. Please try again.");
            }
            saveBtn.Hide();
            editBtn.Show();
            userName.Enabled     = false;
            fName.Enabled        = false;
            lName.Enabled        = false;
            location.Enabled     = false;
            creditCard.Enabled   = false;
            userName.ForeColor   = Color.DarkGray;
            fName.ForeColor      = Color.DarkGray;
            lName.ForeColor      = Color.DarkGray;
            location.ForeColor   = Color.DarkGray;
            creditCard.ForeColor = Color.DarkGray;
        }
Ejemplo n.º 12
0
 private void orders_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (type == 1)
     {
         DialogResult dialogResult = CustomMsgBox.Show("Do you want to take this order?", 2);
         if (dialogResult == DialogResult.Yes)
         {
             int id = Convert.ToInt32(orders.Rows[e.RowIndex].Cells[0].Value);
             ds.Tables[0].Rows[e.RowIndex][4] = "pd";
             OracleConnection con = new OracleConnection(Helper.constr);
             builder = new OracleCommandBuilder(adapter1);
             adapter1.Update(ds.Tables[0]);
             con.Open();
             OracleCommand cmd = new OracleCommand(@"insert into trip 
                                                 (order_id, deliverypartner_username, distance_of_trip, deliveryfees) 
                                                 values (" + id.ToString() + ", '" + Helper.currentUserName + "', " +
                                                   "ROUND(DBMS_RANDOM.VALUE(0,200),2), 0)", con);
             cmd.ExecuteNonQuery();
             con.Close();
             this.Close();
         }
     }
 }
 private void savePasswordBtn_Click(object sender, EventArgs e)
 {
     if (newPassword.Text == "" || oldPassword.Text == "" || confirmPassword.Text == "")
     {
         CustomMsgBox.Show("Please fill all fields.");
     }
     if (oldPassword.Text == part_pass)
     {
         if (newPassword.Text == confirmPassword.Text)
         {
             ds.Tables["partner"].Rows[index][2] = newPassword.Text;
             part_pass = newPassword.Text;
             builder   = new OracleCommandBuilder(adapter);
             adapter.Update(ds.Tables["partner"]);
             CustomMsgBox.Show("Password is changed successfully.");
             oldPassword.Text     = "";
             newPassword.Text     = "";
             confirmPassword.Text = "";
             oldPassword.Hide();
             newPassword.Hide();
             confirmPassword.Hide();
             savePasswordBtn.Hide();
         }
         else
         {
             CustomMsgBox.Show("Please re-enter your new password.");
             newPassword.Text     = "";
             confirmPassword.Text = "";
         }
     }
     else
     {
         CustomMsgBox.Show("Wrong Password! Enter your password again.");
         oldPassword.Text = "";
     }
 }
        private void saveBtn_Click(object sender, EventArgs e)
        {
            if (vehicleType.Text == "" || vehicleType.Text.ToLower() == "car" || vehicleType.Text.ToLower() == "bike" || vehicleType.Text.ToLower() == "scooter" || vehicleType.Text.ToLower() == "no vehicle")
            {
                if (vehicleType.Text == "")
                {
                    vehicleType.Text = "no vehicle";
                }
                ds.Tables["partner"].Rows[index][1] = vehicleType.Text;
                builder = new OracleCommandBuilder(adapter);
                adapter.Update(ds.Tables["partner"]);
                CustomMsgBox.Show("Vehicle is updated successfully.");
                part_vehicle = vehicleType.Text;

                saveBtn.Hide();
                editBtn.Show();
                userName.Enabled    = false;
                vehicleType.Enabled = false;
            }
            else
            {
                CustomMsgBox.Show("Please Enter A valid vehicle\n (car, bike, scooter)");
            }
        }
Ejemplo n.º 15
0
        private void Confirm_Click(object sender, EventArgs e)
        {
            int z = flowLayoutPanel1.Controls.Count;

            for (int i = 0; i < z; i++)
            {
                OracleCommand cmd4 = new OracleCommand();
                cmd4.Connection  = con;
                cmd4.CommandText = "Update_Cart_Items";
                cmd4.CommandType = CommandType.StoredProcedure;
                cmd4.Parameters.Add("id", Helper.currentOrderId);
                cmd4.Parameters.Add("rest_name", cartItems[i].RestName.Text);
                cmd4.Parameters.Add("rest_loc", cartItems[i].RestLoc.Text);
                cmd4.Parameters.Add("food_name", cartItems[i].FoodName.Text);
                cmd4.Parameters.Add("no_of_items", cartItems[i].NoOfItems.Text);
                cmd4.ExecuteNonQuery();
            }

            decimal       totalprice = 0, totaldiscount = 0;
            OracleCommand cmd8 = new OracleCommand();

            cmd8.Connection  = con;
            cmd8.CommandText = "Order_Total_Price";
            cmd8.CommandType = CommandType.StoredProcedure;
            cmd8.Parameters.Add("orderno", Helper.currentOrderId);
            cmd8.Parameters.Add("r", OracleDbType.RefCursor, ParameterDirection.Output);
            OracleDataReader dr1 = cmd8.ExecuteReader();

            while (dr1.Read())
            {
                decimal tmp = Convert.ToDecimal(dr1[1]) * Convert.ToDecimal(dr1[2]);
                totalprice += tmp - (tmp * (Convert.ToDecimal(dr1[3]) / 100));
            }

            if (z > 0)
            {
                OracleCommand cmd5 = new OracleCommand();
                cmd5.Connection  = con;
                cmd5.CommandText = "Update_Order_Status_nc_to_pp";
                cmd5.CommandType = CommandType.StoredProcedure;
                cmd5.Parameters.Add("id", Helper.currentOrderId);
                cmd5.ExecuteNonQuery();

                OracleCommand cmd = new OracleCommand("Create_Cart", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("un", Helper.currentUserName);
                cmd.ExecuteNonQuery();
                Entities ent        = new Entities();
                ORDER    ord        = ent.ORDERS.Where(h => h.ORDER_ID == Helper.currentOrderId).First();
                var      creditcard = ent.CUSTOMERs.Where(c => c.USERNAME == Helper.currentUserName).First().CREDIT_NO;
                if (creditcard != null && CustomMsgBox.Show("Do you want to pay with credit card?", 2) == DialogResult.Yes)
                {
                    ord.PAYMENT_TYPE = "visa";
                }
                else
                {
                    ord.PAYMENT_TYPE = "cash";
                }
                Helper.currentOrderId = Helper.getCartId();

                OracleCommand cmd6 = new OracleCommand();
                cmd6.Connection  = con;
                cmd6.CommandText = "Count_GetPoints";
                cmd6.CommandType = CommandType.StoredProcedure;
                cmd6.Parameters.Add("username", Helper.currentUserName);
                cmd6.Parameters.Add("cnt", OracleDbType.Int32, ParameterDirection.Output);
                cmd6.ExecuteNonQuery();
                Helper.points = int.Parse(cmd6.Parameters["cnt"].Value.ToString());
                if (Helper.points > 20)
                {
                    decimal tmp = Math.Min(50, Helper.points / 2);
                    if (CustomMsgBox.Show("You have a " + tmp.ToString() + "% voucher.\n Do you want to use it?", 2) == DialogResult.Yes)
                    {
                        OracleCommand cmd7 = new OracleCommand();
                        cmd7.Connection  = con;
                        cmd7.CommandText = "UPDATE_ORDER_STATUS_TO_DV";
                        cmd7.CommandType = CommandType.StoredProcedure;
                        cmd7.Parameters.Add("un", Helper.currentUserName);
                        cmd7.ExecuteNonQuery();
                        totaldiscount = (tmp / 100) * totalprice;
                        CustomMsgBox.Show("Voucher is used");
                    }
                }
                ord.FOOD_PRICE = totalprice - totaldiscount;
                ent.SaveChanges();
                CustomMsgBox.Show("Order Confirmed\nOrder Food Total Price = " + ord.FOOD_PRICE.ToString());
            }
            this.Close();
        }
 private void button1_Click(object sender, EventArgs e)
 {
     CustomMsgBox.Show("Type: " + type + "\nIngerdiants: " + ingrediants);
 }
Ejemplo n.º 17
0
        private void signUpBtn_Click(object sender, EventArgs e)
        {
            if (!customerChkBx.Checked && !partnerChkBx.Checked)
            {
                CustomMsgBox.Show("Please select your membership role!");
                return;
            }
            if (userNameSignUp.Text == "Username*" || userNameSignUp.Text == "")
            {
                CustomMsgBox.Show("Please fill the required (*) fields!");
                return;
            }
            if (passwordSignUp.Text == "Password*" || passwordSignUp.Text == "")
            {
                CustomMsgBox.Show("Please fill the required (*) fields!");
                return;
            }
            string lname = lName.Text, fname = fName.Text, location = locationTB.Text, cc = creditCard.Text, vehicle = vehicleTB.Text;

            if (lname == "Last Name")
            {
                lname = null;
            }
            if (fname == "First Name")
            {
                fname = null;
            }
            if (location == "Location")
            {
                location = null;
            }
            if (cc == "Credit Card")
            {
                cc = null;
            }
            if (vehicle == "Vehicle")
            {
                vehicle = "no vehicle";
            }
            OracleCommand cmd = new OracleCommand("sign_up", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("nusername", userNameSignUp.Text);
            cmd.Parameters.Add("npassword", passwordSignUp.Text);
            int nrole;

            if (customerChkBx.Checked)
            {
                nrole = 1;
            }
            else
            {
                nrole = 2;
            }
            cmd.Parameters.Add("nrole", nrole);
            cmd.Parameters.Add("done", OracleDbType.Int32, ParameterDirection.Output);
            cmd.Parameters.Add("nfname", fname);
            cmd.Parameters.Add("nlname", lname);
            cmd.Parameters.Add("nlocation", location);
            cmd.Parameters.Add("ncredit_no", cc);
            cmd.Parameters.Add("nvehicle", vehicle);
            cmd.ExecuteNonQuery();
            int done = Convert.ToInt32(cmd.Parameters["done"].Value.ToString());

            if (done == 0)
            {
                #region create cart
                if (customerChkBx.Checked)
                {
                    cmd             = new OracleCommand("Create_Cart", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("un", userNameSignUp.Text);
                    cmd.ExecuteNonQuery();
                }
                #endregion
                CustomMsgBox.Show("This user has been added!");
                customerChkBx.Checked    = partnerChkBx.Checked = false;
                vehicleTB.Enabled        = false;
                userNameSignIn.Text      = userNameSignUp.Text;
                userNameSignIn.ForeColor = Color.Black;
                userNameSignUp.Text      = "Username*";
                passwordSignUp.Text      = "Password*";
                fName.Text          = "First Name";
                lName.Text          = "Last Name";
                creditCard.Text     = "Credit Card";
                locationTB.Text     = "Location";
                vehicleTB.Text      = "Vehicle";
                vehicleTB.ForeColor = Color.DarkGray;
                fName.ForeColor     = lName.ForeColor = creditCard.ForeColor = locationTB.ForeColor = userNameSignUp.ForeColor = passwordSignUp.ForeColor = Color.DarkGray;
            }
            else
            {
                CustomMsgBox.Show("This username is already taken!");
            }
        }
        private void saveUserNameBtn_Click(object sender, EventArgs e)
        {
            int  tmp_ind = 0;
            bool found   = false;

            while (tmp_ind < ds.Tables["partner"].Rows.Count)
            {
                if (ds.Tables["partner"].Rows[tmp_ind][0].ToString() == userName.Text && tmp_ind != index)
                {
                    found = true;
                    break;
                }
                tmp_ind++;
            }
            if (found == true)
            {
                CustomMsgBox.Show("Username already taken.");
            }
            else
            {
                if (userName.Text != Helper.currentUserName)
                {
                    DataRow r = ds.Tables["partner"].NewRow();
                    r[0] = userName.Text;
                    r[1] = part_vehicle;
                    r[2] = part_pass;
                    r[3] = rating;
                    ds.Tables[0].Rows.Add(r);
                    builder = new OracleCommandBuilder(adapter);
                    adapter.Update(ds.Tables[0]);

                    int row_num = 0;
                    while (row_num < ds.Tables["trip"].Rows.Count)
                    {
                        if (ds.Tables["trip"].Rows[row_num][2].ToString() == Helper.currentUserName)
                        {
                            ds.Tables["trip"].Rows[row_num][2] = userName.Text;
                            builder = new OracleCommandBuilder(adapter1);
                            adapter1.Update(ds.Tables["trip"]);
                        }
                        row_num++;
                    }

                    int tmp = 0;
                    while (tmp < ds.Tables["partner"].Rows.Count)
                    {
                        if (ds.Tables["partner"].Rows[tmp][0].ToString() == Helper.currentUserName)
                        {
                            ds.Tables["partner"].Rows[tmp].Delete();
                            builder = new OracleCommandBuilder(adapter);
                            adapter.Update(ds.Tables["partner"]);
                            break;
                        }
                        tmp++;
                    }

                    Helper.currentUserName = userName.Text;
                    index = 0;
                    while (index < ds.Tables["partner"].Rows.Count)
                    {
                        if (ds.Tables["partner"].Rows[index][0].ToString() == Helper.currentUserName)
                        {
                            break;
                        }
                        index++;
                    }
                    CustomMsgBox.Show("Username is changed successfully.");
                }
                else
                {
                    CustomMsgBox.Show("This is your old username. So nothing has changed");
                }
            }

            saveUserNameBtn.Hide();
            userName.Enabled = false;
        }
Ejemplo n.º 19
0
        private void saveUserNameBtn_Click(object sender, EventArgs e)
        {
            OracleCommand cmd = new OracleCommand();

            cmd.Connection  = con;
            cmd.CommandText = "select * from customer";
            cmd.CommandType = CommandType.Text;
            OracleDataReader rdr = cmd.ExecuteReader();
            int  tmp_ind         = 0;
            bool found           = false;

            while (rdr.Read())
            {
                if (rdr[0].ToString() == userName.Text && tmp_ind != index)
                {
                    found = true;
                    break;
                }
                tmp_ind++;
            }
            if (found == true)
            {
                CustomMsgBox.Show("Username already taken.");
            }
            else
            {
                if (userName.Text != Helper.currentUserName)
                {
                    cmd             = new OracleCommand();
                    cmd.Connection  = con;
                    cmd.CommandText = "insert into customer values(:uname, :fname, :lname, :loc, :credit, :pass)";
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("uname", userName.Text);
                    cmd.Parameters.Add("fname", cust_fname);
                    cmd.Parameters.Add("lname", cust_lname);
                    cmd.Parameters.Add("loc", cust_loc);
                    cmd.Parameters.Add("credit", cust_credit);
                    cmd.Parameters.Add("pass", cust_pass);
                    cmd.ExecuteNonQuery();

                    OracleCommand cmd3 = new OracleCommand();
                    cmd3.Connection  = con;
                    cmd3.CommandText = "update orders set customer_username=:newd where customer_username=:oldd";
                    cmd3.CommandType = CommandType.Text;
                    cmd3.Parameters.Add("newd", userName.Text);
                    cmd3.Parameters.Add("oldd", Helper.currentUserName);
                    cmd3.ExecuteNonQuery();

                    OracleCommand cmd2 = new OracleCommand();
                    cmd2.Connection  = con;
                    cmd2.CommandText = "delete from customer where username=:del";
                    cmd2.CommandType = CommandType.Text;
                    cmd2.Parameters.Add("del", Helper.currentUserName);
                    cmd2.ExecuteNonQuery();

                    Helper.currentUserName = userName.Text;
                }
                CustomMsgBox.Show("Username changed successfully.");
            }
            saveUserNameBtn.Hide();
            userName.Enabled = false;
        }
Ejemplo n.º 20
0
 private void passwordSignIn_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (userNameSignIn.Text.ToLower() == "admin" && passwordSignIn.Text == "123")
         {
             adminForm af = new adminForm();
             af.Show();
             this.Hide();
             af.FormClosing += letsShow;
             return;
         }
         if (!customerChkBxSignIn.Checked && !partnerChkBxSignIn.Checked)
         {
             CustomMsgBox.Show("Please select your membership role!");
             return;
         }
         if (userNameSignIn.Text == "Username*" || userNameSignIn.Text == "")
         {
             CustomMsgBox.Show("Please fill the Username field");
             return;
         }
         if (passwordSignIn.Text == "Password*" || passwordSignIn.Text == "")
         {
             CustomMsgBox.Show("Please fill the Password field");
             return;
         }
         if (customerChkBxSignIn.Checked)
         {
             OracleCommand cmd = new OracleCommand("select count(USERNAME) from customer where USERNAME = :name and PASSWORD = :pass", con);
             cmd.Parameters.Add("name", userNameSignIn.Text);
             cmd.Parameters.Add("pass", passwordSignIn.Text);
             int cnt = Convert.ToInt32(cmd.ExecuteScalar());
             if (cnt > 0)
             {
                 Helper.currentUserName = userNameSignIn.Text;
                 Helper.currentUserRole = 1;
                 mainform = new MainForm();
                 mainform.Show();
                 this.Hide();
                 mainform.FormClosing += letsShow;
             }
             else
             {
                 CustomMsgBox.Show("check your username and password!");
             }
         }
         else
         {
             OracleCommand cmd = new OracleCommand("select count(USERNAME) from DELIVERY_PARTNER where USERNAME = :name and PASSWORD = :pass", con);
             cmd.Parameters.Add("name", userNameSignIn.Text);
             cmd.Parameters.Add("pass", passwordSignIn.Text);
             int cnt = Convert.ToInt32(cmd.ExecuteScalar());
             if (cnt > 0)
             {
                 Helper.currentUserName = userNameSignIn.Text;
                 Helper.currentUserRole = 2;
                 mainform = new MainForm();
                 mainform.Show();
                 this.Hide();
                 mainform.FormClosing += letsShow;
             }
             else
             {
                 CustomMsgBox.Show("check your username and password!");
             }
         }
     }
 }