コード例 #1
0
ファイル: RegisterUser.cs プロジェクト: yprocks/GameAddict
    public bool AddUser(string name, string email, string password)
    {
        try {
            c1 = con1.GetConnection();

            string str = "insert into [User] (name, email, password, isactive, isadmin) values ('" + name + "', '" + email + "', '" + password + "', 1, 0); SELECT NEWID = SCOPE_IDENTITY()";


            SqlCommand cmd = new SqlCommand(str, c1);
            c1.Open();
            var id = cmd.ExecuteScalar();
            SetID(Convert.ToInt32(id));
            System.Diagnostics.Debug.WriteLine(id);
            c1.Close();


            c2 = con1.GetConnection();

            string str1 = "insert into [UserDetails] (userid) values ( " + GetID() + " )";


            SqlCommand cmd1 = new SqlCommand(str1, c2);
            c2.Open();
            cmd1.ExecuteNonQuery();
            c2.Close();
        }
        catch (SqlException e)
        {
            return(false);
        }

        return(true);
    }
コード例 #2
0
ファイル: UpdateUser.cs プロジェクト: yprocks/GameAddict
    public void UpdateUserProfile(int u_id, string address, string city, string state, string zipcode, string telephone, string email, string name)
    {
        c1 = con1.GetConnection();

        string str = "update userdetails set address = '" + address + "', city = '" + city + "', province = '" + state + "', postalcode = '" + zipcode + "' , phone = '" + telephone + "' where userid = " + u_id;

        SqlCommand cmd = new SqlCommand(str, c1);

        c1.Open();
        cmd.ExecuteNonQuery();

        c1.Close();


        c2 = con1.GetConnection();

        string str1 = "update [user] set name = '" + name + "', email = '" + email + "' where userid = " + u_id;

        SqlCommand cmd1 = new SqlCommand(str1, c2);

        c2.Open();
        cmd1.ExecuteNonQuery();

        c2.Close();
    }
コード例 #3
0
    public void AddToReview(int u_id, int g_id, int rating, string review)
    {
        c2 = con2.GetConnection();
        string getCart = "Select reviewid from [review] where userid = " + u_id + " and gameid = " + g_id;

        SqlCommand cmd1 = new SqlCommand(getCart, c2);

        c2.Open();
        SqlDataReader reader = cmd1.ExecuteReader();

        if (reader.HasRows)
        {
            /*while (reader.Read())
             * {
             *  break;
             * }*/

            Exist = true;
        }
        else
        {
            Exist = false;
        }



        c2.Close();

        if (!Exist)
        {
            c1 = con1.GetConnection();

            string str = "insert into Review (UserID, GameID, review, rating, isActive) values (" + u_id + ",+" + g_id + ", '" + review + "', " + rating + ", 1)";

            SqlCommand cmd = new SqlCommand(str, c1);
            c1.Open();
            cmd.ExecuteNonQuery();

            c1.Close();
        }
        else
        {
            c1 = con1.GetConnection();

            string str = "update review set review = '" + review + "', rating = " + rating + " where userid = " + u_id + " and gameid = " + g_id;

            SqlCommand cmd = new SqlCommand(str, c1);
            c1.Open();
            cmd.ExecuteNonQuery();

            c1.Close();
        }


        UpdateGames(g_id);
    }
コード例 #4
0
ファイル: DeleteWishlist.cs プロジェクト: yprocks/GameAddict
    public void DeleteItem(int u_id, int c_id)
    {
        c1 = con1.GetConnection();

        string str = "Delete from wishlist where userid = " + u_id + " and wishlistid = " + c_id;

        SqlCommand cmd = new SqlCommand(str, c1);

        c1.Open();
        cmd.ExecuteNonQuery();

        c1.Close();
    }
コード例 #5
0
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            DataRowView drv = this.questionnaireOriginBindingSource.Current as DataRowView;

            if (drv == null)
            {
                return;
            }

            int originid = (int)drv["OriginNo"];

            try
            {
                if (!Questionnaire.HasRelatedOrigin(MyConnection.GetConnection(), originid))
                {
                    drv.Delete();
                }
                else
                {
                    throw new Exception("Questions related to this questionnaire were detected.");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("Deletion failed " + e1.Message);
            }
        }
コード例 #6
0
ファイル: Wishlist.aspx.cs プロジェクト: yprocks/GameAddict
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userid"] == null)
            Response.Redirect("~/Login.aspx");

        Session.Add("url","Wishlist.aspx");
        dw = new DeleteWishlist();

        string userstr = "SELECT * from wishlist where userid = "+ Convert.ToInt16(Session["userid"]);

        con = new MyConnection();
        c1 = con.GetConnection();
        SqlCommand cmd = new SqlCommand(userstr, c1);
        c1.Open();
        SqlDataReader reader = cmd.ExecuteReader();
        if (reader.HasRows)
        {

            isWishlistEmpty = false;

        }
        else
        {
            isWishlistEmpty = true;
        }

        c1.Close();
    }
コード例 #7
0
 private void FormVettingComments_Load(object sender, EventArgs e)
 {
     vi       = new VettingInfo();
     vi.VetId = this.m_vetid;
     vi.SelectByVetId(MyConnection.GetConnection(), this.m_vetid);
     this.tb_comments.Text = vi.Comments;
 }
コード例 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userid"] == null)
        {
            Response.Redirect("~/Login.aspx");
        }

        Session.Add("url", "Wishlist.aspx");
        dw = new DeleteWishlist();

        string userstr = "SELECT * from wishlist where userid = " + Convert.ToInt16(Session["userid"]);

        con = new MyConnection();
        c1  = con.GetConnection();
        SqlCommand cmd = new SqlCommand(userstr, c1);

        c1.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.HasRows)
        {
            isWishlistEmpty = false;
        }
        else
        {
            isWishlistEmpty = true;
        }



        c1.Close();
    }
コード例 #9
0
        private void PrepareBindingSources()
        {
            bs_vessels = new BindingSource();
            DataTable tbl_vessels = new DataTable();

            Vessel.FillVesselTable(MyConnection.GetConnection(), tbl_vessels);
            DataTable tbl_inspectiontypes = null;

            tbl_inspectiontypes                         = Vetting.Vetting.SelectInspectionTypes(MyConnection.GetConnection());
            bs_vessels.DataSource                       = tbl_vessels;
            bs_inspectiontypes                          = new BindingSource();
            bs_inspectiontypes.DataSource               = tbl_inspectiontypes;
            this.dgvcol_InspectionTypeCmb.DataSource    = bs_inspectiontypes;
            this.dgvcol_InspectionTypeCmb.DisplayMember = "InspectionType";

            this.dgvcol_VesselId_cmb.DataSource    = bs_vessels;
            this.dgvcol_VesselId_cmb.DisplayMember = "VesselName";



            /*
             *  DataTable tbl_requests = new DataTable();
             *  tbl_requests.Columns.Add("UserId", typeof(int));
             *  tbl_requests.Columns.Add("ComputerName", typeof(string));
             *
             *  tbl_requests.Columns.Add("UserName", typeof(String));
             *  tbl_requests.Columns.Add("RequestDate", typeof(DateTime));
             *  tbl_requests.Columns.Add("RequestCode", typeof(string));
             *  tbl_requests.Columns.Add("VetRequestId", typeof(int));
             *  tbl_requests.Columns.Add("Granted", typeof(byte));
             *  tbl_requests.Columns.Add("BriefcaseFile", typeof(string));
             */
        }
コード例 #10
0
        private void FormQuestionnaireOrigin_Load(object sender, EventArgs e)
        {
            daQuestionnaireOrigin = Vetting.QuestionnaireOrigin.GetAdapter(MyConnection.GetConnection());
            this.questionnaireOriginBindingSource.DataSource = this.attendance;
            // TODO: This line of code loads data into the 'attendance.QuestionnaireOrigin' table. You can move, or remove it, as needed.
            int num = daQuestionnaireOrigin.Fill(this.attendance.QuestionnaireOrigin);

            this.questionnaireOriginBindingSource.AddingNew += new AddingNewEventHandler(questionnaireOriginBindingSource_AddingNew);
        }
コード例 #11
0
        private void ExportToBriefcaseFile()
        {
            SaveFileDialog sfdlg = new SaveFileDialog();

            sfdlg.Filter = "(briefcase files *.sdf)|*.sdf";
            if (DialogResult.OK == sfdlg.ShowDialog())
            {
                if (this.dataGridViewVIQRegistry.SelectedRows.Count > 0)
                {
                    try
                    {
                        Portable.SaveSchema(sfdlg.FileName, ApplicationInfo.bfpassword);
                    }
                    catch (Exception e2)
                    {
                        MessageBox.Show("Metadata failed to be exported :" + e2.Message);
                        return;
                    }

                    if (!Questionnaire.TransferRegistryInfoToBriefcase(MyConnection.GetConnection(), sfdlg.FileName, ApplicationInfo.bfpassword))
                    {
                        MessageBox.Show("Registry data failed to be transfered.");

                        return;
                    }
                    foreach (DataGridViewRow dgv in this.dataGridViewVIQRegistry.SelectedRows)
                    {
                        var drv = (DataRowView)dgv.DataBoundItem;
                        int qid = (int)drv["Qid"];
                        try
                        {
                            if ((byte)drv["finalized"] != 1)
                            {
                                throw new Exception("not finalized");
                            }
                        }
                        catch (Exception e3)
                        {
                            MessageBox.Show(drv["Qid"].ToString() + " skipped :not finalized");
                            continue;
                        }


                        try
                        {
                            Portable.TransferQuestionnaireTemplate(MyConnection.GetConnection(), qid, sfdlg.FileName, ApplicationInfo.bfpassword);
                        }
                        catch (Exception e2)
                        {
                            MessageBox.Show("Questionnaire export failed :" + e2.Message);
                        }
                    }
                    MessageBox.Show(string.Format("Briefcase file {0} created.", sfdlg.FileName));
                }
            }
        }
コード例 #12
0
        private void Form_QuestionnaireInfo_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'attendance.VIQInfo' table. You can move, or remove it, as needed.
            int rows = Vetting.VIQInfo.Select(MyConnection.GetConnection(), this.attendance.VIQInfo);

            if (ApplicationInfo.ActiveUserMode == ApplicationInfo.UserMode.Administrator)
            {
                this.dataGridViewVIQRegistry.MultiSelect      = true;
                this.dataGridViewVIQRegistry.ContextMenuStrip = this.contextMenuStrip1;
            }
        }
コード例 #13
0
 private void FormBriefcaseVessels_Load(object sender, EventArgs e)
 {
     // TODO: This line of code loads data into the 'attendance_rdbms.Vessel' table. You can move, or remove it, as needed.
     Vessel.FillVesselTable(MyConnection.GetConnection(), this.attendance_rdbms.Vessel);
     try
     {
         Portable.FillVesselTable(this.m_filepath, this.m_password, this.attendance_briefcase.Vessel);
     }
     catch (Exception e1)
     {
         MessageBox.Show(e1.Message);
     }
 }
コード例 #14
0
        private void chb_fleetwise_CheckedChanged(object sender, EventArgs e)
        {
            return; //uncomment to implement

            if (this.chb_fleetwise.Checked)
            {
                this.tbl_negativecategories_fleet.Clear();
                Reporter.FillTableNegativeCategoriesPerFleet(MyConnection.GetConnection(), this.tbl_negativecategories_fleet);
                this.bindingsource_negativecategories_fleet.DataSource = this.DataSet_ReportCritical;
                this.bindingsource_negativecategories_fleet.DataMember = "NegativeCategoriesFleet";

                this.dgview_negative_categories.DataSource = this.bindingsource_negativecategories_fleet;
                //this.dataGridView_Vessels.ClearSelection();
                this.dataGridView_Vessels.BackgroundColor = Color.Black;

                if (!this.DataSet_ReportCritical.Relations.Contains("relNegativeCategoriesObjects"))
                {
                    DataColumn dcCategoryCategoryId = this.tbl_negativecategories_fleet.Columns["CategoryId"];
                    DataColumn dcCategoryVesselId   = this.tbl_negativecategories_fleet.Columns["VesselId"];

                    DataColumn dcObjectsCategoryId = this.DataSet_ReportCritical.NegativeQuestions.Columns["CategoryNewId"];
                    DataColumn dcObjectsVesselId   = this.DataSet_ReportCritical.NegativeQuestions.Columns["VesselId"];

                    //DataColumn []dcCategories=new DataColumn[]{dcCategoryCategoryId,dcCategoryVesselId};
                    //DataColumn []dcObjects=new DataColumn[]{dcObjectsCategoryId,dcObjectsVesselId};

                    DataRelation drCategoryObjects = new DataRelation("relNegativeCategoriesObjects", new DataColumn[] { dcCategoryCategoryId, dcCategoryVesselId }, new DataColumn[] { dcObjectsCategoryId, dcObjectsVesselId });


                    this.DataSet_ReportCritical.Relations.Add(drCategoryObjects);
                    this.bindingsource_negativecategories_fleet_objects.DataSource = this.DataSet_ReportCritical;
                    this.bindingsource_negativecategories_fleet_objects.DataMember = "NegativeCategoriesFleet.relNegativeCategoriesObjects";
                    this.dataGridView_CriticalQuestions.DataSource = this.bindingsource_negativecategories_fleet_objects;
                }
            }
            else
            {
                this.dgview_negative_categories.DataSource = this.bindingsource_negativecategories;

                try
                {
                    this.dataGridView_Vessels.Rows[0].Selected = true;
                }
                catch
                {
                }
                this.dataGridView_Vessels.BackgroundColor = SystemColors.ControlDark;
                this.bindingsource_negativecategories.ResetCurrentItem();
            }
            this.dataGridView_Vessels.Enabled = !this.chb_fleetwise.Checked;
        }
コード例 #15
0
ファイル: AddCart.cs プロジェクト: yprocks/GameAddict
    protected void InsertIntoCart(int u_id, int g_id)
    {
        c1 = con1.GetConnection();

        string str = "  insert into cart (UserID, GamePlatformID, ISACTIVE, quantity) values (" + u_id + "," + g_id + ",1, 1)";


        SqlCommand cmd = new SqlCommand(str, c1);

        c1.Open();
        cmd.ExecuteNonQuery();

        c1.Close();
    }
コード例 #16
0
        private void bt_save_Click(object sender, EventArgs e)
        {
            vi.Comments = this.tb_comments.Text;

            try
            {
                vi.Save(MyConnection.GetConnection());
                MessageBox.Show("Changes committed");
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
        }
コード例 #17
0
        private void bt_Transfer_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count > 0)
            {
                foreach (DataGridViewRow dgv in this.dataGridView1.SelectedRows)
                {
                    var drv = (DataRowView)dgv.DataBoundItem;
                    int qid = (int)drv["Qid"];


                    Portable.TransferQuestionnaireTemplate(MyConnection.GetConnection(), qid, this.m_FilePath, this.m_password);
                }
            }
        }
コード例 #18
0
    protected void GetGameReview()
    {
        c2 = con2.GetConnection();
        string getCart = "Select  rating, review, name, details, image from [Game] where gameid = " + g_id;

        SqlCommand cmd1 = new SqlCommand(getCart, c2);

        c2.Open();
        SqlDataReader reader = cmd1.ExecuteReader();

        if (reader.HasRows)
        {
            while (reader.Read())
            {
                game_rating = Convert.ToInt16(reader.GetInt32(0));
                game_review = Convert.ToInt16(reader.GetInt32(1));
                g_name      = reader.GetString(2).ToString();
                g_details   = reader.GetString(3).ToString();
                image       = reader.GetString(4).ToString();
            }
        }
        c2.Close();
    }
コード例 #19
0
        private void FormInspectionType_Load(object sender, EventArgs e)
        {
            daInspectionType = Vetting.InspectionType.GetAdapter(MyConnection.GetConnection());
            // TODO: This line of code loads data into the 'attendance.InspectionTypes' table. You can move, or remove it, as needed.
            daInspectionType.Fill(this.attendance.InspectionTypes);

            if (ApplicationInfo.ActiveUserMode == ApplicationInfo.UserMode.NormalUser)
            {
                this.InitializeRole(false);
            }
            else
            {
                this.InitializeRole(true);
            }
        }
コード例 #20
0
        private void FormVesselRegistry_Load(object sender, EventArgs e)
        {
            daVessel = Vetting.Vessel.GetAdapter(MyConnection.GetConnection());
            // TODO: This line of code loads data into the 'attendance.Vessel' table. You can move, or remove it, as needed.
            Vetting.Vessel.FillVesselTable(MyConnection.GetConnection(), this.attendance.Vessel);

            if (ApplicationInfo.ActiveUserMode == ApplicationInfo.UserMode.NormalUser)
            {
                this.InitializeRole(false);
            }
            else
            {
                this.InitializeRole(true);
            }
        }
コード例 #21
0
        public async Task <IActionResult> Login(string username, string password)
        {
            // Find and validate the user:
            //Users user = GetUserByUsername(username);
            User          user  = null;
            string        query = "select * from users where username = @Username and password = @Password";
            IDbConnection dbcon = con.GetConnection();

            try
            {
                var rs = await dbcon.QueryAsync <User>(query, new { Username = username, Password = password }).ConfigureAwait(false);

                user = rs.FirstOrDefault();
            }
            catch (Exception ex)
            {
                //_logger.Error(ex.ToString());
            }
            finally
            {
                dbcon.Close();
                dbcon.Dispose();
            }
            if (user == null)
            {
                ModelState.AddModelError("", "Incorrect username or password.");
                return(View());
            }

            // Create the identity
            var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);

            identity.AddClaim(new Claim(ClaimTypes.Name, user.Username));
            identity.AddClaim(new Claim(ClaimTypes.GivenName, user.FullName));
            identity.AddClaim(new Claim(ClaimTypes.Role, user.Role));

            //// Add roles
            //foreach (var role in user.Roles)
            //{
            //    identity.AddClaim(new Claim(ClaimTypes.Role, role));
            //}

            // Sign in
            var principal = new ClaimsPrincipal(identity);
            await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);

            return(RedirectToAction("Index", "Home"));
        }
コード例 #22
0
        private void FormVettingRequest_Load(object sender, EventArgs e)
        {
            bs_vettingrequests = new BindingSource();
            DataTable tbl = Vetting.VettingRequest.Select(MyConnection.GetConnection());

            bs_vettingrequests.DataSource       = tbl;
            bs_vettingrequests.PositionChanged += new EventHandler(bs_vettingrequests_PositionChanged);

            this.dgv_vettingrequest.DataSource = bs_vettingrequests;


            bs_requestShcedule = new BindingSource();
            DataTable tbl_sch = Vetting.VettingRequest.SelectSchedule(MyConnection.GetConnection(), null);

            bs_requestShcedule.DataSource = tbl_sch;
        }
コード例 #23
0
 private void FormObjectContext_Load(object sender, EventArgs e)
 {
     // TODO: This line of code loads data into the 'attendance.VIQInfo' table. You can move, or remove it, as needed.
     if (Questionnaire.FillObjectRelatedTable(MyConnection.GetConnection(), this.m_objectid, this.attendance.VIQInfo) == 0)
     {
         this.splitContainer1.Panel2Collapsed = true;
     }
     if (Vetting.Vetting.FillObjectRelatedTable(MyConnection.GetConnection(), this.m_objectid, -1, this.attendance.ObjectVettingInfo) == 0)
     {
         this.splitContainer1.Panel1Collapsed = true;
     }
     if (this.m_vesselid != -1)
     {
         this.chb_vesselspecific.Visible = true;
         vesselfilter = "Vesselid = " + this.m_vesselid.ToString();
         ApplyFilter(false);
     }
 }
コード例 #24
0
        private void Form_ReportCritical_Load(object sender, EventArgs e)
        {
            Reporter.FillTableVessel(MyConnection.GetConnection(), this.DataSet_ReportCritical.Vessels);
            Reporter.FillTableNegativeQuestions(MyConnection.GetConnection(), this.DataSet_ReportCritical.NegativeQuestions);
            Reporter.FillTableVetting(MyConnection.GetConnection(), this.DataSet_ReportCritical.Vetting);

            /*
             * foreach (DataRow rr in this.DataSet_ReportCritical.NegativeQuestions.Rows)
             * {
             *  if(rr["vesselid"].ToString()=="10")
             *  System.Console.Out.WriteLine(rr["Questioncode"].ToString()+"   "+rr["categoryNewid"].ToString());
             * }
             */


            this.DataSet_ReportCritical.Tables.Add(this.tbl_negativecategories_fleet);

            if (ApplicationInfo.ActiveUserMode == ApplicationInfo.UserMode.Administrator)
            {
                this.chart.Visible         = true;
                this.ChartCategory.Visible = true;
                this.ChartHistory.Visible  = true;
            }

            // WindowsFormsApplication1.CrystalReport_CriticalReport cr=new CrystalReport_CriticalReport();
            // cr.SetDataSource(this.dataSet_ReportCritical1.Vetting as DataTable );
            // cr.Subreports[0].SetDataSource(this.dataSet_ReportCritical1.NegativeQuestions as DataTable);
            // this.crystalReportViewer1.ReportSource = cr;
            this.lb_sig_1.BackColor = MyColors[1]; this.lb_sig_1.BorderStyle = BorderStyle.None;
            this.lb_sig_2.BackColor = MyColors[2]; this.lb_sig_2.BorderStyle = BorderStyle.None;
            this.lb_sig_3.BackColor = MyColors[3]; this.lb_sig_3.BorderStyle = BorderStyle.None;
            this.lb_sig_4.BackColor = MyColors[4]; this.lb_sig_4.BorderStyle = BorderStyle.None;
            this.lb_sig_5.BackColor = MyColors[5]; this.lb_sig_5.BorderStyle = BorderStyle.None;


            this.lb_sig_bot_1.BackColor = MyColors[1]; this.lb_sig_1.BorderStyle = BorderStyle.None;
            this.lb_sig_bot_2.BackColor = MyColors[2]; this.lb_sig_2.BorderStyle = BorderStyle.None;
            this.lb_sig_bot_3.BackColor = MyColors[3]; this.lb_sig_3.BorderStyle = BorderStyle.None;
            this.lb_sig_bot_4.BackColor = MyColors[4]; this.lb_sig_4.BorderStyle = BorderStyle.None;
            this.lb_sig_bot_5.BackColor = MyColors[5]; this.lb_sig_5.BorderStyle = BorderStyle.None;

            this.dataGridView_CriticalQuestions.DataSource = this.negativeQuestionsBindingSource;
            this.negativeQuestionsBindingSource.Sort       = "DisplayOrder asc";
        }
コード例 #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // disable unobtrusive validation

        if (Session["Userid"] == null)
        {
            Response.Redirect("~/Login.aspx");
        }

        Session.Add("url", "UserProfile.aspx");

        address  = new TextBox();
        city     = new TextBox();
        zipcode  = new TextBox();
        phone    = new TextBox();
        email    = new TextBox();
        name     = new TextBox();
        password = new TextBox();
        pass2    = new TextBox();
        d        = new DropDownList();


        UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
        if (IsPostBack)
        {
            lbl_Message.Text = "";
            lbl_update.Text  = "";
        }

        DDL_pro  = new DropDownList();
        upd_user = new UpdateUser();

        con1 = new MyConnection();
        sql  = con1.GetConnection();
        str  = "Select province from UserDetails where UserID = " + Session["userid"];
        SqlCommand cmd2 = new SqlCommand(str, sql);

        sql.Open();
        //SqlDataReader reader = cmd2.ExecuteReader();

        province = Convert.ToString(cmd2.ExecuteScalar()).Trim();
        sql.Close();
    }
コード例 #26
0
        private void bt_submit_Click(object sender, EventArgs e)
        {
            if (bs_requestShcedule.Count == 0)
            {
                MessageBox.Show("Define vetting schedule to proceed");
                return;
            }



            try
            {
                Vetting.VettingRequest.Save(MyConnection.GetConnection(), bs_vettingrequests.DataSource as DataTable);
                MessageBox.Show("Changes committed successfully.");
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
        }
コード例 #27
0
    public void Add_To_Wishlist(int u_id, int g_id)
    {
        c2 = con2.GetConnection();
        string getCart = "Select wishlistid from [wishlist] where userid = " + u_id + " and gameid = " + g_id;

        SqlCommand cmd1 = new SqlCommand(getCart, c2);

        c2.Open();
        SqlDataReader reader = cmd1.ExecuteReader();

        if (reader.HasRows)
        {
            /*while (reader.Read())
             * {
             *  break;
             * }*/

            Exist = true;
        }
        else
        {
            Exist = false;
        }



        c2.Close();

        if (!Exist)
        {
            c1 = con1.GetConnection();

            string str = "  insert into Wishlist (UserID, GameID, listed, isActive) values (" + u_id + ",+" + g_id + ",1, 1)";

            SqlCommand cmd = new SqlCommand(str, c1);
            c1.Open();
            cmd.ExecuteNonQuery();

            c1.Close();
        }
    }
コード例 #28
0
    protected void CalculatePrice()
    {
        MyConnection con = new MyConnection();

        SqlConnection c1 = con.GetConnection();

        string userstr = "SELECT Cart.CartID, Cart.Quantity, Game.GameID, Game.Name, Game.Details, Game.Image, GamePlatform.DVDPrice, Platform.Name AS Expr1 FROM Cart INNER JOIN GamePlatform ON GamePlatform.GamePlatformID = Cart.GamePlatformID INNER JOIN Platform ON Platform.PlatformID = GamePlatform.PlatformID INNER JOIN Game ON GamePlatform.GameID = Game.GameID WHERE (Cart.UserID = " + Convert.ToInt16(Session["userid"]) + ")";

        int quantity = 0;
        int price    = 0;

        SqlCommand cmd = new SqlCommand(userstr, c1);

        c1.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.HasRows)
        {
            isCartEmpty = false;

            while (reader.Read())
            {
                quantity = reader.GetInt32(1);
                price    = reader.GetInt32(6);

                total_price = total_price + (quantity * price);
            }
        }
        else
        {
            isCartEmpty = true;
        }



        c1.Close();


        div_totalPrice.InnerText = "Total: $" + total_price;
    }
コード例 #29
0
ファイル: UserLogin.cs プロジェクト: yprocks/GameAddict
    public int GetUserID(String email, String password)
    {
        c1 = conuser.GetConnection();

        string userstr = "Select UserID from [User] where email = '" + email + "' and password = '******'";

        int        result = 0;
        SqlCommand cmd    = new SqlCommand(userstr, c1);

        c1.Open();
        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            result = reader.GetInt32(0);
        }

        c1.Close();
        System.Diagnostics.Debug.WriteLine(result);

        return(result);
    }
コード例 #30
0
ファイル: Checkout.aspx.cs プロジェクト: yprocks/GameAddict
    protected void Page_Load(object sender, EventArgs e)
    {
        // disable unobtrusive validation

        if (Session["Userid"] == null)
        {
            Response.Redirect("~/Login.aspx");
        }

        if (Session["cart"] == null)
        {
            Response.Redirect("~/Cart.aspx");
        }

        order = new AddOrders();

        UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
        if (!IsPostBack)
        {
        }
        else
        {
        }

        con1 = new MyConnection();
        sql  = con1.GetConnection();
        str  = "Select province from UserDetails where UserID = " + Session["userid"];
        SqlCommand cmd2 = new SqlCommand(str, sql);

        sql.Open();
        //SqlDataReader reader = cmd2.ExecuteReader();

        province = Convert.ToString(cmd2.ExecuteScalar()).Trim();
        sql.Close();

        Session.Add("url", "Checkout.aspx");
    }
コード例 #31
0
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            try
            {
                DataRowView drv = this.vesselBindingSource.Current as DataRowView;

                if (drv == null)
                {
                    return;
                }
                int vesselid = (int)drv["Vesselid"];



                if (Vetting.Vetting.VesselEncounter(MyConnection.GetConnection(), vesselid) > 0)
                {
                    throw new Exception("Vessel cannot be deleted.She participates into registered vetting(s)");
                }
                else
                {
                    drv.Delete();
                }

                if (drv["Locked"] != DBNull.Value)
                {
                    if ((int)drv["Locked"] > 0)
                    {
                        throw new Exception("Vessel cannot be deleted. System lock detected.");
                    }
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
        }