Ejemplo n.º 1
0
        protected void DdlOficinasRegiao_SelectedIndexChanged(object sender, EventArgs e)
        {
            string proc = "GetWorkshopsInRegionExceptSelf";

            if (DdlOficinasRegiao.SelectedValue == "0")
            {
                LbOficinas.Items.Clear(); return;
            }
            if (DdlOficinasRegiao.SelectedValue == "Total")
            {
                proc = "GetWorkshopNames";
            }

            SqlConnection  con = GetSqlCon.GetCon();
            SqlDataAdapter com = new SqlDataAdapter(proc, con);

            com.SelectCommand.CommandType = CommandType.StoredProcedure;
            com.SelectCommand.Parameters.AddWithValue("@param1", User.Identity.GetUserId());
            com.SelectCommand.Parameters.AddWithValue("@param2", DdlOficinasRegiao.SelectedValue);
            DataSet ds1 = new DataSet();

            if (com != null)
            {
                com.Fill(ds1);
            }
            con.Open();
            LbOficinas.DataSource     = ds1;
            LbOficinas.DataTextField  = "WorkshopName";
            LbOficinas.DataValueField = "WorkshopName";
            LbOficinas.DataBind();
            con.Close();
        }
Ejemplo n.º 2
0
        protected void GetWorkshopDetails(string workshopname)
        {
            SqlConnection  con = GetSqlCon.GetCon();
            SqlDataAdapter com = new SqlDataAdapter("GetWorkshopDetails", con);

            com.SelectCommand.CommandType = CommandType.StoredProcedure;
            com.SelectCommand.Parameters.AddWithValue("@param1", workshopname);
            DataTable dtWorkshops = new DataTable();

            com.Fill(dtWorkshops);
            DescOficina.DataSource = dtWorkshops;
            DescOficina.DataBind();

            //rating
            double rating   = Commissions.GetAvgRating(Users.GetWorkshopId(workshopname));
            Label  ratinglb = DescOficina.FindControl("ratinglabel") as Label;

            if (rating == -1)
            {
                ratinglb.Text = "Sem Avaliação";
            }
            else
            {
                ratinglb.Text = rating.ToString() + "/5" + "&#9733";
            }
        }
Ejemplo n.º 3
0
        protected int populate_DDL()
        {
            int            val;
            SqlConnection  con = GetSqlCon.GetCon();
            SqlDataAdapter com = new SqlDataAdapter("GetWorkshopNamesByRegion", con);

            com.SelectCommand.CommandType = CommandType.StoredProcedure;
            com.SelectCommand.Parameters.AddWithValue("@param1", DdlRegiao.SelectedValue);
            DataSet ds1 = new DataSet();

            if (com != null)
            {
                com.Fill(ds1);
            }
            con.Open();
            DdlOficinas.DataSource     = ds1;
            DdlOficinas.DataTextField  = "WorkshopName";
            DdlOficinas.DataValueField = "WorkshopName";
            DdlOficinas.DataBind();
            con.Close();

            val = Badges.CountWorkshopsInRegion(DdlRegiao.SelectedValue);
            if (val == -1)
            {
                Response.Redirect("~/Error.aspx");
            }
            return(val);
        }
Ejemplo n.º 4
0
        protected void Populate_Details(int groupno)
        {
            string        storedprocedure = "GetComissionDetails";
            SqlConnection cn = GetSqlCon.GetCon();

            if (cn == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt  = new DataTable();
            SqlCommand cmd = new SqlCommand(storedprocedure, cn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@param1", groupno);
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            GridViewGroupDetails.DataSource = dt;
            GridViewGroupDetails.DataBind();
            cn.Close();
            GridViewGroupDetails.Visible = true;

            foreach (GridViewRow row in GridViewGroupDetails.Rows)
            {
                int id, price;
                int.TryParse(row.Cells[0].Text, out id);
                price = Commissions.GetPrice(id);
                Label LabelPrice = row.FindControl("LabelPrice") as Label;
                if (price != 0)
                {
                    LabelPrice.Text = price.ToString();
                }
                else
                {
                    Button BtnAcceptComission = row.FindControl("BtnAcceptComission") as Button;
                    Button BtnRejectComission = row.FindControl("BtnRejectComission") as Button;
                    BtnAcceptComission.Visible = false;
                    BtnRejectComission.Visible = false;
                    LabelPrice.Text            = "N/A";
                }
            }
        }
Ejemplo n.º 5
0
        protected void PopulateGridViews()
        {
            //-----Client------//

            ApplicationDbContext context = new ApplicationDbContext();
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var user        = UserManager.FindById(User.Identity.GetUserId());

            //Active
            string        storedprocedure = "GetActiveComissions";
            SqlConnection cn = GetSqlCon.GetCon();

            if (cn == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt  = new DataTable();
            SqlCommand cmd = new SqlCommand(storedprocedure, cn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            GridViewActiveComissions.DataSource = dt;
            GridViewActiveComissions.DataBind();
            cn.Close();

            //Pending - Singles
            string        storedprocedure2 = "GetPendingComissions";
            SqlConnection cn2 = GetSqlCon.GetCon();

            if (cn2 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt2  = new DataTable();
            SqlCommand cmd2 = new SqlCommand(storedprocedure2, cn2);

            cmd2.CommandType = System.Data.CommandType.StoredProcedure;
            cmd2.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);

            da2.Fill(dt2);
            GridViewComissionsPending.DataSource = dt2;
            GridViewComissionsPending.DataBind();
            cn2.Close();

            //Pending - Group
            string        storedprocedure8 = "GetPendingGroupComissions";
            SqlConnection cn8 = GetSqlCon.GetCon();

            if (cn8 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt8  = new DataTable();
            SqlCommand cmd8 = new SqlCommand(storedprocedure8, cn8);

            cmd8.CommandType = System.Data.CommandType.StoredProcedure;
            cmd8.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da8 = new SqlDataAdapter(cmd8);

            da8.Fill(dt8);
            GridViewGroupComissions.DataSource = dt8;
            GridViewGroupComissions.DataBind();
            cn8.Close();

            //History
            string        storedprocedure3 = "HistoryOfcomissions";
            SqlConnection cn3 = GetSqlCon.GetCon();

            if (cn3 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt3  = new DataTable();
            SqlCommand cmd3 = new SqlCommand(storedprocedure3, cn3);

            cmd3.CommandType = System.Data.CommandType.StoredProcedure;
            cmd3.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da3 = new SqlDataAdapter(cmd3);

            da3.Fill(dt3);
            HistoryOfComissions.DataSource = dt3;
            HistoryOfComissions.DataBind();
            cn3.Close();


            //-----Workshop-----//

            //Active
            string        storedprocedure4 = "GetActiveComissionsWorkshop";
            SqlConnection cn4 = GetSqlCon.GetCon();

            if (cn4 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt4  = new DataTable();
            SqlCommand cmd4 = new SqlCommand(storedprocedure4, cn4);

            cmd4.CommandType = System.Data.CommandType.StoredProcedure;
            cmd4.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da4 = new SqlDataAdapter(cmd4);

            da4.Fill(dt4);
            ActiveComissions.DataSource = dt4;
            ActiveComissions.DataBind();

            //Pending
            string        storedprocedure5 = "GetPendingComissionsWorkshop";
            SqlConnection cn5 = GetSqlCon.GetCon();

            if (cn5 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt5  = new DataTable();
            SqlCommand cmd5 = new SqlCommand(storedprocedure5, cn5);

            cmd5.CommandType = System.Data.CommandType.StoredProcedure;
            cmd5.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da5 = new SqlDataAdapter(cmd5);

            da5.Fill(dt5);
            PendingComissions.DataSource = dt5;
            PendingComissions.DataBind();

            //History
            string        storedprocedure6 = "GetHistoryOfComissionsWorkshop";
            SqlConnection cn6 = GetSqlCon.GetCon();

            if (cn6 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt6  = new DataTable();
            SqlCommand cmd6 = new SqlCommand(storedprocedure6, cn6);

            cmd6.CommandType = System.Data.CommandType.StoredProcedure;
            cmd6.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da6 = new SqlDataAdapter(cmd6);

            da6.Fill(dt6);
            HistoryOfComissionsWorkshop.DataSource = dt6;
            HistoryOfComissionsWorkshop.DataBind();

            //Clients
            string        storedprocedure7 = "GetWorkshopClients";
            SqlConnection cn7 = GetSqlCon.GetCon();

            if (cn7 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt7  = new DataTable();
            SqlCommand cmd7 = new SqlCommand(storedprocedure7, cn7);

            cmd7.CommandType = System.Data.CommandType.StoredProcedure;
            cmd7.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da7 = new SqlDataAdapter(cmd7);

            da7.Fill(dt7);
            Clientes.DataSource = dt7;
            Clientes.DataBind();
        }
Ejemplo n.º 6
0
        protected void PopulateGridViews()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var user        = UserManager.FindById(User.Identity.GetUserId());

            //Active
            string        storedprocedure = "GetActiveComissionsWorkshop";
            SqlConnection cn = GetSqlCon.GetCon();

            if (cn == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt  = new DataTable();
            SqlCommand cmd = new SqlCommand(storedprocedure, cn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            ActiveComissions.DataSource = dt;
            ActiveComissions.DataBind();

            //Pending
            string        storedprocedure2 = "GetPendingComissionsWorkshop";
            SqlConnection cn2 = GetSqlCon.GetCon();

            if (cn2 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt2  = new DataTable();
            SqlCommand cmd2 = new SqlCommand(storedprocedure2, cn2);

            cmd2.CommandType = System.Data.CommandType.StoredProcedure;
            cmd2.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);

            da2.Fill(dt2);
            PendingComissions.DataSource = dt2;
            PendingComissions.DataBind();

            //History
            string        storedprocedure3 = "GetHistoryOfComissionsWorkshop";
            SqlConnection cn3 = GetSqlCon.GetCon();

            if (cn3 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt3  = new DataTable();
            SqlCommand cmd3 = new SqlCommand(storedprocedure3, cn3);

            cmd3.CommandType = System.Data.CommandType.StoredProcedure;
            cmd3.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da3 = new SqlDataAdapter(cmd3);

            da3.Fill(dt3);
            HistoryOfComissions.DataSource = dt3;
            HistoryOfComissions.DataBind();

            //Clients
            string        storedprocedure4 = "GetWorkshopClients";
            SqlConnection cn4 = GetSqlCon.GetCon();

            if (cn4 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt4  = new DataTable();
            SqlCommand cmd4 = new SqlCommand(storedprocedure4, cn4);

            cmd4.CommandType = System.Data.CommandType.StoredProcedure;
            cmd4.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da4 = new SqlDataAdapter(cmd4);

            da4.Fill(dt4);
            Clientes.DataSource = dt4;
            Clientes.DataBind();
        }
Ejemplo n.º 7
0
        protected void PopulateGridViews()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var user        = UserManager.FindById(User.Identity.GetUserId());

            //Active
            string        storedprocedure = "GetActiveComissions";
            SqlConnection cn = GetSqlCon.GetCon();

            if (cn == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt  = new DataTable();
            SqlCommand cmd = new SqlCommand(storedprocedure, cn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            GridViewActiveComissions.DataSource = dt;
            GridViewActiveComissions.DataBind();
            cn.Close();

            //Pending - Singles
            string        storedprocedure2 = "GetPendingComissions";
            SqlConnection cn2 = GetSqlCon.GetCon();

            if (cn2 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt2  = new DataTable();
            SqlCommand cmd2 = new SqlCommand(storedprocedure2, cn2);

            cmd2.CommandType = System.Data.CommandType.StoredProcedure;
            cmd2.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);

            da2.Fill(dt2);
            GridViewComissionsPending.DataSource = dt2;
            GridViewComissionsPending.DataBind();
            cn2.Close();

            //Pending - Group
            string        storedprocedure8 = "GetPendingGroupComissions";
            SqlConnection cn8 = GetSqlCon.GetCon();

            if (cn8 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt8  = new DataTable();
            SqlCommand cmd8 = new SqlCommand(storedprocedure8, cn8);

            cmd8.CommandType = System.Data.CommandType.StoredProcedure;
            cmd8.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da8 = new SqlDataAdapter(cmd8);

            da8.Fill(dt8);
            GridViewGroupComissions.DataSource = dt8;
            GridViewGroupComissions.DataBind();
            cn8.Close();

            //History
            string        storedprocedure3 = "HistoryOfcomissions";
            SqlConnection cn3 = GetSqlCon.GetCon();

            if (cn3 == null)
            {
                Response.Redirect("~/Error.aspx");
            }

            DataTable  dt3  = new DataTable();
            SqlCommand cmd3 = new SqlCommand(storedprocedure3, cn3);

            cmd3.CommandType = System.Data.CommandType.StoredProcedure;
            cmd3.Parameters.AddWithValue("@param1", user.Id);
            SqlDataAdapter da3 = new SqlDataAdapter(cmd3);

            da3.Fill(dt3);
            HistoryOfComissions.DataSource = dt3;
            HistoryOfComissions.DataBind();
            cn3.Close();
        }