Example #1
0
        private static void ReloadProductList()
        {
            using (DatabaseController databaseController = new DatabaseController())
            {
                // Get from database

                /*
                 * List<ProductInfo> l = databaseController.GetProductInfos();
                 * productsList = new Dictionary<int, ProductInfo>(l.Count);
                 * foreach (ProductInfo product in l) { productsList.Add(product.Id, product); }
                 */
                productsList = databaseController.GetProductInfos();
            }
        }
Example #2
0
 private void BtnCashier_Click(object sender, EventArgs e)
 {
     if (info.Give < 0)
     {
         MessageBox.Show(NotEnougnMOney);
         return;
     }
     isConfirm = true;
     if (PrintPDF.Instance.createBill(info))
     {
         this.Close();
         DatabaseController.Insert_Bill(info);
         Console.WriteLine("Add bill to database success");
     }
 }
Example #3
0
        private static void Form_Click_Login(object sender, UserInfo e)
        {
            if (!DatabaseController.IsOnline())
            {
                MessageBox.Show("Không có kết nối mạng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            Form login_form = (Form)sender;

            InternetServiceHandler.Instance.Run();
            if (StoreAssistant_Authenticater.Authenticator.Login(ref e))
            {
                Form1 main_form = new Form1();
                main_form.LoadTheme();
                main_form.LoadFont();
                InternetServiceHandler.Instance.OfflineModeDetected = new EventHandler((s, evt) =>
                {
                    Application.Restart();
                });

                /*
                 * main_form.SignOut += new EventHandler((object obj, EventArgs etc) =>
                 * {
                 *  login_form.Show();
                 *  main_form.Close();
                 * });
                 */
                main_form.FormClosed += new FormClosedEventHandler((object obj, FormClosedEventArgs target) =>
                {
                    if (login_form.Visible == false)
                    {
                        login_form.Close();
                    }
                    else
                    {
                        Application.Restart();
                    }
                });
                main_form.LoadUser();
                main_form.LoadWindowSize();
                main_form.Show();
                login_form.Hide();
            }
            else
            {
                MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng", "Đăng nhập thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void OpenAddProductDialog()
 {
     using (AddProductForm form = new AddProductForm())
     {
         form.ClickSubmitOK += new EventHandler <ProductInfo>((object sender, ProductInfo info) =>
         {
             using (DatabaseController databaseController = new DatabaseController())
             {
                 databaseController.InsertProduct(info);
                 //MessageBox.Show("Click On a product" + Environment.NewLine + info.ToString());
             }
             menuView1.AddMenuControl(info);
         });
         form.ShowDialog();
     }
 }
        private void OpenEditProductDialog(ProductInfo info, MenuControl target)
        {
            using (AddProductForm form = new AddProductForm(info))
            {
                form.ClickSubmitOK += new EventHandler <ProductInfo>((object sender, ProductInfo info2) =>
                {
                    using (DatabaseController databaseController = new DatabaseController())
                    {
                        databaseController.UpdateProduct(info2);

                        //MessageBox.Show("Click On a product" + Environment.NewLine + info.ToString());
                    }
                    target.SetData(info2);
                });
                form.ShowDialog();
            }
        }
 private void BtnSave_Click(object sender, EventArgs e)
 {
     string[] data = GetData();
     if ((data[0] == data[1]) && (data[2] == "-default-") && (data[0] == data[2]))
     {
         // Use default
         SaveData();
         StoreAssistant_Helper.AppManager.LoadSQLServerInfo(GetData());
         MessageBox.Show(Language.GetString("msgChangeOK"), Language.GetString("Success"), MessageBoxButtons.OK);
         this.Close();
     }
     else
     {
         using (DatabaseController databaseController = new DatabaseController())
         {
             try
             {
                 if (databaseController.CheckServerStructure(data[0], data[1], data[2]))
                 {
                     // Go on
                     SaveData();
                     StoreAssistant_Helper.AppManager.LoadSQLServerInfo(GetData());
                     using (DatabaseController databaseController2 = new DatabaseController())
                     {
                         databaseController2.CreateDefaultValue();
                     }
                     MessageBox.Show(Language.GetString("msgChangeOK"), Language.GetString("Success"), MessageBoxButtons.OK);
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show(Language.GetString("errWrongFormat"), Language.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return;
                 }
             }
             catch (Exception ex) { MessageBox.Show(ex.Message, Language.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); }
         }
     }
 }