예제 #1
0
        public static void SetAll(String[] fields, DataTable usrs, DataTable BAddrs)
        {
            String        connString        = Properties.Settings.Default.FAFOS;
            SqlConnection con               = new SqlConnection(connString);
            SqlCommand    FranchiseeCommand = new SqlCommand("UPDATE Franchisee SET company_name = '" + fields[1] +
                                                             "', tax_registration = " + fields[2] +
                                                             ", business_registration_number = " + fields[3] +
                                                             ", fiscal_year_end = '" + fields[4] +
                                                             "' WHERE franchisee_id = " + fields[0], con);


            con.Open();
            FranchiseeCommand.ExecuteNonQuery();
            con.Close();

            int n = usrs.Rows.Count;

            for (int i = 0; i < n; i++)
            {
                MUser.Set(usrs.Rows[i]);
            }

            int x = BAddrs.Rows.Count;

            for (int i = 0; i < x; i++)
            {
                SetBAddr(BAddrs.Rows[i]);
            }
        }
예제 #2
0
        public UserController(MaintainUsersForm child, int usrID, int profilePictureID)
        {
            userID = usrID;
            _user = new MUser(userID);
            picID = profilePictureID;
            _userForm = child;

            if (userID == 1)
            {
                _user.giveAdmin();
                _user.SetHQ(MFranchise.isFranchisor());
            }

            String[] loc = _user.GetLocation();
            if (loc[0] != "0")
                _userForm.InitializeCombos(loc[0], loc[1], loc[2]);
            else
            {
                String[] op = MFranchise.GetOpReg();
                _userForm.InitializeCombos(op[2], op[3], op[4]);
            }

            LoadUserPic();
            _userForm.SetButtons(_user.IsAdmin(), _user.IsHQ());
            _userForm.SetFields(_user.Get());
            /*try { _userForm.SetFields(_user.Get()); }
            catch (Exception) { MessageBox.Show("Failed to load User"); _userForm.Close(); }*/
        }
예제 #3
0
        public UserController(MaintainUsersForm child, int usrID, int profilePictureID)
        {
            userID    = usrID;
            _user     = new MUser(userID);
            picID     = profilePictureID;
            _userForm = child;

            if (userID == 1)
            {
                _user.giveAdmin();
                _user.SetHQ(MFranchise.isFranchisor());
            }

            String[] loc = _user.GetLocation();
            if (loc[0] != "0")
            {
                _userForm.InitializeCombos(loc[0], loc[1], loc[2]);
            }
            else
            {
                String[] op = MFranchise.GetOpReg();
                _userForm.InitializeCombos(op[2], op[3], op[4]);
            }

            LoadUserPic();
            _userForm.SetButtons(_user.IsAdmin(), _user.IsHQ());
            _userForm.SetFields(_user.Get());

            /*try { _userForm.SetFields(_user.Get()); }
             * catch (Exception) { MessageBox.Show("Failed to load User"); _userForm.Close(); }*/
        }
예제 #4
0
        public void SetFields(String[] values)
        {
            fNameTxtBox.Text       = MUser.ConBlank(values[1]);
            lNameTxtBox.Text       = MUser.ConBlank(values[2]);
            mNameTxtBox.Text       = MUser.ConBlank(values[3]);
            usernameTextBox.Text   = MUser.ConBlank(values[4]);
            PassTxtBox.Text        = values[5];
            cnfTxtBox.Text         = values[5];
            addrTextBox.Text       = MUser.ConBlank(values[6]);
            postalCodeTextBox.Text = MUser.ConBlank(values[7]);
            homeTxtBox.Text        = MUser.ConBlank(values[8]);
            cellTextBox.Text       = MUser.ConBlank(values[9]);
            FaxTextBox.Text        = MUser.ConBlank(values[10]);
            EmailTextBox.Text      = MUser.ConBlank(values[11]);
            SkypeBox.Text          = MUser.ConBlank(values[12]);
            PositionTxBox.Text     = MUser.ConBlank(values[13]);
            bool adminUsr = false, hqUsr = false;

            if (String.Equals(values[14], "True", StringComparison.OrdinalIgnoreCase))
            {
                hqUsr = true;
            }
            if (String.Equals(values[15], "True", StringComparison.OrdinalIgnoreCase))
            {
                adminUsr = true;
            }
            SetButtons(adminUsr, hqUsr);
            CountryBox.SelectedValue   = values[19];
            ProvStateBox.SelectedValue = values[17];
            CityBox.SelectedValue      = values[18];
        }
예제 #5
0
 public void AdminButton_Click(object sender, EventArgs e)
 {
     if (_adminForm == null)
     {
         _adminForm = new AdminUserForm(this, _userForm.GetWindowMidRight());
         _adminForm.PopulateUserGridView(MUser.GetAllUsers());
         _adminForm.PopulateBAddrsGridView(MFranchise.GetBAddrs());
         _adminForm.noChanges = true;
         _adminForm.Show();
         _userForm.ToggleAdminButton();
     }
     else
     {
         if (_adminForm.noChanges)
         {
             _adminForm.Close();
             _adminForm = null;
             _userForm.ToggleAdminButton();
         }
         else
         {
             if (MessageBox.Show("Are u sure you want to discard admin changes?", "Confirm Discard", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 _adminForm.Close();
                 _adminForm = null;
                 _userForm.ToggleAdminButton();
             }
             else
             {
                 return;
             }
         }
     }
 }
예제 #6
0
/********************************** Admin User Form **********************************/
        public void UserGridViewClick(object sender, DataGridViewCellEventArgs e)
        {
            var dgv = sender as DataGridView;

            if ((e.ColumnIndex == 2) && (e.RowIndex > -1))//-----------------------------------password reset
            {
                if (MessageBox.Show("Are you sure you want to rest this user's Password?", "Confirm Reset", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    String newPass = GeneratePassword();
                    dgv.Rows[e.RowIndex].Cells["passSetCol"].Value = newPass;
                    MessageBox.Show("Heres the new Password: "******"\nMake sure to copy it down");
                }
            }
            if ((e.ColumnIndex == 10) && (e.RowIndex > -1))//-----------------------------------remove
            {
                if (dgv.Rows[e.RowIndex].Cells["usrIDCol"].Value != null)
                {
                    if (dgv.Rows[e.RowIndex].Cells["usrIDCol"].Value.ToString() == "1")
                    {
                        MessageBox.Show("Cannot remove Primary user!");
                        return;
                    }
                }

                if (userID == 1)//elivated privileges
                {
                    if (MessageBox.Show("Delete User?", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        //MUser.Delete(dgv.Rows[e.RowIndex].Cells["usrIDCol"].Value.ToString());
                        try { MUser.Delete(dgv.Rows[e.RowIndex].Cells["usrIDCol"].Value.ToString()); }
                        catch (Exception) { }
                        dgv.Rows.RemoveAt(e.RowIndex);
                    }
                }
                else // any other user
                {
                    if (string.Equals(dgv.Rows[e.RowIndex].Cells["adminCol"].ToString(), "true", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(dgv.Rows[e.RowIndex].Cells["hqCol"].ToString(), "true", StringComparison.OrdinalIgnoreCase))
                    {
                        MessageBox.Show("You cannot delete users with admin priviledges!\nOnly the primary user can");
                        return;
                    }
                    else
                    if (MessageBox.Show("Delete User?", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        try { MUser.Delete(dgv.Rows[e.RowIndex].Cells["usrIDCol"].Value.ToString()); }
                        catch (Exception) { }
                        dgv.Rows.RemoveAt(e.RowIndex);
                    }
                }
            }
        }
예제 #7
0
        public void setup(String name, String title)
        {
            //User label
            //user = new Users();
            //userid = id;
            lblUserInfo.Text = "Welcome\n " + new Users().getName(Convert.ToInt32(name));
            //lblPageTitle.Text = title;


            List <Bitmap> piclist = MUser.LoadImages();


            //this.profilePic.BackgroundImage = piclist[MUser.GetPicID(name.ToString())];// FAFOS.Properties.Resources.Shades;
            //this.profilePic.BackgroundImageLayout = ImageLayout.Stretch;
        }
예제 #8
0
        public void PopulateUserGridView(DataTable users)
        {
            int n = users.Rows.Count, index;
            DataGridViewCheckBoxCell admin;
            DataGridViewCheckBoxCell hq;
            bool lockRow;

            for (int i = 0; i < n; i++)
            {
                lockRow = false;
                admin   = null;
                hq      = null;
                index   = UserGridView.Rows.Add();
                UserGridView.Rows[index].Cells["usrIDCol"].Value   = users.Rows[i]["user_id"];
                UserGridView.Rows[index].Cells["usrName"].Value    = users.Rows[i]["username"];
                UserGridView.Rows[index].Cells["passSetCol"].Value = users.Rows[i]["password"];
                UserGridView.Rows[index].Cells["fName"].Value      = MUser.ConBlank(users.Rows[i]["first_nm"].ToString());
                UserGridView.Rows[index].Cells["lName"].Value      = MUser.ConBlank(users.Rows[i]["last_nm"].ToString());
                UserGridView.Rows[index].Cells["mName"].Value      = MUser.ConBlank(users.Rows[i]["middle_nm"].ToString());
                UserGridView.Rows[index].Cells["PerOwnCol"].Value  = users.Rows[i]["percentage_ownership"];

                admin = UserGridView.Rows[index].Cells["adminCol"] as DataGridViewCheckBoxCell;
                if (string.Equals(users.Rows[i]["admin_user"].ToString(), "true", StringComparison.OrdinalIgnoreCase))
                {
                    admin.Value = true; lockRow = true;
                }
                if (string.Equals(users.Rows[i]["admin_user"].ToString(), "false", StringComparison.OrdinalIgnoreCase))
                {
                    admin.Value = false;
                }
                hq = UserGridView.Rows[index].Cells["hqCol"] as DataGridViewCheckBoxCell;
                if (string.Equals(users.Rows[i]["hq_user"].ToString(), "true", StringComparison.OrdinalIgnoreCase))
                {
                    hq.Value = true; lockRow = true;
                }
                if (string.Equals(users.Rows[i]["hq_user"].ToString(), "false", StringComparison.OrdinalIgnoreCase))
                {
                    hq.Value = false;
                }

                if (lockRow)
                {
                    UserGridView.Rows[index].ReadOnly = true;
                }
            }
        }
예제 #9
0
        public void UploadPic_click(object sender, EventArgs e)
        {
            OpenFileDialog opendialog = new OpenFileDialog();

            opendialog.Filter = "Image files(*.jpg; *.jpeg; *.gif)| *.jpg; *.jpeg; *.gif";

            if (opendialog.ShowDialog() == DialogResult.OK)
            {
                Bitmap img = new Bitmap(opendialog.FileName);
                opendialog.RestoreDirectory = true;
                LoadUserPic();
                List <Bitmap> picList = MUser.LoadImages();
                picList[picID] = img;
                MUser.SaveImages(picList);
                LoadUserPic();
            }
        }
예제 #10
0
/********************************** Maintain User Form ****************************/
        public void back_Button(object sender, EventArgs e)
        {
            MUser.DeleteBlanks();
            if (_adminForm != null)
            {
                if (_adminForm.noChanges)
                {
                    _adminForm.Close();
                }
                else
                {
                    if (MessageBox.Show("Are u sure you want to discard admin changes?", "Confirm Close", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        _adminForm.Close();
                    }
                    else
                    {
                        return;
                    }
                }
            }
            if (_hqForm != null)
            {
                if (_hqForm.noChanges)
                {
                    _hqForm.Close();
                }
                else
                {
                    if (MessageBox.Show("Are u sure you want to discard admin changes?", "Confirm Close", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        _hqForm.Close();
                    }
                    else
                    {
                        return;
                    }
                }
            }
            _userForm.Close();
        }
예제 #11
0
/********************************** Profile Pics **********************************/
        public void LoadUserPic()
        {
            try { picList = MUser.LoadImages(); }
            catch (Exception) { picList = new List <Bitmap>(); }

            Bitmap img;

            try{ img = picList[picID]; }
            catch (Exception)
            {
                if (picID == picList.Count)
                {
                    picList.Add(new Bitmap(Properties.Resources.DefaultProPic));
                    img = picList[picID];
                }
                else
                {
                    picList[picID] = new Bitmap(Properties.Resources.DefaultProPic);
                    img            = picList[picID];
                }
            }
            _userForm.setPic(img);
        }
예제 #12
0
        private void userSettings_Click(object sender, EventArgs e)
        {
            MaintainUsersForm form = new MaintainUsersForm(userid, MUser.GetPicID(userid.ToString()));

            form.Show();
        }
예제 #13
0
        private void Login_btn_Click(object sender, EventArgs e)
        {
            if (Login())
            {
                pnlLogin.Visible = false;
                this.Exit_btn.Focus();

                /*quote.Visible = true;
                 * editQuote.Visible = true;
                 * salesOrder.Visible = true;
                 * editSalesOrder.Visible = true;
                 * convertSalesOrder.Visible = true;
                 * invoice.Visible = true;
                 * inventory.Visible = true;
                 * purchaseRecord.Visible = true;
                 * payment.Visible = true;
                 * itinerary.Visible = true;
                 * inspection.Visible = true;
                 *
                 * addClient.Visible = true;
                 * addContract.Visible = true;
                 * editClient.Visible = true;
                 * editContract.Visible = true;
                 *
                 * statement.Visible = true;
                 * jobReport.Visible = true;
                 * revenueReport.Visible = true;
                 * royaltyFee.Visible = true;
                 * if (!user.checkAdmin(userid))
                 *  royaltyFee.Visible = false;
                 * //   allRevenue.Visible = true;
                 */
                syncAndroid.Visible        = true;
                btnSyncFromAndroid.Visible = true;

                lblOperations.Visible = true;
                lblDocs.Visible       = true;
                lblClients.Visible    = true;
                lblReports.Visible    = true;

                lblUsername.Visible       = false;
                txtUsername.Visible       = false;
                lblPassword.Visible       = false;
                txtPassword.Visible       = false;
                Login_btn.Visible         = false;
                Logout_btn.Visible        = true;
                noteHideButton.Visible    = true;
                userSettings.Visible      = true;
                lblUserInfo.Visible       = true;
                notificationPanel.Visible = true;
                profilePic.Visible        = true;
                pnlUser.Visible           = true;
                pnlPage.Visible           = true;
                pnlMenu.Visible           = true;
                btnMenu.Visible           = true;


                try
                {
                    piclist = MUser.LoadImages();
                }
                catch (Exception)
                {
                    piclist.Add(FAFOS.Properties.Resources.DefaultProPic);
                    MUser.SaveImages(piclist);
                }

                this.profilePic.BackgroundImage       = piclist[MUser.GetPicID(userid.ToString())];// FAFOS.Properties.Resources.Shades;
                this.profilePic.BackgroundImageLayout = ImageLayout.Stretch;


                lblUserInfo.Text = "Welcome\n " + user.getName(userid);

                /*
                 * quote.tileLocation = quote.Location;
                 * editQuote.tileLocation = editQuote.Location;
                 * salesOrder.tileLocation = salesOrder.Location;
                 * convertSalesOrder.tileLocation = convertSalesOrder.Location;
                 * editSalesOrder.tileLocation = editSalesOrder.Location;
                 *
                 * invoice.tileLocation = invoice.Location;
                 * inventory.tileLocation = inventory.Location;
                 * purchaseRecord.tileLocation = purchaseRecord.Location;
                 * payment.tileLocation = payment.Location;
                 * itinerary.tileLocation = itinerary.Location;
                 * inspection.tileLocation = inspection.Location;
                 *
                 * addClient.tileLocation = addClient.Location;
                 * editClient.tileLocation = editClient.Location;
                 * addContract.tileLocation = addContract.Location;
                 * editContract.tileLocation = editContract.Location;
                 *
                 * statement.tileLocation = statement.Location;
                 * jobReport.tileLocation = jobReport.Location;
                 * revenueReport.tileLocation = revenueReport.Location;
                 * royaltyFee.tileLocation = royaltyFee.Location;
                 * //   allRevenue.tileLocation = allRevenue.Location;
                 */
                string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory);

                /*
                 * quote.setMovie(path + "\\Resources\\Quote1.swf");
                 * editQuote.setMovie(path + "\\Resources\\EditQuote.swf");
                 * salesOrder.setMovie(path + "\\Resources\\CreateSalesOrder1.swf");
                 * editSalesOrder.setMovie(path + "\\Resources\\EditSalesOrder1.swf");
                 * convertSalesOrder.setMovie(path + "\\Resources\\ConvertSalesOrder1.swf");
                 * invoice.setMovie(path + "\\Resources\\Invoice1.swf");
                 * inventory.setMovie(path + "\\Resources\\Inventory1.swf");
                 * purchaseRecord.setMovie(path + "\\Resources\\PurchaseRecord.swf");
                 * payment.setMovie(path + "\\Resources\\payment1.swf");
                 * itinerary.setMovie(path + "\\Resources\\itinerary1.swf");
                 * inspection.setMovie(path + "\\Resources\\Inspection.swf");
                 *
                 * addClient.setMovie(path + "\\Resources\\addClient1.swf");
                 * addContract.setMovie(path + "\\Resources\\addContract1.swf");
                 * editClient.setMovie(path + "\\Resources\\editClient1.swf");
                 * editContract.setMovie(path + "\\Resources\\editContract1.swf");
                 *
                 * statement.setMovie(path + "\\Resources\\Statements.swf");
                 * jobReport.setMovie(path + "\\Resources\\JobReports.swf");
                 * revenueReport.setMovie(path + "\\Resources\\RevenueReports.swf");
                 * royaltyFee.setMovie(path + "\\Resources\\RoyaltyFee.swf");
                 * //  allRevenue.setMovie(path + "\\Resources\\TotalRevenue.swf");
                 */
                Notifications();
            }
        }