Esempio n. 1
0
 private void btnActiveDeactive_Click(object sender, EventArgs e)
 {
     if (DialogResult.Yes.Equals(MessageBox.Show("Are You Sure To " + ((chkMessageService.Checked) ? "Active" : "Deactive").ToString() + " Message Service ...", "Message Service", MessageBoxButtons.YesNo, MessageBoxIcon.Question)))
     {
         Transection = Connection.GetMyConnection().BeginTransaction();
         try
         {
             cmdText = "Update tbl_School Set MessageService = '" + chkMessageService.Checked + "',MessageSenderID = '" + txtSenderID.Text.Trim() + "' " +
                       " ,MessageUserName = '******' ,MessagePassword = '******' ";
             Connection.SqlTransection(cmdText, Connection.MyConnection, Transection);
             Transection.Commit();
             MessageBox.Show("Congratulation!!!\n\t Message Service " + ((chkMessageService.Checked) ? "Activated" : "Deactivated").ToString() + "...", "Message Service", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch
         {
             Transection.Rollback();
             MessageBox.Show("Sorry!!!\n\t Message Service Has Not " + ((chkMessageService.Checked) ? "Activated" : "Deactivated").ToString() + ".\n\t\tPlease Try Again...", "Message Service ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Esempio n. 2
0
        private void listBox1_Click(object sender, EventArgs e)
        {
            String lstval = Convert.ToString(lstbxUser.SelectedValue);

            //string userlvl = Convert.ToString(listBox1.SelectedIndex);
            c.showdata("MasterUser", Connection.GetUserDbConnection(), this, "usercode", lstval);
            // txtuser.Text = CryptorEngine.Decrypt (txtuser.Text, true);
            txtpassword.Text = CryptorEngine.Decrypt(txtpassword.Text, true);
            //DataSet ds34 = Connection.GetDataSet("select UserLevel from tbl_user where usercode='1001'");

            //if (userlvl == "2")
            //{
            //   c.GetMdiParent(this).ToggleEditButton(false);
            //    btndelete.Enabled = false;
            //   c.GetMdiParent(this).ToggleSaveButton(false);
            //}
            //else
            //{
            //   c.GetMdiParent(this).ToggleEditButton(true);
            //    c.GetMdiParent(this).ToggleDeleteButton(true);
            //   c.GetMdiParent(this).ToggleSaveButton(true);
            //}
        }
Esempio n. 3
0
        private void btnok_Click(object sender, EventArgs e)
        {
            //school.CurrentSessionCode = Convert.ToInt32(cmbsession.SelectedValue.ToString());

            string        Pass = CryptorEngine.Encrypt(txtPassword.Text.Trim(), true);
            SqlConnection con  = Connection.GetUserDbConnection();

            //DataSet ds = Connection.GetDataSet("Select * from MasterUser where UserName='******' and UserPassword='******'; ");
            SqlDataAdapter adp = new SqlDataAdapter("Select * from MasterUser where lower(userId)='" + txtUserName.Text.Trim().ToLower() + "' and pwd='" + Pass + "'; ", con);
            DataSet        ds  = new DataSet();

            adp.Fill(ds);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                school1.CurrentUser                     = new CSMSUser();
                school1.CurrentUser.UserId              = ds.Tables[0].Rows[0]["userId"].ToString();
                school1.CurrentUser.Name                = ds.Tables[0].Rows[0]["name"].ToString();
                school1.CurrentUser.Phone               = ds.Tables[0].Rows[0]["phone"].ToString();
                school1.CurrentUser.Address             = ds.Tables[0].Rows[0]["address"].ToString();
                school1.CurrentUser.Email               = ds.Tables[0].Rows[0]["email"].ToString();
                school1.CurrentUser.School              = ds.Tables[0].Rows[0]["school"].ToString();
                school1.CurrentUser.IsPrimaryUser       = Convert.ToBoolean(ds.Tables[0].Rows[0]["isPrimaryUser"]);
                school1.CurrentUser.DbName              = ds.Tables[0].Rows[0]["dbName"].ToString();
                school1.CurrentUser.DbUserPwd           = ds.Tables[0].Rows[0]["dbUserPwd"].ToString();
                school1.CurrentUser.DbUserId            = ds.Tables[0].Rows[0]["dbUserId"].ToString();
                school1.CurrentUser.RoleId              = Convert.ToInt16(ds.Tables[0].Rows[0]["roleId"]);
                school1.CurrentUser.UserCode            = Convert.ToInt32(ds.Tables[0].Rows[0]["UserCode"]);
                school1.CurrentUser.ActivationValidTill = Convert.ToDateTime(ds.Tables[0].Rows[0]["ActivationValidTill"]);
                school1.CurrentUser.ActivatedOn         = Convert.ToDateTime(ds.Tables[0].Rows[0]["ActivatedOn"]);
                school1.CurrentUser.IsActive            = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);

                // Initializing it for school class as well because it is still in use many places
                school.CurrentUser = school1.CurrentUser;

                SetupAppPaths();

                bool isActive = IsUserActive();

                this.Hide();

                if (isActive)
                {
                    MDIParent1 main = new MDIParent1(school1.CurrentUser.UserCode.ToString(), school1.CurrentUser.Name);
                    main.Show();
                }
                else
                {
                    Application.Exit();
                }
            }
            else
            {
                MessageBox.Show("Invalid USER NAME/PASSWORD");
            }

            con.Close();

            //DataSet dschk = Connection.GetDataSet("Select * from SMSsystem ");
            //if (dschk.Tables[0].Rows.Count < 1)
            //{
            //    Registration r = new Registration();
            //    r.Show();
            //}
            //else
            //{

            //    DataSet dschk1 = Connection.GetDataSet("Select * from SMSsystem ");
            //    if (dschk1.Tables[0].Rows.Count < 1)
            //    {
            //        Connection.AllPerform("Insert Into SMSsystem values('" + DateTime.Now.ToShortDateString() + "')");
            //    }
            //    else
            //    {
            //        DateTime dt = Convert.ToDateTime(dschk1.Tables[0].Rows[0].ItemArray[0].ToString());
            //        DateTime dtnew = DateTime.Now;
            //        TimeSpan t = dtnew.Subtract(dt);
            //        int k = t.Days;
            //        if (k > 365)
            //        {
            //            MessageBox.Show("Your Subscription has Expired ? ");
            //            Reminder r = new Reminder();
            //            r.Show();
            //            this.Hide();
            //        }

            //        else
            //        {

            //            DateTime dt1 = Convert.ToDateTime(dschk1.Tables[0].Rows[0].ItemArray[0].ToString());
            //            DateTime dtnew1 = DateTime.Now;
            //            TimeSpan t1 = dtnew.Subtract(dt);
            //            int k1 = t1.Days;
            //            if (k1 > 350 && k1 < 365)
            //            {
            //                int l1 = 365 - k1;
            //                MessageBox.Show("No Of Days Left " + l1.ToString() + "  Please Renew Your Subscription");
            //            }
            //            string Pass = CryptorEngine.Encrypt(txtPassword.Text, true);
            //            //string Pass1 = CryptorEngine.Decrypt(txtPassword.Text, true);
            //            DataSet ds = Connection.GetDataSet("Select Count(*) from tbl_User where UserName='******' and UserPassword='******'; "+
            //                "Select UserCode,UserName From tbl_User Where UserName='******' and UserPassword='******';");
            //            int i = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            //            if (txtUserName.Text.Trim().Equals(SMS.Splash.U) && SMS.Splash.P.Equals(CryptorEngine.Encrypt(txtPassword.Text, true)))
            //            {
            //                this.Hide();
            //                Splash su = new Splash(SMS.Splash.U, SMS.Splash.P);
            //                su.Show();
            //            }
            //           else if (i == 1)
            //            {
            //                this.Hide();
            //                // MessageBox.Show("Welcome To  School Management System ", "Microdigit Software Technologies Pvt Ltd ");
            //                Splash su = new Splash(ds.Tables[1].Rows[0]["UserCode"].ToString(), ds.Tables[1].Rows[0]["UserName"].ToString());
            //                //Form mainForm = new mdikgri(textBox1.Text);
            //                // Make it a child of this MDI form before showing it.
            //                // mainForm.Show();
            //                su.Show();
            //            }
            //            else
            //            {

            //                MessageBox.Show("Invalid USER NAME/PASSWORD");
            //                DataSet ds1 = Connection.GetDataSet("Select Count(*) from tbl_User ");
            //                int ii = Convert.ToInt32(ds1.Tables[0].Rows[0][0]);
            //                if (ii == 0)
            //                {
            //                    MessageBox.Show("Pleace Create a User Account.");
            //                    Form mainForm = new frmuser();
            //                    mainForm.Show();
            //                }
            //                else
            //                {
            //                    DataSet ds2 = Connection.GetDataSet("Select Count(*) from tbl_Userauth ");
            //                    int ij = Convert.ToInt32(ds2.Tables[0].Rows[0][0]);
            //                    if (ij == 0)
            //                    {
            //                        Form mainForm = new frmuserauth();
            //                        mainForm.Show();
            //                    }
            //                }

            //            }
            //            //Form mainForm = new mdikgri();
            //            //mainForm.Show();
            //        }
            //    }
            //    //}
            //}
        }
Esempio n. 4
0
        public override void btnsave_Click(object sender, EventArgs e)
        {
            if (txtuser.Text == "" || txtpassword.Text == "")
            {
                MessageBox.Show("User Name and Password values are mandatory ");
            }
            else
            {
                //c.datasave("tbl_school", c.myconn, this);
                if (add_edit == true)
                {
                    c.returnconn(c.myconn);
                    SqlCommand command = new SqlCommand("select max(usercode) from tbl_user", c.myconn);
                    command.CommandTimeout = 120;
                    Int32 mstudentno;
                    mstudentno = 1001;
                    if (command.ExecuteScalar() != System.DBNull.Value)
                    {
                        mstudentno = Convert.ToInt32(command.ExecuteScalar()) + 1;
                    }
                    DataSet ds = Connection.GetDataSet("select count(* ) from MasterUser where lower(userId)='" + txtuser.Text.Trim().ToLower() + "'", Connection.GetUserDbConnection());

                    int i = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
                    if (i == 0)
                    {
                        txtusercode.Text = mstudentno.ToString();
                        txtpassword.Text = CryptorEngine.Encrypt(txtpassword.Text.Trim(), true);
                        //     txtuser.Text = CryptorEngine.Encrypt(txtuser.Text, true);
                        c.executesql("insert into MasterUser (userId, pwd,  masterUserId, isPrimaryUser, dbUserId, dbUserPwd, dbName, UserLevel, roleId, userCode ) values('" + txtuser.Text.Trim() + "','" + txtpassword.Text + "','" + school1.CurrentUser.UserId + "',false,'" + school1.CurrentUser.DbUserId + "','" + school1.CurrentUser.DbUserPwd + "','" + school1.CurrentUser.DbName + "'," + CmbUserRole.SelectedValue + "," + CmbUserRole.SelectedValue + ",'" + mstudentno.ToString() + "');", Connection.GetUserDbConnection());
                        c.insertdata("MasterUser", Connection.GetUserDbConnection(), this);
                        MessageBox.Show("Record Saved...", "");
                        //this.Hide();
                        DataSet ds2 = Connection.GetDataSet("Select Count(*) from tbl_Userauth ");
                        int     ij  = Convert.ToInt32(ds2.Tables[0].Rows[0][0]);
                        if (ij == 0)
                        {
                            MDIParent1 mdiForm = (MDIParent1)this.FindForm();
                            mdiForm.ShowUserControl(new frmuserauth(), "Set User Permissions");
                            //Form mainForm = new frmuserauth();
                            //mainForm.Show();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Duplicate data not allowed");
                    }
                }
                if (add_edit == false)
                {
                    txtpassword.Text = CryptorEngine.Encrypt(txtpassword.Text, true);
                    //   txtuser.Text = CryptorEngine.Encrypt(txtuser.Text, true);
                    c.updatedata("MasterUser", Connection.GetUserDbConnection(), this, "usercode", txtusercode.Text);
                    MessageBox.Show("Record Saved...", "School");
                }

                c.FillListBox("select * from MasterUser where parentUserId='" + school1.CurrentUser.UserId + "'", Connection.GetUserDbConnection(), "userId", "usercode", ref lstbxUser);
                c.GetMdiParent(this).EnableAllEditMenuButtons();

                //DesignForm.fromDesign1(this);
            }
        }