Click here to Skip to main content
15,881,600 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Improve page performance for aspx page Pin
Not Active3-Oct-11 9:51
mentorNot Active3-Oct-11 9:51 
QuestionEmail reply color Pin
Blikkies3-Oct-11 0:45
professionalBlikkies3-Oct-11 0:45 
AnswerRe: Email reply color Pin
Parwej Ahamad3-Oct-11 8:44
professionalParwej Ahamad3-Oct-11 8:44 
QuestionHow to Focus On The Next Text Box After PostBack? Pin
behzad_Sadeghi2-Oct-11 9:19
behzad_Sadeghi2-Oct-11 9:19 
QuestionCCTV in asp.net Pin
Hassan Sajedi2-Oct-11 6:32
Hassan Sajedi2-Oct-11 6:32 
AnswerRe: CCTV in asp.net Pin
Pravin Patil, Mumbai3-Oct-11 19:59
Pravin Patil, Mumbai3-Oct-11 19:59 
QuestionC# asp.net 2010 Pin
Member 82175172-Oct-11 6:25
Member 82175172-Oct-11 6:25 
GeneralCode chạy thủ tục thêm, xóa, sửa, xem chi tiết, hiện danh sách của bảng Nhân viên Pin
Hoàng Thái Bình2-Oct-11 5:59
Hoàng Thái Bình2-Oct-11 5:59 
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_NhanVien_Admin : System.Web.UI.Page
{
    CTH51Cls.NhanVien nv = new CTH51Cls.NhanVien();
    CTH51Cls.PhongBan ph = new CTH51Cls.PhongBan();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            griNhanVien.DataSource = nv.DS();
            griNhanVien.DataBind();
            droPhongBan.DataSource = ph.DS();
            droPhongBan.DataBind();
        }
    }

    protected void btnThem_Click(object sender, EventArgs e)
    {
        CTH51Cls.NhanVien nv = new CTH51Cls.NhanVien();
        txtHoTen.Text = txtHoTen.Text.Trim();
        while (txtHoTen.Text.IndexOf("  ") >= 0)
        {
            txtHoTen.Text = txtHoTen.Text.Replace("  ", " ");
        }
        nv.HoNV = txtHoTen.Text.Substring(0, txtHoTen.Text.LastIndexOf(" "));
        nv.TenNV = txtHoTen.Text.Substring(txtHoTen.Text.LastIndexOf(" ") + 1);
        nv.DienThoai = txtDienThoai.Text;
        nv.GioiTinh = chkGioiTinh.Checked;
        nv.DiaChi = txtDiaChi.Text;
        if (fileAnhNV.HasFile)
            if (System.IO.File.Exists(Server.MapPath("~/Resource/Staff/") + fileAnhNV.FileName))
                nv.AnhNV = "";
            else
            {
                nv.AnhNV = fileAnhNV.FileName;
                string duongdan = Server.MapPath("~/Resource/Staff/");
                fileAnhNV.SaveAs(duongdan + fileAnhNV.FileName);
            }
        else
            nv.AnhNV = "";
        nv.Email = txtEmail.Text;
        nv.MatKhau = txtEmail.Text;
        nv.MaPB = int.Parse(droPhongBan.SelectedValue);
        nv.Them();
        griNhanVien.DataSource = nv.DS();
        griNhanVien.DataBind();
        txtMaNV.Text = "";
        txtHoTen.Text = "";
        txtDienThoai.Text = "";
        txtDiaChi.Text = "";
        txtEmail.Text = "";
        imgAnhNV.ImageUrl = "";
        chkGioiTinh.Checked = false;
    }


    protected void griNhanVien_SelectedIndexChanged(object sender, EventArgs e)
    {
        nv.MaNV = int.Parse(griNhanVien.SelectedValue.ToString());
        nv.CT();
        txtMaNV.Text = nv.MaNV.ToString();
        txtHoTen.Text = nv.HoNV + " " + nv.TenNV;
        txtDienThoai.Text = nv.DienThoai;
        chkGioiTinh.Checked = nv.GioiTinh;
        txtDiaChi.Text = nv.DiaChi;
        if (nv.AnhNV != "")
            imgAnhNV.ImageUrl = "~/Resource/Staff/" + nv.AnhNV;
        else imgAnhNV.ImageUrl = "";
        txtEmail.Text = nv.Email;
        droPhongBan.SelectedValue = nv.MaPB.ToString();
        imgAnhNV.ToolTip = imgAnhNV.ImageUrl.Substring(imgAnhNV.ImageUrl.LastIndexOf("/") + 1);
    }


    protected void btnXoa_Click(object sender, EventArgs e)
    {
        CTH51Cls.NhanVien nv = new CTH51Cls.NhanVien();
        nv.MaNV = int.Parse(txtMaNV.Text);
        nv.Xoa();
        griNhanVien.DataSource = nv.DS();
        griNhanVien.DataBind();
        if (System.IO.File.Exists(Server.MapPath(imgAnhNV.ImageUrl)))
        System.IO.File.Delete(Server.MapPath(imgAnhNV.ImageUrl));
        txtMaNV.Text = "";
        txtHoTen.Text = "";
        txtDienThoai.Text = "";
        txtDiaChi.Text = "";
        txtEmail.Text = "";
        chkGioiTinh.Checked = false;
    }


    protected void btnSua_Click(object sender, EventArgs e)
    {
        CTH51Cls.NhanVien nv = new CTH51Cls.NhanVien();
        nv.MaNV = int.Parse(txtMaNV.Text);
        nv.HoNV = txtHoTen.Text.Substring(0, txtHoTen.Text.LastIndexOf(" "));
        nv.TenNV = txtHoTen.Text.Substring(txtHoTen.Text.LastIndexOf(" ") + 1);
        nv.DienThoai = txtDienThoai.Text;
        nv.GioiTinh = chkGioiTinh.Checked;
        nv.DiaChi = txtDiaChi.Text;
        if (fileAnhNV.HasFile)
        {
            if (System.IO.File.Exists(Server.MapPath(imgAnhNV.ImageUrl)))
            System.IO.File.Delete(Server.MapPath(imgAnhNV.ImageUrl));
            if (System.IO.File.Exists(Server.MapPath("~/Resource/Staff/") + fileAnhNV.FileName))
                nv.AnhNV = "";
            else
            {
                nv.AnhNV = fileAnhNV.FileName;
                string duongdan = Server.MapPath("~/Resource/Staff/");
                fileAnhNV.SaveAs(duongdan + fileAnhNV.FileName);
            }
        }
        else
            nv.AnhNV = imgAnhNV.ImageUrl.Substring(imgAnhNV.ImageUrl.LastIndexOf("/") + 1);
        nv.Email = txtEmail.Text;
        nv.MatKhau = txtEmail.Text;
        nv.MaPB = int.Parse(droPhongBan.SelectedValue);
        nv.Sua();
        griNhanVien.DataSource = nv.DS();
        griNhanVien.DataBind();
        txtMaNV.Text = "";
        txtHoTen.Text = "";
        txtDienThoai.Text = "";
        txtDiaChi.Text = "";
        txtEmail.Text = "";
        imgAnhNV.ImageUrl = "";
        chkGioiTinh.Checked = false;
    }
}


modified 3-Oct-11 19:15pm.

AnswerRe: Code chạy thủ tục thêm, xóa, sửa, xem chi tiết, hiện danh sách của bảng Nhân viên Pin
Dalek Dave2-Oct-11 7:30
professionalDalek Dave2-Oct-11 7:30 
AnswerRe: Code chạy thủ tục thêm, xóa, sửa, xem chi tiết, hiện danh sách của bảng Nhân viên Pin
TheGreatAndPowerfulOz3-Oct-11 10:19
TheGreatAndPowerfulOz3-Oct-11 10:19 
QuestionISs there any solution. Pin
uspatel30-Sep-11 21:26
professionaluspatel30-Sep-11 21:26 
AnswerRe: ISs there any solution. Pin
Richard MacCutchan30-Sep-11 21:29
mveRichard MacCutchan30-Sep-11 21:29 
GeneralRe: ISs there any solution. Pin
uspatel30-Sep-11 21:48
professionaluspatel30-Sep-11 21:48 
Questionoverride master page Pin
byka30-Sep-11 4:27
byka30-Sep-11 4:27 
AnswerRe: override master page Pin
Parwej Ahamad30-Sep-11 4:58
professionalParwej Ahamad30-Sep-11 4:58 
GeneralRe: override master page Pin
byka30-Sep-11 5:38
byka30-Sep-11 5:38 
GeneralRe: override master page Pin
Parwej Ahamad30-Sep-11 5:46
professionalParwej Ahamad30-Sep-11 5:46 
Questionprogramming in n tier Pin
sheemap29-Sep-11 22:18
sheemap29-Sep-11 22:18 
AnswerRe: programming in n tier Pin
walterhevedeich29-Sep-11 22:27
professionalwalterhevedeich29-Sep-11 22:27 
QuestionUsing Telerik MVC Extensions to select all checkboxes in a grid Pin
jboyd11129-Sep-11 18:10
jboyd11129-Sep-11 18:10 
Questionasp.net 2010 debugging Pin
Member 821751729-Sep-11 7:58
Member 821751729-Sep-11 7:58 
AnswerRe: asp.net 2010 debugging Pin
Pravin Patil, Mumbai29-Sep-11 19:07
Pravin Patil, Mumbai29-Sep-11 19:07 
AnswerRe: asp.net 2010 debugging Pin
keyur satyadev29-Sep-11 19:49
keyur satyadev29-Sep-11 19:49 
QuestionASP and Javascript Pin
berba29-Sep-11 3:16
berba29-Sep-11 3:16 
AnswerRe: ASP and Javascript Pin
Morgs Morgan29-Sep-11 22:55
Morgs Morgan29-Sep-11 22:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.