private void cbQuyen_SelectedIndexChanged(object sender, EventArgs e) { if (quyen != 3) { quyen = Ham.GetIdFromCombobox(cbQuyen.SelectedItem.ToString()); } }
private void Opslaan() { try { string stringetje = "Bestelling_" + DateTime.Now.ToShortDateString().Replace("/", "-") + "om" + DateTime.Now.ToShortTimeString().Replace(":", "-"); SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = stringetje; dlg.DefaultExt = ".pizza"; dlg.Filter = "Pizza bestelDocument |*.pizza"; if (dlg.ShowDialog() == true) { using (StreamWriter bestand = new StreamWriter(dlg.FileName)) { bestand.WriteLine(SmallPizza.ToString()); bestand.WriteLine(MediumPizza.ToString()); bestand.WriteLine(LargePizza.ToString()); bestand.WriteLine(DikkeKorst.ToString()); bestand.WriteLine(ExtraKaas.ToString()); bestand.WriteLine(AantalPizzas); bestand.WriteLine(Ham.ToString()); bestand.WriteLine(Ananas.ToString()); bestand.WriteLine(Salami.ToString()); } } } catch (Exception ex) { MessageBox.Show("Kan het bestand niet opslaan \n" + ex.Message); } }
private void GetAnh(int id) { var dataAnh = conn.getDataTable("SELECT id,sanphamId,title,anh FROM AnhSanPham where sanphamId = " + id); btnXoaAnh1.Visible = false; btnXoaAnh2.Visible = false; if (dataAnh.Rows.Count > 0) { if (dataAnh.Rows.Count == 1) { picAnh1.Image = Ham.GetImageFromString(dataAnh.Rows[0][3].ToString()); btnXoaAnh1.Tag = dataAnh.Rows[0][0].ToString(); btnXoaAnh1.Visible = true; } else { picAnh1.Image = Ham.GetImageFromString(dataAnh.Rows[0][3].ToString()); picAnh2.Image = Ham.GetImageFromString(dataAnh.Rows[1][3].ToString()); btnXoaAnh1.Tag = dataAnh.Rows[0][0].ToString(); btnXoaAnh2.Tag = dataAnh.Rows[1][0].ToString(); btnXoaAnh2.Visible = true; btnXoaAnh1.Visible = true; } } else { picAnh1.Image = null; picAnh2.Image = null; } }
private void btnDoiMatKhau_Click(object sender, EventArgs e) { try { if (txtPassword2.Text == txtPassword3.Text) { if (Ham.EncodePassword(txtPassword1.Text) == passwordCu) { cn.ExecuteNonQuery("UPDATE HTUSER set matkhau = N'" + Ham.EncodePassword(txtPassword2.Text) + "' where id = " + id); MessageBox.Show("Thay đổi thông tin thành công", "Thông báo"); passwordCu = Ham.EncodePassword(txtPassword2.Text); txtPassword2.Text = ""; txtPassword1.Text = ""; txtPassword3.Text = ""; } else { MessageBox.Show("Mật khẩu cũ không chính xác", "Thông báo"); } } else { MessageBox.Show("Mật khẩu mới không trùng nhau", "Thông báo"); } } catch (Exception) { throw; } }
private void updateNhanVien() { string ten, sdt, quequan, username; int id, active, quyen; bool gioitinh; DateTime ngaysinh; id = int.Parse(txtMa.Text); ten = txtTen.Text; sdt = txtSdt.Text; quequan = txtQueQuan.Text; username = txtUsername.Text; quyen = Ham.GetIdFromCombobox(cbQuyen.SelectedItem.ToString()); gioitinh = Ham.NamNuToTrueFalse(cbGioiTinh.SelectedItem.ToString()); active = checkActive.Checked ? 1 : 0; ngaysinh = dateTimePicker1.Value; string sql = "update HTUser set ten = N'" + ten + "',ngaysinh = '" + ngaysinh + "',sdt = '" + sdt + "',gioitinh = '" + gioitinh + "'" + ",diachi = N'" + quequan + "',taikhoan = '" + username + "',active = " + active + ",roleId =" + quyen + " where id = " + id; try { cn.ExecuteNonQuery(sql); getDataNhanVien(); } catch (Exception) { MessageBox.Show("Kiểm tra lại thông tin", "Thông báo!"); } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Pizza orderPizza; List <Pizza> orderList = new List <Pizza>(); orderPizza = new MediumPizza(); orderPizza = new DoubleCheese(orderPizza); // Console.WriteLine(orderPizza); orderList.Add(orderPizza); orderPizza = new SmallPizza(); orderPizza = new Olive(orderPizza); orderPizza = new Ham(orderPizza); // Console.WriteLine(orderPizza); orderList.Add(orderPizza); orderPizza = new BigPizza(); orderPizza = new Ham(orderPizza); orderPizza = new DoubleCheese(orderPizza); orderPizza = new Olive(orderPizza); orderList.Add(orderPizza); foreach (var pizza in orderList) { Console.WriteLine(pizza); } Console.ReadLine(); }
static void Main(string[] args) { //LargePizza largePizza = new LargePizza(); Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Peppers(largePizza); //Console.WriteLine(largePizza.Description); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculateCost()); Console.ReadKey(); Console.WriteLine(); Beverage coffee = new Espresso(); coffee = new Mocha(coffee); coffee = new Mocha(coffee); coffee = new Whip(coffee); Console.WriteLine(coffee.GetDescription()); Console.WriteLine("{0:C2}", coffee.Cost()); Console.ReadKey(); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { //if (e.ColumnIndex == 0 && e.RowIndex != -1) //{ // //var confirmResult = MessageBox.Show("Bạn có muốn xóa ??", // // "Cảnh báo!!", // // MessageBoxButtons.YesNo); // //if (confirmResult == DialogResult.Yes) // //{ // // //int id = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString()); // //} //} //else if (e.RowIndex != -1) //{ txtMa.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTen.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); if (!String.IsNullOrEmpty(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString())) { dateTimePicker1.Value = DateTime.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString()); } txtSdt.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); cbGioiTinh.SelectedItem = Ham.TrueFalseToNamNu(Boolean.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString())); txtQueQuan.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); txtUsername.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); //txtUsername.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString(); checkActive.Checked = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString() == "True" ? true : false; Console.WriteLine(checkActive.Checked); cbQuyen.SelectedItem = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString(); //} }
private void getDataNhanVien() { sSearch = txtSearch.Text; if (cbTrangThai.SelectedIndex == 0) { sTrangThai = 2; } else if (cbTrangThai.SelectedIndex == 1) { sTrangThai = 1; } else { sTrangThai = 0; } if (cbSearchChucVu.SelectedIndex == 0) { sRole = 0; } else { sRole = Ham.GetIdFromCombobox(cbSearchChucVu.SelectedItem.ToString()); } DataTable tb = cn.getDataTable("select u.id,u.ten,u.ngaysinh,u.sdt,u.gioitinh,u.diachi,u.taikhoan,u.active,(convert(varchar,u.roleId) + ' -' + r.ten) as 'Quyền' from HTUser u " + "join HTRole r on u.roleId = r.id where (" + sTrangThai + " = 2 or u.active = " + sTrangThai + ") and (" + sRole + " = 0 or u.roleid = " + sRole + ")"); dataGridView1.DataSource = tb; }
private void iconButton4_Click(object sender, EventArgs e) { if (Int32.Parse(lbKho.Text) > Int32.Parse(txtSL.Text)) { txtSL.Text = (Int32.Parse(txtSL.Text) + 1).ToString(); soluong = Int32.Parse(txtSL.Text); lbTienChu.Text = Ham.ChuyenSo((giaban * soluong).ToString()) + " đồng"; } }
public void LargePizzaWithCheeseAndHam() { Pizza pizza = new LargePizza(); pizza = new Cheese(pizza); pizza = new Ham(pizza); Assert.AreEqual("Large Pizza, Cheese Topping, Ham Topping", pizza.Description()); Assert.AreEqual(11.75, pizza.Cost()); }
public void Run() { Sandwich sandwich = new SmallSandwich(); sandwich = new Ham(sandwich); sandwich = new Pickle(sandwich); // sandwich.GetDescription() --> "Small sandwich, ham, pickle" // sandwich.GetPrice() --> 7.75 }
static void Main(string[] args) { Pizza p = new Ham(new Cheese(new LargePizza())); // L Console.WriteLine(p.GetDescription()); Console.WriteLine(p.CalculateCost()); Console.ReadKey(); }
public void CreateMediumPizzaWithCheeseHamPeppersAndCorrectPrice() { IPizza sut = new MediumPizza(); sut = new Cheese(sut); sut = new Ham(sut); sut = new Peppers(sut); Assert.Equal(10.25, sut.CalculateCost()); }
public void Allow_Being_Decorated_With_Cheese_And_Ham() { Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); Assert.Equal("Large Pizza, Cheese, Ham", largePizza.GetDescription()); Assert.Equal(11.25m, largePizza.CalculateCost()); }
private void TaoMaXacNhan() { string code = ""; string email, username; email = txtEmail.Text; username = txtUsername.Text; code = Ham.RamdomCode(6); cn.ExecuteNonQuery("UPDATE HTUser set Code = '" + code + "' where email = '" + email + "' and taikhoan = '" + username + "'"); GuiMa(code); }
private void cbSNhanVien_SelectedIndexChanged(object sender, EventArgs e) { if (cbSNhanVien.SelectedIndex != 0) { SIdNV = Ham.GetIdFromCombobox(cbSNhanVien.SelectedItem.ToString()); } else { SIdNV = 0; } getAll(); }
public static string Run() { Pizza largePizza = new LargePizza(); // wrap large pizza with our cheese decorator largePizza = new Cheese(largePizza); // wrap our large cheese pizza with our ham decorator largePizza = new Ham(largePizza); return($"{largePizza.GetDescription()} cost: {largePizza.CalculateCost():C2}"); }
private static void Main(string[] args) { Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Peppers(largePizza); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculateCost()); Console.ReadLine(); }
static void executeDecorator() { Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Pepper(largePizza); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculateCost()); Console.ReadKey(); }
public static void Bake() { Pizza pizza = new LargePizza(); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Ham(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Cheese(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Corn(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); pizza = new Cheese(pizza); Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}"); }
public void DecoratorTest() { IOrderable pizza = new Margerita(); IOrderable ham = new Ham(pizza); IOrderable kebab = new Kebab(ham); IOrderable onion = new Onion(kebab); var expectedPizza = $"Margerita{Environment.NewLine} with ham{Environment.NewLine} with kebab{Environment.NewLine} with onion"; var expectedPrice = 125; var actualPizza = onion.GetName(); var actualPrice = onion.GetPrice(); Assert.AreEqual(expectedPizza, actualPizza); Assert.IsTrue(expectedPrice == actualPrice); }
/// <summary> /// Map DBTopping => Topping /// Uses enum to determine which topping class to return. /// </summary> /// <param name="entity"></param> /// <returns></returns> public ATopping Map(DBTopping entity) { ATopping topping = null; switch (entity.TOPPING) { case TOPPINGS.BACON: topping = new Bacon(); break; case TOPPINGS.CHICKEN: topping = new Chicken(); break; case TOPPINGS.EXTRACHEESE: topping = new ExtraCheese(); break; case TOPPINGS.GREENPEPPER: topping = new GreenPepper(); break; case TOPPINGS.HAM: topping = new Ham(); break; case TOPPINGS.NOCHEESE: topping = new NoCheese(); break; case TOPPINGS.PINEAPPLE: topping = new Pineapple(); break; case TOPPINGS.REDPEPPER: topping = new RedPepper(); break; case TOPPINGS.SAUSAGE: topping = new Sausage(); break; default: throw new ArgumentException("Topping not recognized. Topping could not be mapped properly"); } topping.ID = entity.ID; return(topping); }
public void CreateMediumPizzaWithCheeseHamPeppers() { IPizza sut = new MediumPizza(); sut = new Cheese(sut); sut = new Ham(sut); sut = new Peppers(sut); var expected = new MediumPizza { Description = "Medium Pizza, Cheese, Ham, Peppers" }; Assert.Equal(expected.Description, sut.GetDescription()); }
static void Main(string[] args) { EggRoll p1 = new EggRoll(100, "EggRoll 1"); Cheese cheese = new Cheese(12, "cheese"); Ham ham = new Ham(5, "ham"); Egg egg = new Egg(10, "egg"); Console.WriteLine("Material: "); ham.Decorate(p1); cheese.Decorate(ham); egg.Decorate(cheese); egg.Calculate(); }
private void TaiTaiKhoan() { try { string ten, ngaysinh, sdt, quequan, username, password, email; bool active = true; bool gioitinh; ten = txtHoTen.Text; ngaysinh = dateNgaySinh.Value.ToString(); gioitinh = cbGioiTinh.SelectedItem.ToString() == "Nam" ? true : false; sdt = txtSDT.Text; quequan = txtDiaChi.Text; username = txtTaiKhoan.Text; password = Ham.EncodePassword(txtMatKhau.Text); email = txtEmail.Text; if (!String.IsNullOrEmpty(txtHoTen.Text) && !String.IsNullOrEmpty(txtMatKhau.Text) && !String.IsNullOrEmpty(txtTaiKhoan.Text)) { if (txtMatKhau2.Text == txtMatKhau.Text) { if (!CheckUsername(username)) { MessageBox.Show("Tài khoản đã tồn tại trong hệ thống!", "Thông báo!"); } else { string sql = "Insert into HTUser (ten,ngaysinh,sdt,gioitinh,diachi,taikhoan,matkhau,active,roleId,email) values(N'" + ten + "','" + ngaysinh + "','" + sdt + "','" + gioitinh + "',N'" + quequan + "','" + username + "','" + password + "','" + active + "'," + quyen + ",'" + email + "')"; conn.ExecuteNonQuery(sql); MessageBox.Show("Tạo tài khoản thành công!", "Thông báo"); } } else { MessageBox.Show("Mật khẩu không khớp!", "Thông báo!"); } } else { MessageBox.Show("Kiểm tra lại thông tin!", "Thông báo!"); } } catch (Exception) { MessageBox.Show("Kiểm tra lại thông tin!", "Thông báo!"); } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; switch (info.ButtonID) { case 0: { from.SendMessage("You Have Created Meat."); Item o_item = null; switch (Utility.Random(3)) { case 0: o_item = new Ham(); break; case 1: o_item = new CookedBird(); break; case 2: o_item = new Sausage(); break; } from.AddToBackpack(o_item); from.CloseGump(typeof(CreateFoodGump)); break; } case 1: { from.SendMessage("You Have Created Fruits & Vegies."); Item o_item = null; switch (Utility.Random(3)) { case 0: o_item = new Apple(); break; case 1: o_item = new Carrot(); break; case 2: o_item = new Grapes(); break; } from.AddToBackpack(o_item); from.CloseGump(typeof(CreateFoodGump)); break; } } }
static void Main() { Pizza largePizza = new LargePizza(); //Adding Cheese to Large Pizza largePizza = new Cheese(largePizza); //Adding Ham to Large Pizza largePizza = new Ham(largePizza); //Adding Peppers to Large largePizza = new Peppers(largePizza); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculatePrice()); Console.ReadKey(); }
private void txtSL_TextChanged(object sender, EventArgs e) { try { if (Int32.Parse(lbKho.Text) < Int32.Parse(txtSL.Text)) { txtSL.Text = lbKho.Text; soluong = Int32.Parse(txtSL.Text); lbTienChu.Text = Ham.ChuyenSo((giaban * soluong).ToString()) + " đồng"; } } catch (Exception) { txtSL.Text = "1"; MessageBox.Show("Nhập số?", "Thông báo!"); } }
private void getAnh() { var data = conn.getDataTable("select top 2 anh from ANhSanPham where sanphamId = " + Id); if (data.Rows.Count > 0) { if (data.Rows.Count == 1) { picAnhBig.Image = Ham.GetImageFromString(data.Rows[0][0].ToString()); picAnh1.Image = Ham.GetImageFromString(data.Rows[0][0].ToString()); } else { picAnhBig.Image = Ham.GetImageFromString(data.Rows[0][0].ToString()); picAnh1.Image = Ham.GetImageFromString(data.Rows[0][0].ToString()); picAnh2.Image = Ham.GetImageFromString(data.Rows[1][0].ToString()); } } }
private void getSP() { var data = conn.getDataTable("select s.id,s.ten,s.soluong,s.giaban,s.giaKM,s.mausac, s.manhinh,s.camera,s.cpu,s.ram,s.rom,s.baohanh,s.phukiendikem,s.ngaynhap,s.mota,s.luotxem,s.danhgia,l.ten from SanPham s join loaisanpham l on s.loaispId = l.id where s.id = " + Id); if (data.Rows.Count > 0) { lbTen.Text = data.Rows[0][1].ToString() + " - " + data.Rows[0][10].ToString() + " GB"; if (data.Rows[0][4].ToString() == "0") { lbGiaKM.Text = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][3].ToString())) + " đồng"; giaban = Int32.Parse(data.Rows[0][3].ToString()); } else { lbGiaKM.Text = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][4].ToString())) + " đồng"; lbgiaBan.Text = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][3].ToString())) + " đồng"; giaban = Int32.Parse(data.Rows[0][4].ToString()); } lbTienChu.Text = Ham.ChuyenSo((giaban * Int32.Parse(txtSL.Text)).ToString()) + " đồng"; lbMauSac.Text = data.Rows[0][5].ToString(); if (data.Rows[0][2].ToString() == "0") { lbKho.Text = "Hết hàng"; btnDatHang.Enabled = false; btnGiam.Enabled = false; btnTang.Enabled = false; txtSL.Enabled = false; } else { lbKho.Text = data.Rows[0][2].ToString(); } lbMota.Text = data.Rows[0][14].ToString(); lbManHinh.Text = data.Rows[0][6].ToString() + " INCH FULLHD"; lbCamera.Text = data.Rows[0][7].ToString(); lbCPU.Text = data.Rows[0][8].ToString(); lbRam.Text = data.Rows[0][9].ToString() + "GB"; lbRom.Text = data.Rows[0][10].ToString() + "GB"; lbLoaiSanPham.Text = data.Rows[0][17].ToString(); } }
public void UntitledTest() { var sandwich = new BaseSandwich(); Assert.AreEqual(sandwich.Price, 1.00m); var wheatBreadSandwich = new WheatBread(sandwich); Assert.AreEqual(wheatBreadSandwich.Price, 2.00m); var hamSandwich = new Ham(wheatBreadSandwich); Assert.AreEqual(hamSandwich.Price, 4.00m); var baconHam = new Bacon(new Bacon(hamSandwich)); Assert.IsTrue(baconHam.InnerComponent is Bacon); Assert.AreEqual(baconHam.Price, 5.00m); var discountedBaconHam = new BaconDiscount(new BaconDiscount(baconHam)); Assert.AreEqual(discountedBaconHam.Price, 4.00m); }