public RootForm()
 {
     InitializeComponent();
     dh      = DataBaseHandler.getInstance();
     dataset = new DataSet();
     cmd     = new SqlCommand("SELECT * FROM [Book]; SELECT * FROM [Customer];SELECT * FROM [MusicCD];SELECT * FROM [Magazine];", connection);
     adapter = new SqlDataAdapter(cmd);
     adapter.Fill(dataset);
     dtgBook.DataSource     = dataset.Tables[0];
     dtgCustomer.DataSource = dataset.Tables[1];
     dtgMusicCd.DataSource  = dataset.Tables[2];
     dtgMagazine.DataSource = dataset.Tables[3];
     dtgCustomer.SelectAll();
     customerTextArray             = new TextBox[] { txtCustomerName, txtAddress, txtEmail, txtUserName, txtPassword };
     bookTextArray                 = new TextBox[] { txtBookName, txtAuthor, txtPublisher, txtPage, txtBookPrice, txtBookSale, txtBookCategory, txtBookDescription, txtImageName };
     magazineTextArray             = new TextBox[] { txtMagazineName, txtMagazineCategory, txtMagazinePrice, txtMagazineSale, txtIssue, txtMagazineImage, txtMagazineDescription };
     musicCDTextArray              = new TextBox[] { txtMusicName, txtSinger, txtMusicDescription, txtMusicPrice, txtMusicSale, txtMusicCategory, txtMusicImage, txtDemo };
     btnAddBook.Enabled            = false;
     btnAddMagazine.Enabled        = false;
     btnAddMusicCD.Enabled         = false;
     btnBookUpdate.Enabled         = false;
     btnBookDelete.Enabled         = false;
     btnMagazineDelete.Enabled     = false;
     btnUpdateMagazine.Enabled     = false;
     btnMusicDelete.Enabled        = false;
     btnMusicUpdate.Enabled        = false;
     btnCustomerDelete.Enabled     = false;
     btnCustUpdate.Enabled         = false;
     btnBookImageChange.Enabled    = false;
     btnMagazinemageChange.Enabled = false;
     btnMusicCDChangeImage.Enabled = false;
     btnAddDemo.Enabled            = false;
 }
 public void Refresh()
 {
     dataset.Clear();
     dh      = DataBaseHandler.getInstance();
     cmd     = new SqlCommand("SELECT * FROM [Book]; SELECT * FROM [Customer];SELECT * FROM [MusicCD];SELECT * FROM [Magazine];", connection);
     adapter = new SqlDataAdapter(cmd);
     adapter.Fill(dataset);
 }
 private void InvoiceForm_Load(object sender, EventArgs e)
 {
     using (var bitmap = new Bitmap(this.ClientSize.Width, this.ClientSize.Height))
     {
         Customer cust = Customer.getInstance();
         this.pnlInvoice.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
         System.IO.Directory.CreateDirectory(Application.StartupPath + @"\Resources\Invoices\");
         bitmap.Save(Application.StartupPath + @"\Resources\Invoices\" + cust.Username + cust.PurchCount + ".png");
         cust.PurchCount++;
         DataBaseHandler dh = DataBaseHandler.getInstance();
         dh.CustomerUpdate(cust);
     }
 }
Exemple #4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Logger.logger("Profile Form Update");
            DataBaseHandler dh = DataBaseHandler.getInstance();

            cstmr.Name     = txtName.Text;
            cstmr.Adress   = txtAddress.Text;
            cstmr.Email    = txtEmail.Text;
            cstmr.Password = txtPassword.Text;
            dh.CustomerUpdate(cstmr);
            MessageBox.Show("Your profile has been updated successfully.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Exemple #5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            panelCreator = new FactoryPanelCreator();
            DataBaseHandler dh = DataBaseHandler.getInstance();

            productList = new ArrayList();
            booklist    = dh.BookLoader();
            CurrentProductList.AddRange(booklist);
            musiclist    = dh.MusicCDLoader();
            magazinelist = dh.MagazineLoader();
            productList.Add(booklist);
            productList.Add(magazinelist);
            productList.Add(musiclist);
            cbProduct.SelectedIndex    = 0;
            worker.DoWork             += new DoWorkEventHandler(Worker_DoWork);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Worker_RunWorkerCompleted);
            worker.ProgressChanged    += Worker_ProgressChanged;
        }
Exemple #6
0
        private void btnRoot_Click(object sender, EventArgs e)
        {
            Logger.logger(" Main Form Root");
            DataBaseHandler dh   = DataBaseHandler.getInstance();
            RootForm        root = new RootForm();

            root.ShowDialog();
            booklist.Clear();
            musiclist.Clear();
            magazinelist.Clear();
            CurrentProductList.Clear();
            booklist = dh.BookLoader();
            CurrentProductList.AddRange(booklist);

            musiclist    = dh.MusicCDLoader();
            magazinelist = dh.MagazineLoader();
            productList.Clear();
            productList.Add(booklist);
            productList.Add(magazinelist);
            productList.Add(musiclist);

            btnRoot.Visible = Isroot;
            cbProduct_SelectedIndexChanged(cbProduct, null);
        }
Exemple #7
0
        private void pbLogin_Click(object sender, EventArgs e)
        {
            DataBaseHandler dh       = DataBaseHandler.getInstance();
            Customer        logined  = Customer.getInstance();
            Customer        customer = dh.CustomerHandler(txtUsername.Text, txtPassword.Text);

            if (customer != null)
            {
                this.Hide();
                logined = customer;
                Logger.logger("Login");
                MainForm mainform = new MainForm();
                mainform.ShowDialog();
                mainform = null;
                GC.Collect();
                txtUsername.Clear();
                txtPassword.Clear();
                this.Show();
            }
            else
            {
                MessageBox.Show("Wrong Username or Password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }