Example #1
0
 private void Btn_Click(object sender, EventArgs e)
 {
     Guna.UI.WinForms.GunaButton btn = sender as Guna.UI.WinForms.GunaButton;
     if (UserName != "")
     {
         string UserName  = this.UserName;
         string ItemName  = btn.Text;
         float  SalePrice = float.Parse(HomeController.PriceItem(ItemName).Tables[0].Rows[0][0].ToString());
         float  Quantity  = 1;
         bool   check     = OrderItemsController.AddCart(UserName, PassWord, ItemName, SalePrice, Quantity, ref err);
         if (check == true)
         {
             MessageBox.Show("Bạn đã thêm " + ItemName + " vào giỏ hàng thành công");
             this.lblShowCart.Text = OrderItemsController.ShowTotalDetails(UserName, PassWord).Tables[0].Rows[0][0].ToString();
         }
         else
         {
             MessageBox.Show("Bạn đã thêm món ăn vào giỏ hàng thất bại");
         }
     }
     else
     {
         DialogResult dialogResult;
         dialogResult = MessageBox.Show("Mời bạn đăng nhập để sử dụng tính năng này", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
         if (dialogResult == DialogResult.OK)
         {
             this.Hide();
             frmSignIn frmSign = new frmSignIn();
             frmSign.ShowDialog();
             this.Close();
         }
     }
 }
Example #2
0
 private void btnShoppingCart_Click(object sender, EventArgs e)
 {
     if (UserName != "")
     {
         this.Hide();
         frmShoppingCart frmCart = new frmShoppingCart(UserName, PassWord);
         frmCart.ShowDialog();
         this.lblShowCart.Text = OrderItemsController.ShowTotalDetails(UserName, PassWord).Tables[0].Rows[0][0].ToString();
         this.Show();
     }
     else
     {
         DialogResult dialogResult;
         dialogResult = MessageBox.Show("Mời bạn đăng nhập để sử dụng tính năng này", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
         if (dialogResult == DialogResult.OK)
         {
             this.Hide();
             frmSignIn frmSign = new frmSignIn();
             frmSign.ShowDialog();
             this.Close();
         }
     }
 }
Example #3
0
        public frmVegetableShop(string UserName, string PassWord, string Role)
        {
            this.UserName = UserName;
            this.PassWord = PassWord;
            this.Role     = Role;
            InitializeComponent();

            if (UserName == "")
            {
                btnAccount.Text          = "Username ▼";
                this.lblShowCart.Visible = false;
            }
            else
            {
                this.lblShowCart.Text = OrderItemsController.ShowTotalDetails(UserName, PassWord).Tables[0].Rows[0][0].ToString();
                ImageUser             = UserController.ImageUser(UserName).Tables[0].Rows[0][0].ToString();
                if (ImageUser != "")
                {
                    string appPath  = Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10)) + @"\images\imagesUser\";
                    string FileName = appPath + ImageUser;
                    btnAccount.Image = Image.FromFile(FileName);
                }
                this.btnLogOut.Visible              = true;
                btnAccount.Text                     = UserName + "▼";
                this.btnSignIn.Visible              = false;
                this.btnSignUp.Visible              = false;
                this.btnInformationAccount.Visible  = true;
                this.btnInformationAccount.Location = new Point(3, 6);
                this.btnLogOut.Location             = new Point(3, 54);
            }
            if (Role == "Admin")
            {
                this.btnAddItem.Visible    = true;
                this.btnAddSeller.Visible  = true;
                this.btnImportItem.Visible = true;
                this.btnManagement.Visible = true;
                this.btnStatistic.Visible  = true;
            }
            if (Role == "Seller")
            {
                this.btnImportItem.Visible = true;
                this.btnManagement.Visible = true;
                this.pnManagement.Height   = 56;
                this.btnStatistic.Visible  = true;
            }
            if (Role == "Customer")
            {
                this.btnStatistic.Visible = true;
            }
            int xptb  = 65;
            int xbtn  = 65;
            int xlbl  = 111;
            int count = 0;

            dtItem                = HomeController.ShowItem(UserName).Tables[0];
            countPaging           = dtItem.Rows.Count / 6;
            this.lblShowPage.Text = "1 / " + countPaging.ToString();
            while (count < 6 && count < dtItem.Rows.Count)
            {
                DataRow dr = dtItem.Rows[count];
                Guna.UI.WinForms.GunaPictureBox ptb = new Guna.UI.WinForms.GunaPictureBox();
                Guna.UI.WinForms.GunaButton     btn = new Guna.UI.WinForms.GunaButton();
                Guna.UI.WinForms.GunaLabel      lbl = new Guna.UI.WinForms.GunaLabel();
                string ImageTemp = Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10)) + @"\images\imagesProduct\" + dr["Image"].ToString();

                //PictureBox
                ptb.Location    = new Point(xptb, 33);
                ptb.Size        = new Size(162, 162);
                ptb.Image       = Image.FromFile(ImageTemp);
                ptb.SizeMode    = PictureBoxSizeMode.StretchImage;
                ptb.BorderStyle = BorderStyle.FixedSingle;

                //Button
                btn.Location = new Point(xbtn, 220);
                btn.Size     = new Size(162, 36);
                string image = Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10)) + @"\images\cart-plus.png";
                btn.Image            = Image.FromFile(image);
                btn.Text             = dr["ItemName"].ToString();
                btn.Font             = new Font("Tahoma", 10, FontStyle.Bold);
                btn.ForeColor        = Color.Black;
                btn.OnHoverForeColor = Color.Black;
                btn.ImageAlign       = HorizontalAlignment.Right;
                btn.ImageSize        = new Size(20, 20);
                btn.BaseColor        = Color.Transparent;
                btn.Cursor           = Cursors.Hand;
                btn.OnHoverBaseColor = Color.LightGray;
                btn.Click           += Btn_Click;

                //Label
                lbl.Location = new Point(xlbl, 198);
                lbl.Font     = new Font("Tahoma", 12, FontStyle.Bold);
                lbl.Text     = dr["SalePrice"].ToString() + "₫";



                xlbl += 212;
                xptb += 212;
                xbtn += 212;


                pnItems.Controls.Add(ptb);
                pnItems.Controls.Add(btn);
                pnItems.Controls.Add(lbl);

                count = count + 1;
            }
            int i = dtItem.Rows.Count / 6;

            countPaging = i;
            int xbtnPaing = 450;

            for (int j = 1; j <= i; j++)
            {
                //Button Paging
                Guna.UI.WinForms.GunaButton btnPaging = new Guna.UI.WinForms.GunaButton();
                btnPaging.Location         = new Point(xbtnPaing, 327);
                btnPaging.Size             = new Size(35, 35);
                btnPaging.BaseColor        = Color.Silver;
                btnPaging.BorderColor      = Color.Black;
                btnPaging.BorderSize       = 1;
                btnPaging.Font             = new Font("Tahoma", 9, FontStyle.Bold);
                btnPaging.ForeColor        = Color.Black;
                btnPaging.Image            = null;
                btnPaging.Text             = j.ToString();
                btnPaging.Cursor           = Cursors.Hand;
                btnPaging.TextAlign        = HorizontalAlignment.Center;
                btnPaging.OnHoverBaseColor = Color.LightGray;
                btnPaging.OnHoverForeColor = Color.Black;
                btnPaging.Click           += BtnPaging_Click;
                xbtnPaing += 34;

                pnItems.Controls.Add(btnPaging);
            }
        }