//protected void btnSaveProfile_Click(object sender, EventArgs e) //{//cap nhat thong tin tai khoan admin // string hoTen = string.Empty; // if (!MyUtility.TextBoxHopLe(txtHoTen, out hoTen)) // { // lblThongBaoProfile.Text = ThongBao.BatBuoc; // return; // } // NhanVien nv = LayNVTheoQS(); // if (nv != default(NhanVien)) // { // nv.HoTen = hoTen; // nv.MaVTCV = int.Parse(ddlVTCV.SelectedValue); // nv.GioiTinh = rblGT.SelectedValue == "1" ? true : false; // nv.NgaySinh = // hix dang code // } //} //t dang lam trang nay em dung lam trang nay nua nhe. em lam trang nao fai fill vao schemale de moi nguoi biet. protected void btnSaveProfile_Click(object sender, EventArgs e) {//cap nhat thong tin tai khoan admin string hoTen = string.Empty; if (!MyUtility.TextBoxHopLe(txtHoTen, out hoTen)) { lblThongBaoProfile.Text = ThongBao.BatBuoc; return; } DateTime ns = new DateTime(); if (!DateTime.TryParseExact(txtNgaySinh.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None, out ns)) { lblThongBaoProfile.Text = ThongBao.NgayKhongDung; return; } NhanVien nv = LayNVTheoQS(); if (nv != default(NhanVien)) { nv.HoTen = hoTen; nv.MaVTCV = int.Parse(ddlVTCV.SelectedValue); nv.GioiTinh = rblGT.SelectedValue == "1" ? true : false; nv.NgaySinh = ns; nv.Email = txtEmail.Text; nv.TrangThai = rblTT.SelectedValue == "1" ? true : false; } //luu hinh nhan vien neu co: string fileHinhCu = nv.Hinh; if (fulProfile.HasFile) { string extension = string.Empty; if (!MyUtility.FileHinhHopLe(fulProfile, out extension)) { lblThongBaoProfile.Text = ThongBao.HinhKhongHoLe; return; } if (MyUtility.LuuHinh(fulProfile, string.Format(@"~/images/NhanVien/{0}.{1}", nv.MaNV, extension))) { nv.Hinh = string.Format("{0}.{1}", nv.MaNV, extension); if (MyUtility.ChuoiHopLe(fileHinhCu) && !fileHinhCu.Equals(nv.Hinh)) { //xoa hinh cu: MyUtility.XoaHinh(string.Format(@"~/images/NhanVien/{0}", fileHinhCu)); } } } if (!kho.SuaNhanVien(nv) || !kho.Luu()) { lblThongBaoProfile.Text = ThongBao.SuaKhongThanhCong; return; } this.LoadTTNV(); lblThongBaoProfile.Text = ThongBao.ThanhCong; }
protected void btnCapNhat_Click(object sender, EventArgs e) { if (!MyUtility.ChuoiHopLe(txtTenDV.Text)) { lblKQDV.Text = ThongBao.BatBuoc; return; } if (Request.QueryString["dv"] != null) {//cap nhat: int maDV = int.Parse(Request.QueryString["dv"]); DonVi dv = kho.TimDonVi(maDV); if (dv == default(DonVi)) { return; } dv.TenDV = txtTenDV.Text; dv.TenDVEN = string.Empty; dv.DienThoai = txtDT.Text; dv.DiaChi = txtDC.Text; dv.Email = txtEmail.Text; dv.Fax = txtFax.Text; dv.TrangThai = true; dv.Logo = string.Empty; dv.Website = txtWebsite.Text; //neu co logo: if (fulLogo.HasFile) { string exten; if (!MyUtility.FileHinhHopLe(fulLogo, out exten)) { lblKQDV.Text = ThongBao.HinhKhongHoLe; return; } var virPath = @"~/images/LogoDV/" + dv.MaDV + "." + exten; if (MyUtility.LuuHinh(fulLogo, virPath)) { dv.Logo = dv.MaDV + "." + exten; } } if (!kho.SuaDonVi(dv) || !kho.Luu()) { lblKQDV.Text = ThongBao.SuaKhongThanhCong; return; } Response.Redirect("~/SuperAdmin/QLDonVi.aspx"); } }
protected void btnSave_Click(object sender, EventArgs e) { if (!MyUtility.ChuoiHopLe(txtTenDV.Text)) { lblKQDV.Text = ThongBao.BatBuoc; return; } DonVi dv = new DonVi() { TenDV = txtTenDV.Text, TenDVEN = string.Empty, DienThoai = txtDT.Text, DiaChi = txtDC.Text, Email = txtEmail.Text, Fax = txtFax.Text, TrangThai = true, Logo = string.Empty, Website = txtWebsite.Text }; //neu co logo: if (fulLogo.HasFile) { string exten; if (!MyUtility.FileHinhHopLe(fulLogo, out exten)) { lblKQDV.Text = ThongBao.HinhKhongHoLe; return; } var virPath = @"~/images/LogoDV/" + dv.MaDV + "." + exten; if (MyUtility.LuuHinh(fulLogo, virPath)) { dv.Logo = dv.MaDV + "." + exten; } } if (!kho.ThemDonVi(dv)) { lblKQDV.Text = ThongBao.ThemKhongThanhCong; return; } if (!kho.Luu()) { lblKQDV.Text = ThongBao.ThemKhongThanhCong; return; } else { //neu co logo: if (fulLogo.HasFile) { string exten; if (!MyUtility.FileHinhHopLe(fulLogo, out exten)) { lblKQDV.Text = ThongBao.HinhKhongHoLe; return; } var virPath = @"~/images/LogoDV/" + dv.MaDV + "." + exten; if (MyUtility.LuuHinh(fulLogo, virPath)) { dv.Logo = dv.MaDV + "." + exten; if (!kho.Luu()) { lblKQDV.Text = ThongBao.ThemKhongThanhCong; return; } } } //reload: Response.Redirect("~/SuperAdmin/QLDonVi.aspx"); } }
protected void btnCreate_Click(object sender, EventArgs e) { string maNV = string.Empty; if (!MyUtility.TextBoxHopLe(txtMaNV, out maNV)) { lblThongBao.Text = ThongBao.BatBuoc; return; } string hoTen = string.Empty; if (!MyUtility.TextBoxHopLe(txtHoTen, out hoTen)) { lblThongBao.Text = ThongBao.BatBuoc; return; } DateTime ns = new DateTime(); if (!DateTime.TryParseExact(txtNgaySinh.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None, out ns)) { lblThongBao.Text = ThongBao.NgayKhongDung; return; } if (!MyUtility.MatKhauTrungKhop(txtPass.Text, txtRetype.Text)) { lblThongBao.Text = ThongBao.MatKhauKhongTrung; return; } ; //lay thong tin: NhanVien nv = new NhanVien() { MaNV = maNV, HoTen = hoTen.ToProper(), MaVTCV = int.Parse(ddlVTCV.SelectedValue), GioiTinh = rblGT.SelectedValue == "1" ? true : false, NgaySinh = ns, Email = txtEmail.Text, DienThoai = txtDT.Text, TrangThai = rblTT.SelectedValue == "1" ? true : false, MatKhau = txtPass.Text, MaVT = int.Parse(ddlVaiTro.SelectedValue), MaCM = int.Parse(ddlChuyenMon.SelectedValue) }; //them nhan vien: //luu hinh nhan vien neu co: if (fulProfile.HasFile) { string extension = string.Empty; if (!MyUtility.FileHinhHopLe(fulProfile, out extension)) { lblThongBao.Text = ThongBao.HinhKhongHoLe; return; } if (MyUtility.LuuHinh(fulProfile, string.Format(@"~/images/NhanVien/{0}.{1}", nv.MaNV, extension))) { nv.Hinh = string.Format("{0}.{1}", nv.MaNV, extension); } } if (!kho.ThemNhanVien(nv) || !kho.Luu()) { lblThongBao.Text = ThongBao.ThemKhongThanhCong; return; } this.LoadTTNV(); lblThongBao.Text = ThongBao.ThanhCong; }