Esempio n. 1
0
        private void Populate_Dropdwown()
        {
            DataTable subjects = new DataTable();


            using (SqlConnection con = DB_helper.GetConnection())
            {
                try
                {
                    SqlDataAdapter adapter = new SqlDataAdapter("SELECT pid, location FROM Port", con);
                    adapter.Fill(subjects);

                    portdp.DataSource     = subjects;
                    portdp.DataTextField  = "location";
                    portdp.DataValueField = "pid";
                    portdp.DataBind();

                    cont1.Visible = false;
                    cont2.Visible = true;
                }
                catch (Exception ex)
                {
                    // Handle the error
                }
            }
        }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Userses"] != null)
     {
         CustomerClass customer = (CustomerClass)Session["Userses"];
         uid = customer.id;
         SqlConnection con = DB_helper.GetConnection();
         con.Open();
         String     cquery  = "SELECT * from Staff Where sid = '" + uid + "'";
         SqlCommand command = new SqlCommand(cquery, con);
         using (SqlDataReader reader = command.ExecuteReader())
         {
             if (reader.Read())
             {
                 port = String.Format("{0}", reader["portID"]);
             }
         }
         BindShipment(port);
         con.Close();
     }
     else
     {
         Response.Redirect("~/Default.aspx");
     }
 }
Esempio n. 3
0
        protected void Log_Click(object sender, EventArgs e)
        {
            SqlConnection con = DB_helper.GetConnection();

            con.Open();
            String guid = System.Guid.NewGuid().ToString();

            if (Session["ship"] == null)
            {
                try
                {
                    String query2 = "INSERT INTO Shipment (shipID, arPID, depPID, statusAP, statusAR, customerID, details, date) " +
                                    "values(@shipID, @arPID, @depPID, @statusAP, @statusAR, @customerID, @details, @date)";

                    SqlCommand cmd2 = new SqlCommand(query2, con);
                    cmd2.Parameters.AddWithValue("@shipID", guid);
                    cmd2.Parameters.AddWithValue("@arPID", portar.SelectedValue);
                    cmd2.Parameters.AddWithValue("@depPID", portdp.SelectedValue);
                    cmd2.Parameters.AddWithValue("@statusAP", "In Progress");
                    cmd2.Parameters.AddWithValue("@statusAR", "Not Arrived");
                    cmd2.Parameters.AddWithValue("@CustomerID", uid);
                    cmd2.Parameters.AddWithValue("@details", description.Value);
                    cmd2.Parameters.AddWithValue("@date", datepicker.Value);
                    cmd2.ExecuteNonQuery();
                    con.Close();
                    Response.Redirect("CustomerHome.aspx");
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.ToString());
                }
            }
            else
            {
                try
                {
                    String query2 = "UPDATE Shipment SET arPID = @arPID, depPID = @depPID, details = @details, date = @date " +
                                    "WHERE shipID = @shipID";

                    SqlCommand cmd2 = new SqlCommand(query2, con);
                    cmd2.Parameters.AddWithValue("@shipID", Session["ship"].ToString());
                    cmd2.Parameters.AddWithValue("@arPID", portar.SelectedValue);
                    cmd2.Parameters.AddWithValue("@depPID", portdp.SelectedValue);
                    cmd2.Parameters.AddWithValue("@details", description.Value);
                    cmd2.Parameters.AddWithValue("@date", datepicker.Value);
                    cmd2.ExecuteNonQuery();
                    con.Close();
                    Session["ship"] = null;
                    Response.Redirect("CustomerHome.aspx");
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.ToString() + "TTTTTTTT" + uid + "TTTTTTTT" + portar.SelectedValue);
                }
            }
        }
Esempio n. 4
0
        private void BindStaff()
        {
            SqlConnection con = DB_helper.GetConnection();

            con.Open();
            String     cquery    = "SELECT * FROM Staff";
            SqlCommand ccmd      = new SqlCommand(cquery, con);
            DataTable  dataTable = new DataTable();

            CRepeater.DataSource = ccmd.ExecuteReader();
            CRepeater.DataBind();
            con.Close();
        }
Esempio n. 5
0
        private void BindShipment()
        {
            SqlConnection con = DB_helper.GetConnection();

            con.Open();
            String     cquery    = "SELECT * FROM Shipment WHERE customerID = '" + uid + "'";
            SqlCommand ccmd      = new SqlCommand(cquery, con);
            DataTable  dataTable = new DataTable();

            CRepeater.DataSource = ccmd.ExecuteReader();
            CRepeater.DataBind();
            con.Close();
        }
Esempio n. 6
0
        protected void Register_Click(object sender, EventArgs e)
        {
            SqlConnection con = DB_helper.GetConnection();

            con.Open();
            String     cquery = "SELECT COUNT(*) FROM Users WHERE email='" + email.Value + "'";
            SqlCommand ccmd   = new SqlCommand(cquery, con);
            int        temp   = Convert.ToInt32(ccmd.ExecuteScalar().ToString());

            if (temp == 1)
            {
                Response.Write("User already exists");
            }
            else
            {
                String guid = System.Guid.NewGuid().ToString();
                try
                {
                    String query = "INSERT INTO Staff (sid, portID, contact, name, email) " +
                                   "values(@ID, @Port, @Contact, @Name, @Email)";

                    String query2 = "INSERT INTO Users (uid, email, password, userrole) values(@uid, @Email, @Password, @Role)";

                    SqlCommand cmd2 = new SqlCommand(query2, con);
                    cmd2.Parameters.AddWithValue("@uid", guid);
                    cmd2.Parameters.AddWithValue("@Email", email.Value);
                    cmd2.Parameters.AddWithValue("@Password", password.Value);
                    cmd2.Parameters.AddWithValue("@Role", "Staff");
                    cmd2.ExecuteNonQuery();

                    SqlCommand cmd = new SqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@ID", guid);
                    cmd.Parameters.AddWithValue("@Port", portdp.SelectedValue);
                    cmd.Parameters.AddWithValue("@Contact", contact.Value);
                    cmd.Parameters.AddWithValue("@Name", name.Value);
                    cmd.Parameters.AddWithValue("@Email", email.Value);

                    cmd.ExecuteNonQuery();
                    Response.Redirect("~/Admin/AdminStaff.aspx");
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.ToString());
                }
            }
        }
Esempio n. 7
0
 protected void Delete(object sender, CommandEventArgs e)
 {
     try
     {
         SqlConnection con = DB_helper.GetConnection();
         con.Open();
         string     query = "DELETE FROM Port WHERE pid = @pid";
         SqlCommand cmd   = new SqlCommand(query, con);
         cmd.Parameters.AddWithValue("@pid", e.CommandArgument.ToString());
         cmd.ExecuteNonQuery();
         con.Close();
         Response.Redirect("AdminPort.aspx");
     }
     catch (Exception ex)
     {
         Response.Write("ErrorL  " + ex.ToString());
     }
 }
Esempio n. 8
0
 protected void Decline(object sender, CommandEventArgs e)
 {
     try
     {
         SqlConnection con = DB_helper.GetConnection();
         con.Open();
         string     query = "UPDATE Shipment SET statusAP = @ap WHERE shipID = @id";
         SqlCommand cmd   = new SqlCommand(query, con);
         cmd.Parameters.AddWithValue("@id", e.CommandArgument.ToString());
         cmd.Parameters.AddWithValue("@ap", "Declined");
         cmd.ExecuteNonQuery();
         con.Close();
         Response.Redirect("StaffHome.aspx");
     }
     catch (Exception ex)
     {
         Response.Write("ErrorL  " + ex.ToString());
     }
 }
Esempio n. 9
0
        private void Populate_Edit()
        {
            SqlConnection con = DB_helper.GetConnection();

            con.Open();
            String     cquery  = "SELECT * from Shipment Where shipID = '" + shid + "'";
            SqlCommand command = new SqlCommand(cquery, con);

            using (SqlDataReader reader = command.ExecuteReader())
            {
                if (reader.Read())
                {
                    datepicker.Value     = String.Format("{0}", reader["date"]);
                    portar.SelectedValue = String.Format("{0}", reader["arPID"]);
                    portdp.SelectedValue = String.Format("{0}", reader["depPID"]);
                    description.Value    = String.Format("{0}", reader["details"]);
                }
            }
            con.Close();
        }
Esempio n. 10
0
        private void BindShipment(String portID)
        {
            SqlConnection con = DB_helper.GetConnection();

            con.Open();
            String     query  = "SELECT * FROM Shipment, Port WHERE pid = depPID AND arPID = '" + portID + "' AND statusAP = 'Approved' AND statusAR != 'Delivered'";
            String     cquery = "SELECT * FROM Shipment, Port WHERE pid = arPID AND depPID = '" + portID + "' AND statusAP != 'Approved'";
            SqlCommand ccmd   = new SqlCommand(cquery, con);

            CRepeater.DataSource = ccmd.ExecuteReader();
            CRepeater.DataBind();
            con.Close();

            SqlConnection con2 = DB_helper.GetConnection();

            con2.Open();
            SqlCommand ccmd2 = new SqlCommand(query, con2);

            CRepeater2.DataSource = ccmd2.ExecuteReader();
            CRepeater2.DataBind();
            con.Close();
        }
Esempio n. 11
0
        protected void Register_Click(object sender, EventArgs e)
        {
            SqlConnection con = DB_helper.GetConnection();

            con.Open();

            String guid = System.Guid.NewGuid().ToString();

            try
            {
                String query2 = "INSERT INTO Port (pid, name, location) values(@pid, @name, @location)";

                SqlCommand cmd2 = new SqlCommand(query2, con);
                cmd2.Parameters.AddWithValue("@pid", guid);
                cmd2.Parameters.AddWithValue("@name", email.Value);
                cmd2.Parameters.AddWithValue("@location", password.Value);
                cmd2.ExecuteNonQuery();
                Response.Redirect("AdminPort.aspx");
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.ToString());
            }
        }