Exemple #1
0
 public bool SuaAdminDV(AdminDV ad)
 {
     try
     {
         var kq = TimAdminDV(ad.MaDV);
         if (kq == default(AdminDV))
         {
             return(false);
         }
         kq.MaDV     = ad.MaDV;
         kq.TenDN    = ad.TenDN;
         kq.GioiTinh = ad.GioiTinh;
         kq.NgaySinh = ad.NgaySinh;
         if (MyUtility.ChuoiHopLe(ad.Hinh))
         {
             kq.Hinh = ad.Hinh;
         }
         kq.Email     = ad.Email;
         kq.DienThoai = ad.DienThoai;
         kq.TrangThai = ad.TrangThai;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #2
0
    //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;
    }
Exemple #3
0
    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");
        }
    }
Exemple #4
0
    void LoadTTDV(int maDV)
    {
        DonVi dv = this.kho.TimDonVi(maDV);

        if (dv != default(DonVi))
        {
            //header:
            lblMaDV.Text        = dv.MaDV.ToString();
            lblDiaChiDV.Text    = dv.DiaChi;
            lblFaxDV.Text       = dv.Fax;
            lblEmailDV.Text     = dv.Email;
            lblDienThoaiDV.Text = dv.DienThoai;
            lblTenDV.Text       = dv.TenDV;
            lblWebsite.Text     = dv.Website;
            //thong tin don vi:
            txtTenDV.Text   = dv.TenDV;
            txtWebsite.Text = dv.Website;
            txtFax.Text     = dv.Fax;
            txtEmail.Text   = dv.Email;
            txtDC.Text      = dv.DiaChi;
            txtDT.Text      = dv.DienThoai;
            txtWebsite.Text = dv.Website;
            if (MyUtility.ChuoiHopLe(dv.Logo))
            {
                imgLogo.ImageUrl = string.Format(@"~/images/LogoDV/{0}", dv.Logo);
            }
            //load thong tin admin don vi:
            if (dv.AdminDV != null)
            {
                lblHoTenAdmin.Text     = dv.AdminDV.HoTen;
                lblEmailAdmin.Text     = dv.AdminDV.Email;
                lblTenDN.Text          = dv.AdminDV.TenDN;
                lblDienThoaiAdmin.Text = dv.AdminDV.DienThoai;
                lblGioiTinh.Text       = (bool)dv.AdminDV.GioiTinh ? "Nam" : "Nữ";
            }
        }
    }
Exemple #5
0
    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");
        }
    }