Пример #1
0
        private void GoToLogin()
        {
            Loginform lf = new Loginform();

            this.Hide();
            lf.Show();
            lf.BringToFront();
        }
Пример #2
0
        private void CheckForSubcription()
        {
            DataSet dschk = Connection.GetDataSet("Select * from tbl_ProductReg ");

            if (dschk.Tables[0].Rows.Count < 1)
            {
                Registration r = new Registration();
                this.Hide();
                r.Show();
                r.BringToFront();
            }
            else
            {
                if (dschk.Tables[0].Rows[0]["prodkey"] == null || string.Equals(dschk.Tables[0].Rows[0]["prodkey"], school.trialProdKey) || string.IsNullOrEmpty(dschk.Tables[0].Rows[0]["prodkey"].ToString()))
                {
                    DataSet dsTrial = Connection.GetDataSet("Select * from SMSsystem ");
                    long    regDate = Convert.ToInt64(dsTrial.Tables[0].Rows[0]["RegDate"]);

                    DateTime dt      = DateTime.FromBinary(regDate);
                    long     runTime = Convert.ToInt64(dsTrial.Tables[0].Rows[0]["RunTime"]);

                    int daysLeft = dt.AddDays(30).Subtract(DateTime.Now).Days + 1;

                    int runCount = Convert.ToInt32(dsTrial.Tables[0].Rows[0]["RunCount"]);

                    int daysUsed = dt.AddSeconds(runTime).Subtract(dt).Days;

                    if (daysLeft <= 0 || daysUsed > 30 || runCount > 45)
                    {
                        this.Hide();
                        MessageBox.Show("Your trial subscription has ended. Please activate your product.", "Subscription Ended", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Registration r = new Registration();
                        r.Show();
                        r.BringToFront();
                    }
                    else if (daysLeft < 15)
                    {
                        if (MessageBox.Show(
                                "Your trial will end in " + daysLeft + " days. Would you like to activate your product now?",
                                "Alert", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            this.Hide();
                            Registration r = new Registration();
                            r.Show();
                            r.BringToFront();
                        }
                        else
                        {
                            Loginform lf = new Loginform();
                            this.Hide();
                            lf.Show();
                            lf.BringToFront();
                        }
                    }
                    else
                    {
                        Loginform lf = new Loginform();
                        this.Hide();
                        lf.Show();
                        lf.BringToFront();
                    }
                }

                else
                {
                    DataSet dsSchool = Connection.GetDataSet("Select schoolname, schoolcity from tbl_school ");

                    DataSet dsTrial = Connection.GetDataSet("Select * from SMSsystem ");
                    long    regDate = Convert.ToInt64(dsTrial.Tables[0].Rows[0]["RegDate"]);

                    DateTime dt = DateTime.FromBinary(regDate);

                    school sc   = new school();
                    string pKey = sc.ConstructProductKey(dsSchool.Tables[0].Rows[0]["schoolname"].ToString().Replace(" ", "").Replace(".", ""),
                                                         dsSchool.Tables[0].Rows[0]["schoolcity"].ToString().Replace(" ", ""), dt.Day.ToString(), dt.Month.ToString(), dt.Year.ToString());

                    if (string.Equals(dschk.Tables[0].Rows[0]["prodkey"], pKey))
                    {
                        DateTime dtnew = DateTime.Now;
                        TimeSpan t     = dtnew.Subtract(dt);
                        int      k     = t.Days;
                        if (k > 365)
                        {
                            MessageBox.Show("Your Subscription has expired.");
                            Help r = new Help();
                            r.Show();
                            this.Hide();
                            r.BringToFront();
                        }
                        else
                        {
                            if (k > 350 && k < 365)
                            {
                                int l1 = 365 - k;
                                MessageBox.Show("Number of days left " + l1.ToString() +
                                                ", please renew your Subscription.");
                            }

                            Loginform lf = new Loginform();
                            this.Hide();
                            lf.Show();
                            lf.BringToFront();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Your Product Key is invalid. Please contact our support team for help.");
                        Help r = new Help();
                        r.Show();
                        this.Hide();
                        r.BringToFront();
                    }
                }
            }
        }
Пример #3
0
        private void btnUseTrial_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                SqlConnection LocalCon = Connection.Conn();
                if (LocalCon.State != ConnectionState.Open)
                {
                    LocalCon.Open();
                }
                SqlTransaction LocalTrn = LocalCon.BeginTransaction();
                try
                {
                    DataSet dsSchool = Connection.GetDataSet("select * from tbl_school");

                    if (dsSchool.Tables[0].Rows.Count > 0)
                    {
                        Connection.SqlTransection(
                            "Update tbl_school set schoolname = '" +
                            ProperCase(txtSchoolName.Text).Trim().Replace("'", "''") +
                            "', schoolcity='" + ProperCase(txtCity.Text).Trim() +
                            "'", LocalCon, LocalTrn);
                    }
                    else
                    {
                        Connection.SqlTransection(
                            "Insert Into tbl_school (schoolname, schoolcity) values ('" +
                            ProperCase(txtSchoolName.Text).Trim().Replace("'", "''") +
                            "', '" + ProperCase(txtCity.Text).Trim() + "')", LocalCon, LocalTrn);
                    }

                    Connection.SqlTransection(
                        "Delete from tbl_ProductReg; Insert Into tbl_ProductReg (schoolname, city, username, branchname,prodkey, regDate) values ('" +
                        ProperCase(txtSchoolName.Text).Trim().Replace("'", "''") +
                        "','" + ProperCase(txtCity.Text).Trim() +
                        "','" + ProperCase(txtUserName.Text).Trim() +
                        "','" + ProperCase(txtBranch.Text).Trim() +
                        "','" + school.trialProdKey +
                        "','" + DateTime.Now.ToShortDateString() +
                        "'" + ")", LocalCon, LocalTrn);


                    long       dt  = DateTime.Now.ToBinary();
                    SqlCommand cmd = LocalCon.CreateCommand();
                    cmd.CommandText = "Delete from SMSsystem;Insert Into SMSsystem values(@dt,@count,@time)";
                    cmd.Transaction = LocalTrn;
                    long time = 0;
                    cmd.Parameters.Add("@dt", dt);
                    cmd.Parameters.Add("@count", 1);
                    cmd.Parameters.Add("@time", time);

                    cmd.ExecuteNonQuery();
                    LocalTrn.Commit();

                    Loginform l = new Loginform();
                    l.Show();
                    this.Hide();
                    l.BringToFront();
                }
                catch (Exception ex)
                {
                    LocalTrn.Rollback();
                    MessageBox.Show("Some error has occurred. Please Try Again.", "Error");
                }
            }
        }
Пример #4
0
        private void loginToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Loginform frm = (new Loginform());

            frm.ShowDialog();
        }
Пример #5
0
        private void btnActivateNow_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                school c       = new school();
                string prodKey = c.ConstructProductKey(txtSchoolName.Text.Replace(" ", "").Replace(".", ""),
                                                       txtCity.Text.Replace(" ", ""), DateTime.Today.Day.ToString(), DateTime.Now.Month.ToString(),
                                                       DateTime.Now.Year.ToString());
                if (IsValidAttempt())
                {
                    if (prodKey == txtProdKey.Text.Trim().ToUpper())
                    {
                        SqlConnection LocalCon = Connection.Conn();
                        if (LocalCon.State != ConnectionState.Open)
                        {
                            LocalCon.Open();
                        }
                        SqlTransaction LocalTrn = LocalCon.BeginTransaction();
                        try
                        {
                            DataSet dsSchool = Connection.GetDataSet("select * from tbl_school");

                            if (dsSchool.Tables[0].Rows.Count > 0)
                            {
                                Connection.SqlTransection(
                                    "Update tbl_school set schoolname = '" +
                                    ProperCase(txtSchoolName.Text).Trim().Replace("'", "''") +
                                    "', schoolcity='" + ProperCase(txtCity.Text).Trim() +
                                    "'", LocalCon, LocalTrn);
                            }
                            else
                            {
                                Connection.SqlTransection(
                                    "Insert Into tbl_school (schoolname, schoolcity) values ('" +
                                    ProperCase(txtSchoolName.Text).Trim().Replace("'", "''") +
                                    "', '" + ProperCase(txtCity.Text).Trim() + "')", LocalCon, LocalTrn);
                            }

                            Connection.SqlTransection(
                                "Delete from tbl_ProductReg; Insert Into tbl_ProductReg (schoolname, city, username, branchname,prodkey, regDate) values ('" +
                                ProperCase(txtSchoolName.Text).Trim().Replace("'", "''") +
                                "','" + ProperCase(txtCity.Text).Trim() +
                                "','" + ProperCase(txtUserName.Text).Trim() +
                                "','" + ProperCase(txtBranch.Text).Trim() +
                                "','" + txtProdKey.Text.Trim().ToUpper() +
                                "','" + DateTime.Now.ToShortDateString() +
                                "'" + ")", LocalCon, LocalTrn);


                            long       dt  = DateTime.Now.ToBinary();
                            SqlCommand cmd = LocalCon.CreateCommand();
                            cmd.CommandText = "Delete from SMSsystem;Insert Into SMSsystem values(@dt,@count,@time)";
                            cmd.Transaction = LocalTrn;

                            long time = 0;
                            cmd.Parameters.Add("@dt", dt);
                            cmd.Parameters.Add("@count", 1);
                            cmd.Parameters.Add("@time", time);

                            cmd.ExecuteNonQuery();

                            LocalTrn.Commit();
                            if (LocalCon.State == ConnectionState.Open)
                            {
                                LocalCon.Close();
                            }
                            MessageBox.Show("Your product activation is successful.");

                            if (this.Modal)
                            {
                                this.Close();
                            }
                            else
                            {
                                Loginform l = new Loginform();
                                l.Show();
                                this.Hide();
                                l.BringToFront();
                            }
                        }
                        catch (Exception ex)
                        {
                            LocalTrn.Rollback();
                            MessageBox.Show("Some error has occurred. Please Try Again.", "Error");
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid activation key.", "Error");
                        SqlConnection LocalCon = Connection.Conn();
                        if (LocalCon.State != ConnectionState.Open)
                        {
                            LocalCon.Open();
                        }

                        SqlCommand cmd = LocalCon.CreateCommand();
                        cmd.CommandText = "update tbl_RegAttempt set attempt=attempt+1, date = '" +
                                          DateTime.Now.ToShortDateString() + "'";
                        cmd.ExecuteNonQuery();
                        if (LocalCon.State == ConnectionState.Open)
                        {
                            LocalCon.Close();
                        }
                    }
                }
            }
        }