public bool insertCon(string maHD, string makh, string thoihan, string loaixe, int soluong , DateTime ngaybatdau, DateTime ngaykethuc, string tien, string note) { SqlCommand cmd = new SqlCommand("insert into HopDong(Mahd,MaKH,ThoiHan,LoaiXe,SoLuong,NgayBatDau,NgayKetThuc,Tien,note)" + "values(@mahd,@makh,@thoihan,@loaixe,@soluong,@ngaybd,@ngaykt,@tien,@note)", mydb.getConnection); cmd.Parameters.Add("@mahd", SqlDbType.VarChar).Value = maHD; cmd.Parameters.Add("@makh", SqlDbType.VarChar).Value = makh; cmd.Parameters.Add("@thoihan", SqlDbType.VarChar).Value = thoihan; cmd.Parameters.Add("@loaixe", SqlDbType.VarChar).Value = loaixe; cmd.Parameters.Add("@soluong", SqlDbType.Int).Value = soluong; cmd.Parameters.Add("@ngaybd", SqlDbType.DateTime).Value = ngaybatdau; cmd.Parameters.Add("@ngaykt", SqlDbType.DateTime).Value = ngaykethuc; cmd.Parameters.Add("@tien", SqlDbType.VarChar).Value = tien; cmd.Parameters.Add("@note", SqlDbType.VarChar).Value = note; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool insertDETAILRECEIPT(string receipt, DateTime date, int idBrand, int idService, string nameService, int period, decimal total, string remain) { SqlCommand cmd = new SqlCommand("insert into tblDETAILSRECEIPT(receiptID,receiptDate,idBrand,idService,nameServices,period,total,remain)" + "values (@id,@date,@idBrand,@idSer,@name,@dis,@total,@remain)", mydb.getConnection); cmd.Parameters.Add("@id", SqlDbType.VarChar).Value = receipt; cmd.Parameters.Add("@date", SqlDbType.DateTime).Value = date; cmd.Parameters.Add("@idBrand", SqlDbType.Int).Value = idBrand; cmd.Parameters.Add("@idSer", SqlDbType.Int).Value = idService; cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = nameService; cmd.Parameters.Add("@dis", SqlDbType.Int).Value = period; cmd.Parameters.Add("@total", SqlDbType.Decimal).Value = total; cmd.Parameters.Add("@remain", SqlDbType.NVarChar).Value = remain; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
[HttpPost]// thuc hien dang nhap public ActionResult VerifyLogin(User user) { // kiem tra du lieu nhap if (ModelState.IsValid) { // truy van csdl string uid = null; using (var _context = new DA_QLTMDTEntities()) { // query id tu email va password de kiem tra dang nhap try { var id = (from u in _context.Users where u.Email == user.Email && u.Password == user.Password select u).FirstOrDefault(); uid = id.ToString(); } catch { } } if (uid != null) { mydb.closeConnection(); return(View("LoginSuccess")); } else { mydb.closeConnection(); return(View("Error")); } } return(View("Login")); }
public void loop(int day, int shift, DataTable table) { SqlCommand cmd = new SqlCommand("INSERT INTO calendar (day, shift, employee_id) VALUES (@day, @shift, @id)", mydb.getConnection); for (; shift <= 3; shift++) { if (Global.init > table.Rows.Count - 1) { Global.setInit(0); } cmd.Parameters.Clear(); cmd.Parameters.Add("@day", SqlDbType.Int).Value = day; cmd.Parameters.Add("@shift", SqlDbType.Int).Value = shift; cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(table.Rows[Global.init][0]); mydb.openConnection(); if (cmd.ExecuteNonQuery() == 0) { mydb.closeConnection(); } else { mydb.closeConnection(); } Global.increaseInit(); Global.setInitDatabase(); } }
public bool insertDETAILCON(string conID, string receiptID, string ptID, int idPackage, DateTime start, DateTime end, string status) { SqlCommand cmd = new SqlCommand("insert into tblDETAILSCONTRACT(cont_ID,receipt_ID,ptID,servicePACK,dateStart,dateDischarge,status)" + "values (@con,@rep,@pt,@pack,@start,@end,@status)", mydb.getConnection); cmd.Parameters.Add("@con", SqlDbType.VarChar).Value = conID; cmd.Parameters.Add("@rep", SqlDbType.VarChar).Value = receiptID; cmd.Parameters.Add("@pt", SqlDbType.VarChar).Value = ptID; cmd.Parameters.Add("@pack", SqlDbType.Int).Value = idPackage; cmd.Parameters.Add("@start", SqlDbType.DateTime).Value = start; cmd.Parameters.Add("@end", SqlDbType.DateTime).Value = end; cmd.Parameters.Add("@status", SqlDbType.NVarChar).Value = status; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
private bool managerLogin() { Manager manager = new Manager(); SqlCommand cmd = new SqlCommand("SELECT * FROM manager WHERE username=@username AND password=@password", mydb.getConnection); cmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = usernameBox.Text; cmd.Parameters.Add("@password", SqlDbType.NVarChar).Value = passwordBox.Text; SqlDataAdapter adpt = new SqlDataAdapter(cmd); DataTable table = new DataTable(); adpt.Fill(table); mydb.openConnection(); if (table.Rows.Count > 0) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
private void saveButton_Click(object sender, EventArgs e) { MY_DB mydb = new MY_DB(); User user = new User(); SqlCommand cmd = new SqlCommand("SELECT user_id, fname, lname, birthdate, gender, phone, address, picture, selected_courses FROM listUser WHERE user_id=@id", mydb.getConnection); cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(idBox.Text); SqlDataAdapter adpt = new SqlDataAdapter(); DataTable table = new DataTable(); adpt.SelectCommand = cmd; adpt.Fill(table); if (table.Rows.Count > 0) { for (int i = 0; i < selectedCourseListBox.Items.Count; i++) { int courseID = course.getCourseId(selectedCourseListBox.Items[i].ToString()); if (user.addCourse(Convert.ToInt32(idBox.Text), courseID, 0, "")) { MessageBox.Show("Saved " + selectedCourseListBox.Items[i].ToString()); } } selectedCourseListBox.Items.Clear(); mydb.closeConnection(); } else { MessageBox.Show("This ID is not available!!!", "Error"); mydb.closeConnection(); } if (user.selectedCourse(Convert.ToInt32(idBox.Text))) { } }
private void btnDelNV_Click(object sender, EventArgs e) { DialogResult traloi; traloi = MessageBox.Show("Bạn thực sự muốn xóa?", "Trả lời", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (traloi == DialogResult.OK) { MY_DB mydb = new MY_DB(); mydb.openConnection(); SqlTransaction objTrans = null; using (SqlConnection objConn = mydb.getConnection) { objTrans = objConn.BeginTransaction(); SqlCommand dlDV = new SqlCommand("update DatVe set MaNV=NULL where MaNV=" + txtMaNV.Text, mydb.getConnection, objTrans); SqlCommand dlDN = new SqlCommand("delete from DangNhap where MaNV=" + txtMaNV.Text, mydb.getConnection, objTrans); SqlCommand dlNV = new SqlCommand("delete from NhanVien where MaNV=" + txtMaNV.Text, mydb.getConnection, objTrans); try { dlDV.ExecuteNonQuery(); dlDN.ExecuteNonQuery(); dlNV.ExecuteNonQuery(); objTrans.Commit(); MessageBox.Show("Da xoa nhan vien" + txtMaNV.Text); } catch (Exception ex) { objTrans.Rollback(); MessageBox.Show(ex.Message); } mydb.closeConnection(); } } }
private void findBtn_Click(object sender, EventArgs e) { int ID = int.Parse(textBoxId.Text); mydb.openConnection(); SqlCommand cmd = new SqlCommand("SELECT fname,lname,bdate,gender,phone,adresss,picture FROM SinhVien WHERE id=@ID ", mydb.getConnection); cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID; SqlDataReader data = cmd.ExecuteReader(); while (data.Read()) { textBoxFName.Text = data.GetValue(0).ToString(); textBoxLName.Text = data.GetValue(1).ToString(); dateTimePicker1.Value = data.GetDateTime(2); string temp = data.GetString(3).ToString(); string gder = temp.Trim(); if (gder == "Male") { radioButton1.Checked = true; } else { radioButton2.Checked = true; } textBoxPhone.Text = data.GetValue(4).ToString(); textBoxAddress.Text = data.GetValue(5).ToString(); byte[] pic = (byte[])data.GetValue(6); MemoryStream picture = new MemoryStream(pic); pictureBox1.Image = Image.FromStream(picture); } mydb.closeConnection(); }
private void btnXoa_Click(object sender, EventArgs e) { int r = dgv_HopDong.CurrentCell.RowIndex; string strHD = dgv_HopDong.Rows[r].Cells[0].Value.ToString(); DialogResult traloi; traloi = MessageBox.Show("Bạn thực sự muốn xóa?", "Trả lời", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (traloi == DialogResult.OK) { MY_DB mydb = new MY_DB(); mydb.openConnection(); SqlTransaction objTrans = null; using (SqlConnection objConn = mydb.getConnection) { objTrans = objConn.BeginTransaction(); SqlCommand dlHSX = new SqlCommand($"update HangSanXuat set MaHD=NULL where MaHD=N'{txtMaHD.Text.Trim()}'", mydb.getConnection, objTrans); SqlCommand dlPHD = new SqlCommand($"delete from PhimHopDong where MaHD= N'{txtMaHD.Text.Trim()}'", mydb.getConnection, objTrans); try { dlHSX.ExecuteNonQuery(); dlPHD.ExecuteNonQuery(); objTrans.Commit(); MessageBox.Show("Da xoa hop dong" + txtMaHD.Text); } catch (Exception ex) { objTrans.Rollback(); MessageBox.Show(ex.Message); } mydb.closeConnection(); } } }
public static void setInitDatabase() { MY_DB mydb = new MY_DB(); SqlCommand cmd = new SqlCommand("UPDATE initial SET init = @init", mydb.getConnection); cmd.Parameters.Add("@init", System.Data.SqlDbType.Int).Value = init; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 0) { mydb.closeConnection(); } else { mydb.closeConnection(); } }
//Lay thong tin public DataTable getGROUPEMP() { SqlCommand cmd = new SqlCommand("select *from tblGROUPEMPLOYEE ", mydb.getConnection); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); mydb.closeConnection(); return(dt); }
private void signUpButton_Click(object sender, EventArgs e) { MY_DB db = new MY_DB(); SqlCommand cmd = new SqlCommand("INSERT INTO account (username, password, Id) VALUES (@username, @password, @id)", db.getConnection); cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Value = Convert.ToInt32(IDBox.Text); cmd.Parameters.Add("@username", System.Data.SqlDbType.VarChar).Value = textBoxUser.Text; cmd.Parameters.Add("@password", System.Data.SqlDbType.VarChar).Value = textBoxPass.Text; db.openConnection(); if (cmd.ExecuteNonQuery() == 1) { MessageBox.Show("You Have Sign Up Successfully"); db.closeConnection(); } else { db.closeConnection(); } }
//Dang ky tai khoan public bool insertAILITIES(string emID, string workID) { SqlCommand cmd = new SqlCommand("insert into ABILITIES(employeeID,workID)" + "values (@empID,@workID))", mydb.getConnection); cmd.Parameters.Add("@empID", SqlDbType.VarChar).Value = emID; cmd.Parameters.Add("@workID", SqlDbType.VarChar).Value = workID; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool insertBill(int IdBill, int IdDish, int amount) { SqlCommand command = new SqlCommand("INSERT INTO [BillInfo] (IdBill,IdDish,Amount) VALUES (@idB,@idD,@Am)", db.getConnection); command.Parameters.Add("@idB", SqlDbType.Int).Value = IdBill; command.Parameters.Add("@idD", SqlDbType.Int).Value = IdDish; command.Parameters.Add("@Am", SqlDbType.Int).Value = amount; db.openConnection(); if (command.ExecuteNonQuery() == 1) { db.closeConnection(); return(true); } else { db.closeConnection(); return(false); } }
public bool insertAccount(string username, string login, string logout, string status) { SqlCommand cmd = new SqlCommand("insert into tblCHECKLOGIN(usr,loginDate,logoutDate,status)" + "values(@user,@login,@logout,@status)", mydb.getConnection); cmd.Parameters.Add("@user", SqlDbType.VarChar).Value = username; cmd.Parameters.Add("@login", SqlDbType.VarChar).Value = login; cmd.Parameters.Add("@logout", SqlDbType.VarChar).Value = logout; cmd.Parameters.Add("@status", SqlDbType.VarChar).Value = status; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }//update CLASSROOM set classID=@id
public bool mySalary() { TimeSpan workHours = new TimeSpan(); try { DateTime checkin = (DateTime)myWorkTime().Rows[0][0]; DateTime checkout = (DateTime)myWorkTime().Rows[0][1]; workHours = checkout.TimeOfDay - checkin.TimeOfDay; } catch { workHours = new TimeSpan(0, 0, 0); } if (workHours.Hours < 12) { if (fined(100)) { } } int salary = workHours.Hours * 80; SqlCommand cmd = new SqlCommand("UPDATE salary SET mysalary=@salary WHERE employee_id=@id", mydb.getConnection); cmd.Parameters.Add("@id", SqlDbType.Int).Value = Global.StaffID; cmd.Parameters.Add("@salary", SqlDbType.Int).Value = salary; mydb.openConnection(); if (cmd.ExecuteNonQuery() > 0) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool insertSTATISTIC(DateTime day, string group, int amount, decimal total, string status) { SqlCommand cmd = new SqlCommand("insert into DAYSTATISTIC(dayST,groupST,amount,total,statusST)" + "values(@day,@gr,@amount,@total,@status)", mydb.getConnection); cmd.Parameters.Add("@day", SqlDbType.DateTime).Value = day; cmd.Parameters.Add("@gr", SqlDbType.NVarChar).Value = group; cmd.Parameters.Add("@amount", SqlDbType.Int).Value = amount; cmd.Parameters.Add("@total", SqlDbType.Decimal).Value = total; cmd.Parameters.Add("@status", SqlDbType.NVarChar).Value = status; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool insertRecipe(string IdDish, int idMaterial, string Material, string amount) { SqlCommand command = new SqlCommand("INSERT INTO [recipe](IdDish,IDMaterial,Material,amount)" + " VALUES ( @idD,@IDM,@Mtr, @Am)", db.getConnection); command.Parameters.Add("@idD", SqlDbType.NVarChar).Value = IdDish; command.Parameters.Add("@IDM", SqlDbType.NVarChar).Value = idMaterial; command.Parameters.Add("@Mtr", SqlDbType.NVarChar).Value = Material; command.Parameters.Add("@Am", SqlDbType.NVarChar).Value = amount; db.openConnection(); if (command.ExecuteNonQuery() == 1) { db.closeConnection(); return(true); } else { db.closeConnection(); return(false); } }
//Dang ky tai khoan public bool insertLogin(string user, string pass, string type, string state) { SqlCommand cmd = new SqlCommand("insert into tblACCOUNT(username,passw,userID,state)" + "values (@user,@pass,@type,@state)", mydb.getConnection); cmd.Parameters.Add("@user", SqlDbType.VarChar).Value = user; cmd.Parameters.Add("@pass", SqlDbType.VarChar).Value = pass; cmd.Parameters.Add("@type", SqlDbType.Int).Value = type; cmd.Parameters.Add("@state", SqlDbType.VarChar).Value = state; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool InsertBill(int idTable, DateTime TimeIn) { SqlCommand command = new SqlCommand("INSERT INTO [Bill] (IdTable, state,checkIn)" + " VALUES (@idT,@st,@CIn)", db.getConnection); command.Parameters.Add("@idT", SqlDbType.Int).Value = idTable; command.Parameters.Add("@st", SqlDbType.NVarChar).Value = " Eating"; command.Parameters.Add("@CIn", SqlDbType.DateTime).Value = TimeIn; db.openConnection(); if (command.ExecuteNonQuery() == 1) { db.closeConnection(); return(true); } else { db.closeConnection(); return(false); } }
public bool insertRECEIPT(string receipt, string memID, decimal total) { SqlCommand cmd = new SqlCommand("insert into tblRECEIPT(receipt_ID,mem_ID,total)" + "values (@id,@mem,@total)", mydb.getConnection); cmd.Parameters.Add("@id", SqlDbType.VarChar).Value = receipt; cmd.Parameters.Add("@mem", SqlDbType.VarChar).Value = memID; cmd.Parameters.Add("@total", SqlDbType.Decimal).Value = total; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool addContact(int Id, string fname, string lname, int group_id, string phone, string email, string address, MemoryStream picture, int userID) { SqlCommand cmd = new SqlCommand("INSERT INTO mycontact (id, fname, lname, group_id, phone, email, address, picture, userid) VALUES (@id, @fname, @lname, @group_id, @phone, @email, @address, @picture, @userid)", mydb.getConnection); cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Value = Id; cmd.Parameters.Add("@fname", System.Data.SqlDbType.NVarChar).Value = fname; cmd.Parameters.Add("@lname", System.Data.SqlDbType.NVarChar).Value = lname; cmd.Parameters.Add("@group_id", System.Data.SqlDbType.Int).Value = group_id; cmd.Parameters.Add("@email", System.Data.SqlDbType.NVarChar).Value = email; cmd.Parameters.Add("@phone", System.Data.SqlDbType.NVarChar).Value = phone; cmd.Parameters.Add("@address", System.Data.SqlDbType.NVarChar).Value = address; cmd.Parameters.Add("@picture", System.Data.SqlDbType.Image).Value = picture.ToArray(); cmd.Parameters.Add("@userid", System.Data.SqlDbType.Int).Value = userID; mydb.openConnection(); if ((cmd.ExecuteNonQuery() == 1)) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool ThemXe(string id, string nguoiGoi, string hinhThucGoi, DateTime ngayGoi, MemoryStream picBangSo, MemoryStream picGoi, string bangSo) { DateTime ngayNhan = NgayToiHan(hinhThucGoi, ngayGoi); command = new SqlCommand("insert into XeMay1 (MaXe,NguoiGoi,HinhThucGoi,NgayGoi,NgayToiHan,AnhBangSo,AnhNguoiGoi,BangSo)" + "values(@id,@name,@hinhthuc,@ngoi,@nnhan, @pcbs, @pcn, @bs", mydb.getConnection); command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@name", nguoiGoi); command.Parameters.AddWithValue("@hinhthuc", hinhThucGoi); command.Parameters.AddWithValue("@ngoi", ngayGoi); command.Parameters.AddWithValue("@nnhan", ngayNhan); command.Parameters.AddWithValue("@pcbs", picBangSo); command.Parameters.AddWithValue("@pcn", picGoi); command.Parameters.AddWithValue("@bs", bangSo); mydb.openConnection(); if (command.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool insertWORK(string id, string name, int group, string groupid) { SqlCommand cmd = new SqlCommand("insert into WORK(workID,workName,workGroup,groupWorkID)" + "values (@id,@name,@work,@workgroup)", mydb.getConnection); cmd.Parameters.Add("@id", SqlDbType.VarChar).Value = id; cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = name; cmd.Parameters.Add("@work", SqlDbType.NVarChar).Value = group; cmd.Parameters.Add("@workgroup", SqlDbType.NVarChar).Value = groupid; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool insertSERVICE(int id, string name, decimal cost, string note, string tag) { SqlCommand cmd = new SqlCommand("insert into tblSERVICEPACK(serID,serNAME,cost,note, tagPT)" + "values (@id,@name,@cost,@note,@tag)", mydb.getConnection); cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = name; cmd.Parameters.Add("@cost", SqlDbType.Decimal).Value = cost; cmd.Parameters.Add("@note", SqlDbType.NVarChar).Value = note; cmd.Parameters.Add("@tag", SqlDbType.VarChar).Value = tag; mydb.openConnection(); if (cmd.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
public bool addScore(int stdID, int courseID, float score, string description) { SqlCommand cmd = new SqlCommand("UPDATE score SET student_score = @score, description = @des WHERE student_id = @std_id AND course_id = @course_id", mydb.getConnection); cmd.Parameters.Add("@score", SqlDbType.Float).Value = score; cmd.Parameters.Add("@std_id", SqlDbType.Int).Value = stdID; cmd.Parameters.Add("@course_id", SqlDbType.Int).Value = courseID; cmd.Parameters.Add("@des", SqlDbType.NVarChar).Value = description; mydb.openConnection(); if (cmd.ExecuteNonQuery() > 0) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }
private void removeButton_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("UPDATE calendar SET employee_id = 0 WHERE day=@day AND shift=@shift", mydb.getConnection); cmd.Parameters.Add("@day", SqlDbType.Int).Value = calendar.convertToInt(dayBox.Text); cmd.Parameters.Add("@shift", SqlDbType.Int).Value = Convert.ToInt32(shiftBox.Text); mydb.openConnection(); if (cmd.ExecuteNonQuery() > 0) { MessageBox.Show("Removed Shift"); if (salary.fined(400)) { } mydb.closeConnection(); } else { mydb.closeConnection(); } }
public void reload() { DataTable dt = new DataTable(); dt = log.getAccountbyUser(GLOBAL.username); txtPass.Text = dt.Rows[0][1].ToString(); DataTable empDT = new DataTable(); empDT = emp.getEmployeebyID(GLOBAL.username); if (empDT.Rows.Count > 0) { lbID.Text = empDT.Rows[0][0].ToString(); lbGroup.Text = empDT.Rows[0][1].ToString(); try { byte[] picPD; picPD = (byte[])empDT.Rows[0][2]; MemoryStream pic = new MemoryStream(picPD); this.picAva.Image = Image.FromStream(pic); } catch { MessageBox.Show("Vui lòng cập nhật đủ thông tin cá nhân", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } lbFname.Text = empDT.Rows[0][3].ToString(); lbLname.Text = empDT.Rows[0][4].ToString(); lbBirthday.Text = Convert.ToDateTime(empDT.Rows[0][5]).ToShortDateString(); lbAddress.Text = empDT.Rows[0][6].ToString(); if (empDT.Rows[0][7].ToString() == "Female") { lbGender.Text = "Nữ"; } else { lbGender.Text = "Nam"; } lbPhone.Text = empDT.Rows[0][8].ToString(); lbSalary.Text = empDT.Rows[0][9].ToString(); lbIDCard.Text = empDT.Rows[0][10].ToString(); } else { // MessageBox.Show(GLOBAL.username); } mydb.closeConnection(); }
public bool removeCourseById(int id) { SqlCommand command = new SqlCommand("DELETE FROM course WHERE Id=@id", mydb.getConnection); command.Parameters.Add("@id", SqlDbType.Int).Value = id; mydb.openConnection(); if (command.ExecuteNonQuery() == 1) { mydb.closeConnection(); return(true); } else { mydb.closeConnection(); return(false); } }