示例#1
0
        private void CheckLogin()
        {
            //check validate

            using (var db = new ShopDataContext())
            {
                var user = db.Users.Where(
                    x => x.UserName.Equals(txtUserName.Text))
                           .SingleOrDefault();
                if (user != null)
                {
                    if (user.Password.Equals(txtPassword.Text))
                    {
                        //ok
                        new frmMain(user).Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Password invalid!");
                    }
                }
                else
                {
                    MessageBox.Show("User name not exist!");
                }
            }
        }
示例#2
0
 private void loadOrders()
 {
     using (var db = new ShopDataContext())
     {
         DateTime b_month = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
         var      orders  = from o in db.Orders
                             //   where o.OrderDate>= b_month&& o.OrderDate>DateTime.Now
                            orderby o.Status, o.Id descending
                  select new //noi bang co truong moi tham chieu
         {
             o.Id,
             o.OrderDate,
             o.Customer,
             Employee = o.User.FullName,
             Total    = o.OrderDetails.Count > 0? o.OrderDetails.Sum(d => d.Quantity * d.Price):0,
             Status   = o.Status == 1?"Pending":"Finish"
         };
         dgvOrdersList.DataSource = orders;
         dgvOrdersList.Columns["Id"].DefaultCellStyle.Format        = "D5";
         dgvOrdersList.Columns["total"].DefaultCellStyle.Format     = "N0";
         dgvOrdersList.Columns["OrderDate"].DefaultCellStyle.Format = "dd/MM/yyyy";
     }
 }