public void Class_Equals_equality_should_work()
        {
            var expected     = new Pooh(42);
            var expectedExpr = Constant(expected, typeof(Pooh));

            var paramExpr      = Parameter(typeof(Pooh), "x");
            var isExpectedExpr = Lambda(Equal(paramExpr, expectedExpr), paramExpr);

            var isExpected = isExpectedExpr.CompileFast <Func <Pooh, bool> >(true);

            Assert.IsTrue(isExpected(expected));
            Assert.IsFalse(isExpected(new Pooh(53)));
        }
コード例 #2
0
        async void SaveButton_Clicked(object sender, EventArgs e)
        {
            var isOk = await DisplayAlert("ยืนยัน", "คุณต้องการบันทึกใช่หรือไม่", "ใช่", "ไม่ใช่");

            if (isOk)
            {
                if (pooh == null)
                {
                    var product = new Pooh();
                    product.Name                  = nameEntry.Text;
                    product.Lastname              = lastnameEntry.Text;
                    product.Age                   = int.Parse(ageEntry.Text);
                    genderPicker.SelectedItem     = product.Sex;
                    departmentPicker.SelectedItem = product.Department;
                    product.Phone                 = int.Parse(phoneEntry.Text);
                    product.Email                 = emailEntry.Text;
                    product.Address               = addressEditor.Text;
                    statusPicker.SelectedItem     = product.Status;

                    var id = App.DbHelper.Addproduct(product);
                    await DisplayAlert("บันทึกสำเร็จ", "รหัสสินค้าของท่านคือ" + id, "ตกลง");
                }

                else
                {
                    pooh.Name       = nameEntry.Text;
                    pooh.Lastname   = lastnameEntry.Text;
                    pooh.Age        = int.Parse(ageEntry.Text);
                    pooh.Sex        = genderPicker.SelectedItem.ToString();
                    pooh.Department = departmentPicker.SelectedItem.ToString();
                    pooh.Phone      = int.Parse(phoneEntry.Text);
                    pooh.Email      = emailEntry.Text;
                    pooh.Status     = statusPicker.SelectedItem.ToString();
                    pooh.Children   = chlidLabel.ToString();
                    pooh.Address    = addressEditor.Text;
                    pooh.Salary     = decimal.Parse(salaryLabel.Text);


                    var id = App.DbHelper.UpdateProduct(pooh);
                    await DisplayAlert("บันทึกสำเร็จ", "แก้ไขข้อมูลสินค้า" + id, "ตกลง");
                }
                await Navigation.PopModalAsync();
            }
        }
コード例 #3
0
 public int UpdatePooh(Pooh pooh)
 {
     return(db.Update(pooh));
 }
コード例 #4
0
 public int DeletePooh(Pooh pooh)
 {
     return(db.Delete(pooh));
 }
コード例 #5
0
 public int Add(Pooh pooh)
 {
     db.Insert(pooh);
     return(pooh.Id);
 }