private void btnLuu_Click(object sender, EventArgs e) { if (flagluu != 1) { if (flagluu != 2) { return; } var db = new MyDBContextDataContext(); var tb = (from s in db.tbDanhSachSanPhams where s.MaSanPham == maSanPhamTextEdit.Text select s) .Single(); tb.TenKhachHang = txtKhachHang.Text; tb.TenSanPham = TENSANPHAMTextEdit.Text; tb.LoaiSanPham = txtLoaiSanPham.Text; tb.PhuongPhapIn = txtPhuongPhapIn.Text; tb.KichThuoc = KICHTHUOCTextEdit.Text; tb.DonViTinh = txtDonViTinh.Text; tb.GiaCongMatPhai = GIACONGMATPHAITextEdit.Text; tb.GiaCongMatTrai = GIACONGMATTRAITextEdit.Text; tb.MauMatPhai = MAUMATPHAITextEdit.Text; tb.MauMatTrai = MAUMATTRAITextEdit.Text; tb.PhuongPhapCat = PHUONGPHAPCATTextEdit.Text; tb.BoGoc = BOGOCTextEdit.Text; tb.Lo = LOTextEdit.Text; tb.XoChi = XOCHITextEdit.Text; tb.TinhTrang = TINHTRANGTextEdit.Text; tb.GhiChu = GHICHUTextEdit.Text; db.SubmitChanges(); MessageBox.Show("Cập nhật Thành Công"); frmDanhSachSanPham_Load(sender, e); } else { var db = new MyDBContextDataContext(); var tb = new tbDanhSachSanPham(); dt = con.GetData("select MaSanPham from tbDanhSachSanPham order by (MaSanPham) asc"); tb.MaSanPham = SinhMaTuDong(dt); tb.TenKhachHang = txtKhachHang.Text; tb.TenSanPham = TENSANPHAMTextEdit.Text; tb.LoaiSanPham = txtLoaiSanPham.Text; tb.PhuongPhapIn = txtPhuongPhapIn.Text; tb.KichThuoc = KICHTHUOCTextEdit.Text; tb.DonViTinh = txtDonViTinh.Text; tb.GiaCongMatPhai = GIACONGMATPHAITextEdit.Text; tb.GiaCongMatTrai = GIACONGMATTRAITextEdit.Text; tb.MauMatPhai = MAUMATPHAITextEdit.Text; tb.MauMatTrai = MAUMATTRAITextEdit.Text; tb.PhuongPhapCat = PHUONGPHAPCATTextEdit.Text; tb.BoGoc = BOGOCTextEdit.Text; tb.Lo = LOTextEdit.Text; tb.XoChi = XOCHITextEdit.Text; tb.TinhTrang = TINHTRANGTextEdit.Text; tb.GhiChu = GHICHUTextEdit.Text; db.tbDanhSachSanPhams.InsertOnSubmit(tb); db.SubmitChanges(); MessageBox.Show("Thêm Sản Phẩm Thành Công"); frmDanhSachSanPham_Load(sender, e); } }
void load() { string sql = "select RoomCode from APM_Room"; DataTable dt = DBHelper.GetData(sql); int RoomID = 0; string RoomState = ""; string Sanname = ""; foreach (DataRow row in dt.Rows) { RoomID = Convert.ToInt32(row["RoomCode"]); string sql1 = string.Format("select RoomCode from APM_Room where RoomCode={0}", RoomID); DataTable dt1 = DBHelper.GetData(sql1); RoomState = dt1.Rows[0][0].ToString(); string sql2 = "select RoomName from APM_Room where RoomCode=" + RoomID; DataTable dt2 = DBHelper.GetData(sql2); if (dt2.Rows.Count > 0) { Sanname = dt2.Rows[0][0].ToString(); } else { Sanname = RoomState; } UCRoom roomInfo = new UCRoom() { RoomNum = RoomID, Status = RoomState, InUsers = RoomID % 7 == 0 ? null : new List <UCRoom.User>() { new UCRoom.User() { UserName = Sanname } } }; roomInfo.Tag = RoomID; roomInfo.Click += UCRoom_Click; roomInfo.Name = "Số" + RoomID; flowLayoutPanel1.Controls.Add(roomInfo); } }
public List <Room_OBJ> LoadPTNlist(string id) { List <Room_OBJ> ptnlist = new List <Room_OBJ>(); DataTable data = db.GetData("select RoomCode,RoomName,Floor from APM_Room where Roomcode not like N'%Sys%'" + id); foreach (DataRow item in data.Rows) { Room_OBJ roommap = new Room_OBJ(item); ptnlist.Add(roommap); } return(ptnlist); }