private int GetChoNgoi() { //idChuyen int index = lblMaVe.Text.IndexOf(" "); string IdChuyen = lblMaVe.Text.Substring(index + 3); try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); //Cho Ngồi string GheTrong = string.Format("exec GetChoNgoi @IdChuyenDi"); //Gọi Proc SqlCommand Com = new SqlCommand(GheTrong, Con); Com.Parameters.Add(new SqlParameter("@IdChuyenDi", IdChuyen)); int a = Convert.ToInt32(Com.ExecuteScalar()); return(a); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } return(0); }
private int GetMaNV() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); string MNV = string.Format("select MAX(nv.MaNhanVien) from NhanVien nv"); //Gọi Proc SqlCommand Com = new SqlCommand(MNV, Con); if (Com.ExecuteScalar() == null) { return(0); } else { int a = Convert.ToInt32(Com.ExecuteScalar()); return(a); } } catch (Exception) { return(0); } }
private void EditUser() { NguoiDung NguoiDung = new NguoiDung(); NguoiDung.DiaChi = txtDiaChiNguoiDung.Text.ToString(); NguoiDung.SoDienThoai = numberTextBoxDT.Text.ToString(); try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); string UpdateUser = string.Format("exec EditUser @DiaChi, @SDT, @IdNguoiDung"); DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(UpdateUser, Con); Com.Parameters.Add(new SqlParameter("@DiaChi", NguoiDung.DiaChi)); Com.Parameters.Add(new SqlParameter("@SDT", NguoiDung.SoDienThoai)); Com.Parameters.Add(new SqlParameter("@IdNguoiDung", IdNguoiDung_FormMain)); SqlDataAdapter adapt = new SqlDataAdapter(Com); adapt.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Cập Nhật Thành Công Cho {0}!", NguoiDung.Ten)); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void GetInfoVe() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); SqlCommand Com; int index = lblLoTrinh.Text.LastIndexOf("-"); if (index == -1) { lblNgayDi.Text = ""; lblMaChuyen.Text = ""; lblLoTrinh.Text = ""; } else { string DiemDen = lblLoTrinh.Text.Substring(index + 2); string DiemDi = lblLoTrinh.Text.Substring(0, index - 1); //LayNgayDi string NgayDi = string.Format("exec GetInfoVe_NgayDi @DiemXuatPhat , @DiemDich"); //Gọi Proc Com = new SqlCommand(NgayDi, Con); Com.Parameters.Add(new SqlParameter("@DiemXuatPhat", DiemDi)); Com.Parameters.Add(new SqlParameter("@DiemDich", DiemDen)); lblNgayDi.Text = Com.ExecuteScalar().ToString(); //LấyIdVe string IdVe = string.Format("exec GetInfoVe_ID"); //Gọi Proc Com = new SqlCommand(IdVe, Con); lblMaChuyen.Text = Com.ExecuteScalar().ToString() + " - "; string IDChuyen = string.Format("exec GetInfoVe_IdChuyen @DiemXuatPhat , @DiemDich"); //Gọi Proc Com = new SqlCommand(IDChuyen, Con); Com.Parameters.Add(new SqlParameter("@DiemXuatPhat", DiemDi)); Com.Parameters.Add(new SqlParameter("@DiemDich", DiemDen)); lblMaChuyen.Text += Com.ExecuteScalar().ToString(); } //LayLoaiNV string LoaiNV = string.Format("select nv.LoaiNV from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(LoaiNV, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNhanVien_FormMain)); LoaiNhanVien = Com.ExecuteScalar().ToString(); lblLNV.Text = TenLoaiNV(Com.ExecuteScalar().ToString()); //LayTenNV string namae = string.Format("select nv.TenNhanVien from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(namae, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNhanVien_FormMain)); lblTenNhanVien.Text = Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void Begin() { if (LoaiNhanVien == "1" || LoaiNhanVien == "2") { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); String Soure = String.Format("select p.LoTrinh from PhanCongViec p where p.MaCongViec=@MaCV"); SqlCommand Com = new SqlCommand(Soure, Con); Com.Parameters.Add(new SqlParameter("@MaCV", MaNhanVien_FormMain)); if (Com.ExecuteScalar() == null) { lblLoTrinh.Text = ""; } else { lblLoTrinh.Text = Com.ExecuteScalar().ToString(); lblLoTrinh.SelectedValue = Com.ExecuteScalar().ToString(); } Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } } else { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); String Soure = String.Format("select p.CaTruc from PhanCongViec p where p.MaCongViec=@MaCV"); SqlCommand Com = new SqlCommand(Soure, Con); Com.Parameters.Add(new SqlParameter("@MaCV", MaNhanVien_FormMain)); if (Com.ExecuteScalar() == null) { comboBox1.Text = ""; } else { comboBox1.Text = Com.ExecuteScalar().ToString(); comboBox1.SelectedValue = Com.ExecuteScalar().ToString(); } Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } } }
private void UpdateCongViec() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); string ThemNV; if (LoaiNhanVien == "1" || LoaiNhanVien == "2") { ThemNV = string.Format("update PhanCongViec set MaChuyenXe = @MaChuyenXe,NgayDi =@NgayDi,LoTrinh=@LoTrinh where MaCongViec=@MaCongViec"); } else { ThemNV = string.Format("update PhanCongViec set CaTruc=@CaTruc where MaCongViec=@MaCongViec"); } DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(ThemNV, Con); DateTime NS; if (LoaiNhanVien == "1" || LoaiNhanVien == "2") { string temp = lblNgayDi.Text.Replace("Ngày ", ""); NS = Convert.ToDateTime(temp); Com.Parameters.Add(new SqlParameter("@NgayDi", NS)); Com.Parameters.Add(new SqlParameter("@MaChuyenXe", lblMaChuyen.Text)); Com.Parameters.Add(new SqlParameter("@LoTrinh", lblLoTrinh.Text)); } else { Com.Parameters.Add(new SqlParameter("@CaTruc", comboBox1.Text)); } //ThemNV Com.Parameters.Add(new SqlParameter("@MaCongViec", MaNhanVien_FormMain)); SqlDataAdapter adapt = new SqlDataAdapter(Com); adapt.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Cập Nhật Công Việc Cho Nhân Viên {0}!", lblTenNhanVien.Text), "Compelete", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void ThemNhanVien(Class.ThemNV NV) { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); string ThemNV = string.Format("insert into NhanVien(MaNhanVien, TenNhanVien, SDT, NgaySinh, GioiTinh, DiaChi, NgayVaoLamViec,KinhNghiem,SoGioDaChay, LoaiNV, MaCV) values(@MaNV, @Ten, @SDT, @NgaySinh, @GioiTinh, @DiaChi, @NgayLam, @KinhNghiem, @SoGioLam, @LoaiNV, @MaCV)"); string InsertCVNV = string.Format("insert into PhanCongViec(MaCongViec) values(@MaCV)"); string InsertDanhGia = string.Format("insert into DanhGiaNhanVien(MaNhanVien) values(@MaNhanVien)"); DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(ThemNV, Con); SqlCommand ComCV = new SqlCommand(InsertCVNV, Con); SqlCommand ComDG = new SqlCommand(InsertDanhGia, Con); DateTime NS; DateTime.TryParse(NV.NgaySinh, out NS); DateTime NL; DateTime.TryParse(NV.NgayLamViec, out NL); //ThemNV Com.Parameters.Add(new SqlParameter("@MaNV", NV.MaNhanVien)); Com.Parameters.Add(new SqlParameter("@Ten", NV.TenNhanVien)); Com.Parameters.Add(new SqlParameter("@SDT", NV.SDT)); Com.Parameters.Add(new SqlParameter("@NgaySinh", NS)); Com.Parameters.Add(new SqlParameter("@GioiTinh", NV.GioiTinh)); Com.Parameters.Add(new SqlParameter("@DiaChi", NV.DiaChi)); Com.Parameters.Add(new SqlParameter("@NgayLam", NL)); Com.Parameters.Add(new SqlParameter("@KinhNghiem", NV.KinhNghiem)); Com.Parameters.Add(new SqlParameter("@SoGioLam", NV.SoGioDaChay)); Com.Parameters.Add(new SqlParameter("@LoaiNV", NV.LoaiNV)); Com.Parameters.Add(new SqlParameter("@MaCV", NV.MaCV)); //InsertCVNV ComCV.Parameters.Add(new SqlParameter("@MaCV", NV.MaCV)); //InsertDGNV ComDG.Parameters.Add(new SqlParameter("@MaNhanVien", NV.MaNhanVien)); SqlDataAdapter adapt1 = new SqlDataAdapter(ComCV); SqlDataAdapter adapt = new SqlDataAdapter(Com); SqlDataAdapter adapt2 = new SqlDataAdapter(ComDG); adapt1.Fill(user); adapt.Fill(user); adapt2.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Thêm Nhân Viên {0}!", NV.TenNhanVien), "Compelete", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void XepLichChayXe() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); Class.ChuyenXe ChuyenXe = new Class.ChuyenXe(); //idChuyen ChuyenXe.IdChuyen = txtIdChuyen.Text.ToString(); //SoXe ChuyenXe.SoXe = txtSoXe.Text.ToString(); //NgayDi ChuyenXe.NgayDi = dateTimePicker1.Text.ToString(); //HangXe ChuyenXe.HieuXe = txtHangXe.Text.ToString(); //GioDi ChuyenXe.GioDi = txtGioDi.Text.ToString(); //XuatPhat ChuyenXe.XuatPhat = txtXuatPhat.Text.ToString(); //DichDen ChuyenXe.DichDen = txtDichDen.Text.ToString(); //SoChoNgoi ChuyenXe.SoGheTrong = Convert.ToInt32(txtSoChoNgoi.Text); string XepLichChay = string.Format("exec XepLichChayXe @IdChuyen,@So_Xe,@NgayDi,@Gio,@HieuXe,@SoGhe,@XuatPhat,@DiemDich"); DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(XepLichChay, Con); //ThemVe Com.Parameters.Add(new SqlParameter("@IdChuyen", ChuyenXe.IdChuyen)); Com.Parameters.Add(new SqlParameter("@So_Xe", ChuyenXe.SoXe)); Com.Parameters.Add(new SqlParameter("@NgayDi", ChuyenXe.NgayDi)); Com.Parameters.Add(new SqlParameter("@Gio", ChuyenXe.GioDi)); Com.Parameters.Add(new SqlParameter("@HieuXe", ChuyenXe.HieuXe)); Com.Parameters.Add(new SqlParameter("@SoGhe", ChuyenXe.SoGheTrong)); Com.Parameters.Add(new SqlParameter("@XuatPhat", ChuyenXe.XuatPhat)); Com.Parameters.Add(new SqlParameter("@DiemDich", ChuyenXe.DichDen)); SqlDataAdapter adapt = new SqlDataAdapter(Com); adapt.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Đặt Lịch Thành Công Cho Chuyến {0}!", ChuyenXe.XuatPhat + " - " + ChuyenXe.DichDen)); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void GetInfoVe() { int index = CBChuyenTu_Den.Text.LastIndexOf("-"); string DiemDen = CBChuyenTu_Den.Text.Substring(index + 2); string DiemDi = CBChuyenTu_Den.Text.Substring(0, index - 1); try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); txtChoGui.Text = DiemDi; txtChoNhan.Text = DiemDen; //LayNgayDi string NgayDi = string.Format("exec GetInfoVe_NgayDi @DiemXuatPhat ,@DiemDich"); //Gọi Proc SqlCommand Com = new SqlCommand(NgayDi, Con); Com.Parameters.Add(new SqlParameter("@DiemXuatPhat", DiemDi)); Com.Parameters.Add(new SqlParameter("@DiemDich", DiemDen)); txtNgayDi.Text = Com.ExecuteScalar().ToString(); //int i = txtNgayDi.Text.IndexOf(" "); //if (i != -1) //{ // txtNgayDi.Text = txtNgayDi.Text.Substring(0, i); //} //LayGioDi string GioDi = string.Format("exec GetInfoVe_GioDi @DiemXuatPhat,@DiemDich"); //Gọi Proc Com = new SqlCommand(GioDi, Con); Com.Parameters.Add(new SqlParameter("@DiemXuatPhat", DiemDi)); Com.Parameters.Add(new SqlParameter("@DiemDich", DiemDen)); txtGioDi.Text = Com.ExecuteScalar().ToString(); //LấyidHàng string Idhang = string.Format("exec GetInfoVe_IdHang"); //Gọi Proc Com = new SqlCommand(Idhang, Con); Com.Parameters.Add(new SqlParameter("@DiemXuatPhat", DiemDi)); Com.Parameters.Add(new SqlParameter("@DiemDich", DiemDen)); lblMaVe.Text = Com.ExecuteScalar().ToString() + " - "; //LayIdChuyen string IDChuyen = string.Format("exec GetInfoVe_IdChuyen @DiemXuatPhat, @DiemDich"); //Gọi Proc Com = new SqlCommand(IDChuyen, Con); Com.Parameters.Add(new SqlParameter("@DiemXuatPhat", DiemDi)); Com.Parameters.Add(new SqlParameter("@DiemDich", DiemDen)); lblMaVe.Text += Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void btnDoiVe_Click(object sender, EventArgs e) { //Get idChuyen int index = lblMaVe.Text.IndexOf(" "); string IdChuyen = lblMaVe.Text.Substring(index + 3); string LoTrinh = ""; try { //LayLoTrinh SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); LoTrinh = string.Format("exec LoTrinh @IdChuyen"); //Gọi Proc SqlCommand Com = new SqlCommand(LoTrinh, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); LoTrinh = Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } Visible_Sao(); if (Compelete() == false) { } else if (GetChoNgoi() < 1) { MetroFramework.MetroMessageBox.Show(this, string.Format("Chuyến: {0} :Không Còn Chổ Trống !", LoTrinh)); } else { if (MetroFramework.MetroMessageBox.Show(this, "Chắc Chắn Hay Không", "Bạn Có Chắc Đổi Vé Này", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string Str = IdCanDoi + "&" + TextBoxGiaTien.Text + "&" + IdNguoiDung_FormMain; DoiVeXe(); frmInPhieu In = new frmInPhieu(); PassDataInPhieuDatVe Share = new PassDataInPhieuDatVe(In.GetPassData_FormDatVe); Share(Str); this.Hide(); In.ShowDialog(); HuyDoiVe_Load(sender, e); metroPanel1.Visible = false; this.Show(); } } }
private int KiemTraTonTai(string MaVe) { int index = txtKiemTra.Text.IndexOf(" "); //Định Dạng String MaVe Là IDVe - IdChuyen (Exam '1 - CX0001') if (index == -1) { return(-1); } if (index + 3 >= txtKiemTra.Text.Length) //ràng buộc IdChuyen Phải Tồn Tại { return(-1); } string IdVe = txtKiemTra.Text.Substring(0, index); int IdTemp = 0; if (!int.TryParse(IdVe, out IdTemp)) //Đảm bảo ID vé Phải Là Số If not number error { return(-1); } string IdChuyen = txtKiemTra.Text.Substring(index + 3); IdChuyenCanDoi = txtKiemTra.Text.Substring(index + 3); IdCanDoi = txtKiemTra.Text.Substring(0, index); try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); string Dem = string.Format("exec KiemTraTonTaiVe @IdChuyen ,@IdVe"); //Gọi Proc SqlCommand Com = new SqlCommand(Dem, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); int check = Convert.ToInt32(Com.ExecuteScalar()); Con.Close(); return(check); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } return(0); }
private void GetTenNhanVien() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); //TenNhanVien string TenNhanVien = string.Format("exec GetTenNhanVien @IdNguoiDung "); //Gọi Proc SqlCommand Com = new SqlCommand(TenNhanVien, Con); Com.Parameters.Add(new SqlParameter("@IdNguoiDung", IdNguoiDung_FormMain)); lblTenBanVe.Text = Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void EditNhanVien(Class.ThemNV NV) { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); string ThemNV = string.Format("update NhanVien set TenNhanVien= @Ten,SDT = @SDT,NgaySinh= @NgaySinh,GioiTinh=@GioiTinh,DiaChi=@DiaChi,KinhNghiem=@KinhNghiem,SoGioDaChay=@SoGioLam,LoaiNV = @LoaiNV where MaNhanVien=@MaNhanVien"); DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(ThemNV, Con); DateTime NS; DateTime.TryParse(NV.NgaySinh, out NS); //ThemNV Com.Parameters.Add(new SqlParameter("@Ten", NV.TenNhanVien)); Com.Parameters.Add(new SqlParameter("@SDT", NV.SDT)); Com.Parameters.Add(new SqlParameter("@NgaySinh", NS)); Com.Parameters.Add(new SqlParameter("@GioiTinh", NV.GioiTinh)); Com.Parameters.Add(new SqlParameter("@DiaChi", NV.DiaChi)); Com.Parameters.Add(new SqlParameter("@KinhNghiem", NV.KinhNghiem)); Com.Parameters.Add(new SqlParameter("@SoGioLam", NV.SoGioDaChay)); Com.Parameters.Add(new SqlParameter("@LoaiNV", NV.LoaiNV)); Com.Parameters.Add(new SqlParameter("@MaNhanVien", MaNhanVien_FormMain)); SqlDataAdapter adapt = new SqlDataAdapter(Com); adapt.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Edit Nhân Viên {0}!", NV.TenNhanVien), "Compelete", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void GetLoTrinhVe() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); String Soure = String.Format("exec GetLoTrinhVe"); DataTable user = new DataTable(); SqlCommand cmd = new SqlCommand(Soure, Con); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet ChuyenDi = new DataSet(); adapt.Fill(ChuyenDi); CBChuyenTu_Den.DataSource = ChuyenDi.Tables[0]; //Đổ dữ liệu vào Combobox CBChuyenTu_Den.DisplayMember = "LoTrinh"; CBChuyenTu_Den.ValueMember = "LoTrinh"; Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void Lay_LoaiNhanVien() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); String Soure = String.Format("select * from LoaiNhanVien "); DataTable user = new DataTable(); SqlCommand cmd = new SqlCommand(Soure, Con); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet LNV = new DataSet(); adapt.Fill(LNV); txtLoaiNhanVien.DataSource = LNV.Tables[0]; //Đổ dữ liệu vào Combobox txtLoaiNhanVien.DisplayMember = "TenLoaiNV"; txtLoaiNhanVien.ValueMember = "IdLoaiNV"; Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private string TenLoaiNV(string LoaiNV) { string temp = ""; try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); //Lấy Tên string Ten = string.Format("select lnv.TenLoaiNV from LoaiNhanVien lnv where lnv.IdLoaiNV=@LoaiNV"); //Gọi Proc SqlCommand Com = new SqlCommand(Ten, Con); Com.Parameters.Add(new SqlParameter("@LoaiNV", LoaiNV)); temp = Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } return(temp); }
/// <summary> /// Login /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, EventArgs e) { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); string PassWordMD5 = txtMatKhau.Text; PassWordMD5 = md5(PassWordMD5); string SelectDangNhap = string.Format("exec DangNhap @UseName, @MatKhau"); //Gọi Proc SqlCommand Com = new SqlCommand(SelectDangNhap, Con); Com.Parameters.Add(new SqlParameter("@UseName", txtTaiKhoan.Text)); Com.Parameters.Add(new SqlParameter("@MatKhau", PassWordMD5)); int check = Convert.ToInt32(Com.ExecuteScalar()); Con.Close(); if (txtTaiKhoan.Text == "" && txtMatKhau.Text == "") { this.lblThongBao.Visible = true; this.lblThongBao.Text = "Chưa Nhập Tài Khoản Và Mật Khẩu"; this.lblTBPass.Visible = true; this.lblTBTaiKhoan.Visible = true; } else { if (this.txtTaiKhoan.Text != "" && this.txtMatKhau.Text == "") { this.lblThongBao.Visible = true; this.lblThongBao.Text = "Chưa Nhập Mật Khẩu"; this.lblTBPass.Visible = true; this.lblTBTaiKhoan.Visible = false; } else if (this.txtTaiKhoan.Text != "" && this.txtMatKhau.Text != "") { if (check == 1) { this.lblTBPass.Visible = false; this.lblTBTaiKhoan.Visible = false; Main FrmMain = new Main(); PassData Share = new PassData(FrmMain.GetData_Form1); Share(this.txtTaiKhoan); this.Hide(); FrmMain.ShowDialog(); this.lblThongBao.Visible = false; this.Show(); } else { this.lblThongBao.Visible = true; this.lblThongBao.Text = "Sai Tài Khoản Hoặc Mật Khẩu"; this.lblTBPass.Visible = false; this.lblTBTaiKhoan.Visible = false; } } else { this.lblThongBao.Visible = true; this.lblThongBao.Text = "Chưa Nhập Tài Khoản"; this.lblTBPass.Visible = false; this.lblTBTaiKhoan.Visible = true; } } } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void DatVeXe() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); CDatVe VXe = new CDatVe(); //idChuyen int index = lblMaVe.Text.IndexOf(" "); VXe.IdChuyen = lblMaVe.Text.Substring(index + 3); //Ten VXe.TenKhachHang = txtTen.Text; //CMND VXe.CMND = ntxtCMND.Text; //QueQuan VXe.QueQuan = DynamicCBOXQueQuan.Text; //NgaySinh VXe.NgaySinh = dateTimePicker1.Value.ToString(); int i = VXe.NgaySinh.IndexOf(" "); if (i != -1) { VXe.NgaySinh = VXe.NgaySinh.Substring(0, i); } //SDT VXe.SDT = ntxtSDT.Text; //Tien VXe.TienVe = TextBoxGiaTien.Text; //Thoi Gian Mua Ve VXe.ThoiGianMuaVe = "Ngày " + DateTime.Now.Day.ToString() + " Tháng " + DateTime.Now.Month.ToString() + " Năm " + DateTime.Now.Year.ToString(); string ThemVe = string.Format("exec ThemVe @IdChuyen, @TenHanhKhach, @NgaySinh, @SDTHanhKhach, @CMND, @QueQuan, @GiaTien, @ThoiGianMua"); string UpdateChoNgoi = string.Format("exec UpdateChoNgoi @SoGheTrong, @IdChuyen"); string InsertUuDaiKhachHang = string.Format("exec InsertUuDaiKhachHang @MaVeUuDai,@TenHangKhachUuDai,@SDTUuDai,@CMNDUuDai,@LoaiGiaoDich"); DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(ThemVe, Con); SqlCommand ComUpdate = new SqlCommand(UpdateChoNgoi, Con); SqlCommand ComUuDai = new SqlCommand(InsertUuDaiKhachHang, Con); //ThemVe Com.Parameters.Add(new SqlParameter("@IdChuyen", VXe.IdChuyen)); Com.Parameters.Add(new SqlParameter("@TenHanhKhach", VXe.TenKhachHang)); Com.Parameters.Add(new SqlParameter("@NgaySinh", VXe.NgaySinh)); Com.Parameters.Add(new SqlParameter("@SDTHanhKhach", VXe.SDT)); Com.Parameters.Add(new SqlParameter("@CMND", VXe.CMND)); Com.Parameters.Add(new SqlParameter("@QueQuan", VXe.QueQuan)); Com.Parameters.Add(new SqlParameter("@GiaTien", VXe.TienVe)); Com.Parameters.Add(new SqlParameter("@ThoiGianMua", VXe.ThoiGianMuaVe)); //UpdateChoNgoi ComUpdate.Parameters.Add(new SqlParameter("@SoGheTrong", GetChoNgoi() - 1)); ComUpdate.Parameters.Add(new SqlParameter("@IdChuyen", VXe.IdChuyen)); //InsertUuDaiKhachHang ComUuDai.Parameters.Add(new SqlParameter("@MaVeUuDai", lblMaVe.Text)); ComUuDai.Parameters.Add(new SqlParameter("@TenHangKhachUuDai", VXe.TenKhachHang)); ComUuDai.Parameters.Add(new SqlParameter("@SDTUuDai", VXe.SDT)); ComUuDai.Parameters.Add(new SqlParameter("@CMNDUuDai", VXe.CMND)); ComUuDai.Parameters.Add(new SqlParameter("@LoaiGiaoDich", this.Text)); SqlDataAdapter adapt = new SqlDataAdapter(Com); SqlDataAdapter adapt1 = new SqlDataAdapter(ComUpdate); SqlDataAdapter adapt2 = new SqlDataAdapter(ComUuDai); adapt.Fill(user); adapt1.Fill(user); adapt2.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Đặt Vé Cho Khách Hàng {0}!", VXe.TenKhachHang)); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void ShowInfoKhachHang(string MaVe) { int index = MaVe.IndexOf(" "); string IdHangHoa = MaVe.Substring(0, index); string IdChuyen = MaVe.Substring(index + 3); try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); //Lấy Tên Người Gửi string TenNG = string.Format("exec InfoNhanHang_TenNG @IdHangHoa , @IdChuyen"); //Gọi Proc SqlCommand Com = new SqlCommand(TenNG, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtTenNguoiGui.Text = Com.ExecuteScalar().ToString(); //Lấy Tên Người Nhận string TenNN = string.Format("exec InfoNhanHang_TenNN @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(TenNN, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtTenNguoiNhan.Text = Com.ExecuteScalar().ToString(); //LayCMNDNguoiGui string CMNDNG = string.Format("exec InfoNhanHang_CMNDNG @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(CMNDNG, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ntxtCMNDNguoiGui.Text = Com.ExecuteScalar().ToString(); //LayCMNDNguoiNhan string CMNDNN = string.Format("exec InfoNhanHang_CMNDNN @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(CMNDNN, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ntxtCMNDNguoiNhan.Text = Com.ExecuteScalar().ToString(); //LaySDTNguoiGui string SDTNG = string.Format("exec InfoNhanHang_SDTNG @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(SDTNG, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ntxtSDTNguoiGui.Text = Com.ExecuteScalar().ToString(); //LaySDTNguoiNhan string SDTNN = string.Format("exec InfoNhanHang_SDTNN @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(SDTNN, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ntxtSDTNguoiNhan.Text = Com.ExecuteScalar().ToString(); //LayTenHang string TenHang = string.Format("exec InfoNhanHang_TenHang @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(TenHang, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtTenHang.Text = Com.ExecuteScalar().ToString(); //LayTrongLuong string trongluong = string.Format("exec InfoNhanHang_TrongLuong @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(trongluong, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ntxtTrongLuong.Text = Com.ExecuteScalar().ToString(); //LayKichThuoc string KichThuoc = string.Format("exec InfoNhanHang_KichThuoc @IdHangHoa , @IdChuyen"); //Gọi Proc Com = new SqlCommand(KichThuoc, Con); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtKichThuoc.Text = Com.ExecuteScalar().ToString(); //LayLoTrinh string LoTrinh = string.Format("exec InfoNhanHang_LoTrinh @IdChuyen"); //Gọi Proc Com = new SqlCommand(LoTrinh, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); CBChuyenTu_Den.Text = Com.ExecuteScalar().ToString(); //LayDiemGui string DiemGui = string.Format("exec InfoNhanHang_DiemGui @IdChuyen"); //Gọi Proc Com = new SqlCommand(DiemGui, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtChoGui.Text = Com.ExecuteScalar().ToString(); //LayDiemNhan string DiemNhan = string.Format("exec InfoNhanHang_DiemNhan @IdChuyen"); //Gọi Proc Com = new SqlCommand(DiemNhan, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtChoNhan.Text = Com.ExecuteScalar().ToString(); //LayNgayChay string NgayChay = string.Format("exec InfoNhanHang_NgayChay @IdChuyen"); //Gọi Proc Com = new SqlCommand(NgayChay, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtNgayDi.Text = Com.ExecuteScalar().ToString(); //LayGioDi string GioDi = string.Format("exec InfoNhanHang_Gio @IdChuyen "); //Gọi Proc Com = new SqlCommand(GioDi, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtGioDi.Text = Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void DoiVeXe() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); CDatVe VXe = new CDatVe(); //idChuyen int index = lblMaVe.Text.IndexOf(" "); string IdVe = lblMaVe.Text.Substring(0, index); VXe.IdChuyen = lblMaVe.Text.Substring(index + 3); //Ten VXe.TenKhachHang = txtTen.Text; //CMND VXe.CMND = ntxtCMND.Text; //QueQuan VXe.QueQuan = DynamicCBOXQueQuan.Text; //NgaySinh VXe.NgaySinh = dateTimePicker1.Value.ToString(); int i = VXe.NgaySinh.IndexOf(" "); if (i != -1) { VXe.NgaySinh = VXe.NgaySinh.Substring(0, i); } //SDT VXe.SDT = ntxtSDT.Text; //Tien string TempTien = TextBoxGiaTien.Text; int ixdexTien = TextBoxGiaTien.Text.IndexOf("."); if (ixdexTien == -1) { VXe.TienVe = Convert.ToInt32(TempTien); } else { TempTien = TempTien.Replace(".", ""); VXe.TienVe = Convert.ToInt32(TempTien); } //Thoi Gian Mua Ve VXe.ThoiGianMuaVe = "Ngày " + DateTime.Now.Day.ToString() + " Tháng " + DateTime.Now.Month.ToString() + " Năm " + DateTime.Now.Year.ToString(); string DoiVe = string.Format("exec DoiVe @IdChuyenNow,@TenHanhKhach,@NgaySinh,@SDTHanhKhach,@CMND,@QueQuan,@GiaTien,@ThoiGianMua,@IdChuyenCanDoi,@IdVe"); string InsertUuDaiKhachHang = string.Format("exec InsertUuDaiKhachHang @MaVeUuDai,@TenHangKhachUuDai,@SDTUuDai,@CMNDUuDai,@LoaiGiaoDich"); DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(DoiVe, Con); SqlCommand ComUuDai = new SqlCommand(InsertUuDaiKhachHang, Con); //DoiVe Com.Parameters.Add(new SqlParameter("@IdChuyenNow", VXe.IdChuyen)); Com.Parameters.Add(new SqlParameter("@IdVe", IdCanDoi)); Com.Parameters.Add(new SqlParameter("@IdChuyenCanDoi", IdChuyenCanDoi)); Com.Parameters.Add(new SqlParameter("@TenHanhKhach", VXe.TenKhachHang)); Com.Parameters.Add(new SqlParameter("@NgaySinh", VXe.NgaySinh)); Com.Parameters.Add(new SqlParameter("@SDTHanhKhach", VXe.SDT)); Com.Parameters.Add(new SqlParameter("@CMND", VXe.CMND)); Com.Parameters.Add(new SqlParameter("@QueQuan", VXe.QueQuan)); Com.Parameters.Add(new SqlParameter("@GiaTien", VXe.TienVe)); Com.Parameters.Add(new SqlParameter("@ThoiGianMua", VXe.ThoiGianMuaVe)); //InsertUuDaiKhachHang ComUuDai.Parameters.Add(new SqlParameter("@MaVeUuDai", lblMaVe.Text)); ComUuDai.Parameters.Add(new SqlParameter("@TenHangKhachUuDai", VXe.TenKhachHang)); ComUuDai.Parameters.Add(new SqlParameter("@SDTUuDai", VXe.SDT)); ComUuDai.Parameters.Add(new SqlParameter("@CMNDUuDai", VXe.CMND)); ComUuDai.Parameters.Add(new SqlParameter("@LoaiGiaoDich", "Đổi Vé")); SqlDataAdapter adapt = new SqlDataAdapter(Com); SqlDataAdapter adapt2 = new SqlDataAdapter(ComUuDai); adapt.Fill(user); adapt2.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Đổi Vé Cho Khách Hàng: {0}!", VXe.TenKhachHang)); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void btnHuyVe_Click(object sender, EventArgs e) { if (MetroFramework.MetroMessageBox.Show(this, "Chắc Chắn Hay Không", "Bạn Có Chắc Huỷ Vé Này", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CDatVe VXe = new CDatVe(); //Ten VXe.TenKhachHang = txtTen.Text; //CMND VXe.CMND = ntxtCMND.Text; //SDT VXe.SDT = ntxtSDT.Text; // // int index = lblMaVe.Text.IndexOf(" "); string IdVe = IdCanDoi; string IdChuyen = IdChuyenCanDoi; try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); DataTable user = new DataTable(); string HuyVe = string.Format("exec HuyVe @IdChuyen,@IdVe"); string InsertUuDaiKhachHang = string.Format("exec InsertUuDaiKhachHang @MaVeUuDai,@TenHangKhachUuDai,@SDTUuDai,@CMNDUuDai,@LoaiGiaoDich"); string UpdateChoNgoi = string.Format("exec UpdateChoNgoi @SoGheTrong, @IdChuyen"); SqlCommand ComUuDai = new SqlCommand(InsertUuDaiKhachHang, Con); SqlCommand ComUpdate = new SqlCommand(UpdateChoNgoi, Con); //HuyVe SqlCommand Com = new SqlCommand(HuyVe, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); ComUpdate.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ComUpdate.Parameters.Add(new SqlParameter("@SoGheTrong", GetChoNgoi() + 1)); //InsertUuDaiKhachHang ComUuDai.Parameters.Add(new SqlParameter("@MaVeUuDai", lblMaVe.Text)); ComUuDai.Parameters.Add(new SqlParameter("@TenHangKhachUuDai", VXe.TenKhachHang)); ComUuDai.Parameters.Add(new SqlParameter("@SDTUuDai", VXe.SDT)); ComUuDai.Parameters.Add(new SqlParameter("@CMNDUuDai", VXe.CMND)); ComUuDai.Parameters.Add(new SqlParameter("@LoaiGiaoDich", "Huỷ Vé")); // SqlDataAdapter adapt1 = new SqlDataAdapter(ComUpdate); SqlDataAdapter adapt2 = new SqlDataAdapter(ComUuDai); SqlDataAdapter adapt = new SqlDataAdapter(Com); adapt.Fill(user); adapt1.Fill(user); adapt2.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Delete Vé Mã Số:{0}", IdCanDoi + " - " + IdChuyenCanDoi)); HuyDoiVe_Load(sender, e); metroPanel1.Visible = false; } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } } }
private void ShowInfoKhachHang(string MaVe) { int index = MaVe.IndexOf(" "); string IdVe = MaVe.Substring(0, index); string IdChuyen = MaVe.Substring(index + 3); try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); //Lấy Tên string Ten = string.Format("exec ShowInfoKhachHang_Ten @IdChuyen, @IdVe"); //Gọi Proc SqlCommand Com = new SqlCommand(Ten, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtTen.Text = Com.ExecuteScalar().ToString(); //LayCMND string CMND = string.Format("exec ShowInfoKhachHang_CMND @IdChuyen,@IdVe"); //Gọi Proc Com = new SqlCommand(CMND, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ntxtCMND.Text = Com.ExecuteScalar().ToString(); //QueQuan string Que = string.Format("exec ShowInfoKhachHang_Que @IdChuyen,@IdVe"); //Gọi Proc Com = new SqlCommand(Que, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); DynamicCBOXQueQuan.Text = Com.ExecuteScalar().ToString(); //LaySDT string SDT = string.Format("exec ShowInfoKhachHang_SDT @IdChuyen, @IdVe"); //Gọi Proc Com = new SqlCommand(SDT, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); ntxtSDT.Text = Com.ExecuteScalar().ToString(); //LayNgaySinh string NgaySinh = string.Format("exec ShowInfoKhachHang_NgaySinh @IdChuyen ,@IdVe"); //Gọi Proc Com = new SqlCommand(NgaySinh, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); dateTimePicker1.Text = Com.ExecuteScalar().ToString(); //LayGiaTien string Tien = string.Format("exec ShowInfoKhachHang_Tien @IdChuyen, @IdVe"); //Gọi Proc Com = new SqlCommand(Tien, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); TextBoxGiaTien.Text = Com.ExecuteScalar().ToString(); //LayNgay string Ngay = string.Format("exec ShowInfoKhachHang_NgayDi @IdChuyen, @IdVe"); //Gọi Proc Com = new SqlCommand(Ngay, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtNgayDi.Text = Com.ExecuteScalar().ToString(); //LayGio string Gio = string.Format("exec ShowInfoKhachHang_GioDi @IdChuyen , @IdVe"); //Gọi Proc Com = new SqlCommand(Gio, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); txtGioDi.Text = Com.ExecuteScalar().ToString(); //LayLoTrinh string LoTrinh = string.Format("exec ShowInfoKhachHang_LoTrinh @IdChuyen,@IdVe"); //Gọi Proc Com = new SqlCommand(LoTrinh, Con); Com.Parameters.Add(new SqlParameter("@IdVe", IdVe)); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); CBChuyenTu_Den.Text = Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void KiGui() { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); Class.KiGuiHangHoa HangHoa = new Class.KiGuiHangHoa(); //idChuyen int index = lblMaVe.Text.IndexOf(" "); HangHoa.IdChuyen = lblMaVe.Text.Substring(index + 3); //Ten HangHoa.TenNguoiGui = txtTenNguoiGui.Text.ToString(); HangHoa.TenNguoiNhan = txtTenNguoiNhan.Text.ToString(); //CMND HangHoa.CMNDNguoiGui = ntxtCMNDNguoiGui.Text.ToString(); HangHoa.CMNDNguoiNhan = ntxtCMNDNguoiNhan.Text.ToString(); //SDT HangHoa.SDTNguoiGui = ntxtSDTNguoiGui.Text.ToString(); HangHoa.SDTNguoiNhan = ntxtSDTNguoiNhan.Text.ToString(); //Hàng Hoá HangHoa.TenMonHang = txtTenHang.Text.ToString(); HangHoa.KichThuoc = txtKichThuoc.Text.ToString(); HangHoa.TrongLuong = ntxtTrongLuong.Text.ToString(); //Tien string TempTien = TextBoxGiaTien.Text; int ixdexTien = TextBoxGiaTien.Text.IndexOf("."); if (ixdexTien == -1) { HangHoa.ChiPhiGui = Convert.ToInt32(TempTien); } else { TempTien = TempTien.Replace(".", ""); HangHoa.ChiPhiGui = Convert.ToInt32(TempTien); } string KiGui = string.Format("exec KiGui @TenNguoiGui, @SDTNguoiGui, @CMNDNguoiGui, @TenNguoiNhan, @SDTNguoiNhan, @CMNDNguoiNhan, @TenMonHang, @TrongLuong, @KichThuoc, @ChiPhiGui, @IdChuyen"); string InsertNhatKi = string.Format("exec InsertNhatKi @TenNguoiGui,@SDTNguoiGui,@CMNDNguoiGui,@LoaiGiaoDichGui"); DataTable user = new DataTable(); SqlCommand Com = new SqlCommand(KiGui, Con); SqlCommand ComUuDai = new SqlCommand(InsertNhatKi, Con); //KiGui Com.Parameters.Add(new SqlParameter("@TenNguoiGui", HangHoa.TenNguoiGui)); Com.Parameters.Add(new SqlParameter("@SDTNguoiGui", HangHoa.SDTNguoiGui)); Com.Parameters.Add(new SqlParameter("@CMNDNguoiGui", HangHoa.CMNDNguoiGui)); Com.Parameters.Add(new SqlParameter("@TenNguoiNhan", HangHoa.TenNguoiNhan)); Com.Parameters.Add(new SqlParameter("@SDTNguoiNhan", HangHoa.SDTNguoiNhan)); Com.Parameters.Add(new SqlParameter("@CMNDNguoiNhan", HangHoa.CMNDNguoiNhan)); Com.Parameters.Add(new SqlParameter("@TenMonHang", HangHoa.TenMonHang)); Com.Parameters.Add(new SqlParameter("@TrongLuong", HangHoa.TrongLuong)); Com.Parameters.Add(new SqlParameter("@KichThuoc", HangHoa.KichThuoc)); Com.Parameters.Add(new SqlParameter("@ChiPhiGui", HangHoa.ChiPhiGui)); Com.Parameters.Add(new SqlParameter("@IdChuyen", HangHoa.IdChuyen)); //InsertNhatKiKhachHangGui ComUuDai.Parameters.Add(new SqlParameter("@TenNguoiGui", HangHoa.TenNguoiGui)); ComUuDai.Parameters.Add(new SqlParameter("@SDTNguoiGui", HangHoa.SDTNguoiGui)); ComUuDai.Parameters.Add(new SqlParameter("@CMNDNguoiGui", HangHoa.CMNDNguoiGui)); ComUuDai.Parameters.Add(new SqlParameter("@LoaiGiaoDichGui", "Gửi Hàng" + " - " + HangHoa.TenMonHang)); SqlDataAdapter adapt = new SqlDataAdapter(Com); SqlDataAdapter adapt1 = new SqlDataAdapter(ComUuDai); adapt.Fill(user); adapt1.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Đặt Hàng :{0}: Cho Khách Hàng: {1}!", HangHoa.TenMonHang, HangHoa.TenNguoiGui)); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void LayThongTin(string MaNV) { try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); //Lấy Tên string Ten = string.Format("select nv.TenNhanVien from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc SqlCommand Com = new SqlCommand(Ten, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); txtTen.Text = Com.ExecuteScalar().ToString(); //LayKinhNghiem string KinhNghiem = string.Format("select nv.KinhNghiem from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(KinhNghiem, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); txtKinhNghiem.Text = Com.ExecuteScalar().ToString(); //LayNgaySinh string NgaySinh = string.Format("select nv.NgaySinh from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(NgaySinh, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); txtNgaySinh.Value = Convert.ToDateTime(Com.ExecuteScalar()); //LayGioiTinh string sex = string.Format("select nv.GioiTinh from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(sex, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); if (Com.ExecuteScalar().ToString() == "Nam") { rdNam.Checked = true; } else { rdNu.Checked = true; } //LaySDT string SDT = string.Format("select nv.SDT from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(SDT, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); txtSDT.Text = Com.ExecuteScalar().ToString(); //LayDiaChi string DiaChi = string.Format("select nv.DiaChi from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(DiaChi, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); txtDiaChi.Text = Com.ExecuteScalar().ToString(); //LayhrsChay string h_Chay = string.Format("select nv.SoGioDaChay from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(h_Chay, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); txtSohChay.Text = Com.ExecuteScalar().ToString(); //LayLoaiNV string LoaiNV = string.Format("select nv.LoaiNV from NhanVien nv where nv.MaNhanVien=@MaNV"); //Gọi Proc Com = new SqlCommand(LoaiNV, Con); Com.Parameters.Add(new SqlParameter("@MaNV", MaNV)); txtLoaiNhanVien.Text = TenLoaiNV(Com.ExecuteScalar().ToString()); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } }
private void btnNhanHang_Click(object sender, EventArgs e) { if (MetroFramework.MetroMessageBox.Show(this, "Chắc Chắn Hay Không", "Bạn Có Chắc Huỷ Vé Này", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Class.KiGuiHangHoa HangHoa = new Class.KiGuiHangHoa(); //Ten HangHoa.TenNguoiNhan = txtTenNguoiNhan.Text.ToString(); //CMND HangHoa.CMNDNguoiNhan = ntxtCMNDNguoiNhan.Text.ToString(); //SDT HangHoa.SDTNguoiNhan = ntxtSDTNguoiNhan.Text.ToString(); //Hàng Hoá HangHoa.TenMonHang = txtTenHang.Text.ToString(); string IdHangHoa = IdHangCanDoi; string IdChuyen = IdChuyenCanDoi; try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); DataTable user = new DataTable(); string NhanHang = string.Format("exec NhanHang @IdChuyen ,@IdHangHoa"); string InsertNikki = string.Format("exec InsertNikki @TenNguoiNhan,@SDTNguoiNhan,@CMNDNguoiNhan,@LoaiGiaoDichNhan"); //Insert NhatKyNguoiDung SqlCommand ComUuDai = new SqlCommand(InsertNikki, Con); //dat hang SqlCommand Com = new SqlCommand(NhanHang, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", IdChuyen)); Com.Parameters.Add(new SqlParameter("@IdHangHoa", IdHangHoa)); //InsertUuDaiKhachHang //InsertNhatKiKhachHangNhan ComUuDai.Parameters.Add(new SqlParameter("@TenNguoiNhan", HangHoa.TenNguoiNhan)); ComUuDai.Parameters.Add(new SqlParameter("@SDTNguoiNhan", HangHoa.SDTNguoiNhan)); ComUuDai.Parameters.Add(new SqlParameter("@CMNDNguoiNhan", HangHoa.CMNDNguoiNhan)); ComUuDai.Parameters.Add(new SqlParameter("@LoaiGiaoDichNhan", "Nhận Hàng" + " - " + HangHoa.TenMonHang)); // SqlDataAdapter adapt1 = new SqlDataAdapter(ComUuDai); SqlDataAdapter adapt = new SqlDataAdapter(Com); adapt.Fill(user); adapt1.Fill(user); Con.Close(); MetroFramework.MetroMessageBox.Show(this, string.Format("Đã Trao Hàng Mã Số:{0}", IdHangCanDoi + " - " + IdChuyenCanDoi)); NhanHang_Load(sender, e); metroPanel1.Visible = false; btnNhanHang.Visible = false; } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } } }
private CDatVe GetInfoKhachHang() { CDatVe Info = new CDatVe(); try { SqlConnection Con = KetNoiCSDL.KetNoiSQL(); Con.Open(); //IdChuyen string IdChuyen = string.Format("exec GetInfoKhachHang_IdChuyen @ID"); //Gọi Proc SqlCommand Com = new SqlCommand(IdChuyen, Con); Com.Parameters.Add(new SqlParameter("@ID", IdVe)); Info.IdChuyen = Com.ExecuteScalar().ToString(); //Ten string Ten = string.Format("exec GetInfoKhachHang_Ten @ID"); //Gọi Proc Com = new SqlCommand(Ten, Con); Com.Parameters.Add(new SqlParameter("@ID", IdVe)); Info.TenKhachHang = Com.ExecuteScalar().ToString(); //CMND string CMND = string.Format("exec GetInfoKhachHang_CMND @ID"); //Gọi Proc Com = new SqlCommand(CMND, Con); Com.Parameters.Add(new SqlParameter("@ID", IdVe)); Info.CMND = Com.ExecuteScalar().ToString(); //LayNgaySinh string NgaySinh = string.Format("exec GetInfoKhachHang_NgaySinh @ID"); //Gọi Proc Com = new SqlCommand(NgaySinh, Con); Com.Parameters.Add(new SqlParameter("@ID", IdVe)); Info.NgaySinh = Com.ExecuteScalar().ToString(); int index = Info.NgaySinh.IndexOf(" "); if (index != -1) { Info.NgaySinh = Info.NgaySinh.Substring(0, index); } //LayDienThoai string SoDienThoai = string.Format("exec GetInfoKhachHang_SDT @ID"); //Gọi Proc Com = new SqlCommand(SoDienThoai, Con); Com.Parameters.Add(new SqlParameter("@ID", IdVe)); Info.SDT = Com.ExecuteScalar().ToString(); //LayDiaChi string DiaChi = string.Format("exec GetInfoKhachHang_DiaChi @ID"); //Gọi Proc Com = new SqlCommand(DiaChi, Con); Com.Parameters.Add(new SqlParameter("@ID", IdVe)); Info.QueQuan = Com.ExecuteScalar().ToString(); //Giá Vé Info.TienVe = TienVe; //LaySoXe string SoXe = string.Format("exec GetInfoKhachHang_SoXe @IdChuyen"); //Gọi Proc Com = new SqlCommand(SoXe, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", Info.IdChuyen)); Info.SoXe = Com.ExecuteScalar().ToString(); //NgayDi string NgayDi = string.Format("exec GetInfoKhachHang_NgayDi @IdChuyen"); //Gọi Proc Com = new SqlCommand(NgayDi, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", Info.IdChuyen)); Info.NgayDi = Com.ExecuteScalar().ToString(); //GioDi string GioDi = string.Format("exec GetInfoKhachHang_GioDi @IdChuyen "); //Gọi Proc Com = new SqlCommand(GioDi, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", Info.IdChuyen)); Info.GioDi = Com.ExecuteScalar().ToString(); //HieuXe string HieuXe = string.Format("exec GetInfoKhachHang_HieuXe @IdChuyen"); //Gọi Proc Com = new SqlCommand(HieuXe, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", Info.IdChuyen)); Info.HieuXe = Com.ExecuteScalar().ToString(); //LoTrinh string LoTrinh = string.Format("exec GetInfoKhachHang_LoTrinh @IdChuyen"); //Gọi Proc Com = new SqlCommand(LoTrinh, Con); Com.Parameters.Add(new SqlParameter("@IdChuyen", Info.IdChuyen)); Info.LoTrinh = Com.ExecuteScalar().ToString(); //TenNhanVien string TenNhanVien = string.Format("exec GetInfoKhachHang_TenNhanVien @IdNguoiDung"); //Gọi Proc Com = new SqlCommand(TenNhanVien, Con); Com.Parameters.Add(new SqlParameter("@IdNguoiDung", IdNguoiDung_FormDatVe)); lblTenBanVe.Text = Com.ExecuteScalar().ToString(); Con.Close(); } catch (Exception EX) { MetroFramework.MetroMessageBox.Show(this, EX.Message); } return(Info); }