Click here to Skip to main content
15,175,222 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Improve page performance for aspx page Pin
Not Active3-Oct-11 10:51
mentorNot Active3-Oct-11 10:51 
QuestionEmail reply color Pin
Blikkies3-Oct-11 1:45
professionalBlikkies3-Oct-11 1:45 
AnswerRe: Email reply color Pin
Parwej Ahamad3-Oct-11 9:44
professionalParwej Ahamad3-Oct-11 9:44 
QuestionHow to Focus On The Next Text Box After PostBack? Pin
behzad_Sadeghi2-Oct-11 10:19
Memberbehzad_Sadeghi2-Oct-11 10:19 
QuestionCCTV in asp.net Pin
Hassan Sajedi2-Oct-11 7:32
MemberHassan Sajedi2-Oct-11 7:32 
AnswerRe: CCTV in asp.net Pin
Pravin Patil, Mumbai3-Oct-11 20:59
MemberPravin Patil, Mumbai3-Oct-11 20:59 
QuestionC# asp.net 2010 Pin
Member 82175172-Oct-11 7:25
MemberMember 82175172-Oct-11 7: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 6:59
MemberHoàng Thái Bình2-Oct-11 6: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 8:30
professionalDalek Dave2-Oct-11 8: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 11:19
MemberTheGreatAndPowerfulOz3-Oct-11 11:19 
QuestionISs there any solution. Pin
uspatel30-Sep-11 22:26
professionaluspatel30-Sep-11 22:26 
AnswerRe: ISs there any solution. Pin
Richard MacCutchan30-Sep-11 22:29
mveRichard MacCutchan30-Sep-11 22:29 
GeneralRe: ISs there any solution. Pin
uspatel30-Sep-11 22:48
professionaluspatel30-Sep-11 22:48 
Questionoverride master page Pin
byka30-Sep-11 5:27
Memberbyka30-Sep-11 5:27 
AnswerRe: override master page Pin
Parwej Ahamad30-Sep-11 5:58
professionalParwej Ahamad30-Sep-11 5:58 
GeneralRe: override master page Pin
byka30-Sep-11 6:38
Memberbyka30-Sep-11 6:38 
GeneralRe: override master page Pin
Parwej Ahamad30-Sep-11 6:46
professionalParwej Ahamad30-Sep-11 6:46 
Questionprogramming in n tier Pin
sheemap29-Sep-11 23:18
Membersheemap29-Sep-11 23:18 
AnswerRe: programming in n tier Pin
walterhevedeich29-Sep-11 23:27
professionalwalterhevedeich29-Sep-11 23:27 
QuestionUsing Telerik MVC Extensions to select all checkboxes in a grid Pin
jboyd11129-Sep-11 19:10
Memberjboyd11129-Sep-11 19:10 
Questionasp.net 2010 debugging Pin
Member 821751729-Sep-11 8:58
MemberMember 821751729-Sep-11 8:58 
AnswerRe: asp.net 2010 debugging Pin
Pravin Patil, Mumbai29-Sep-11 20:07
MemberPravin Patil, Mumbai29-Sep-11 20:07 
AnswerRe: asp.net 2010 debugging Pin
keyur satyadev29-Sep-11 20:49
Memberkeyur satyadev29-Sep-11 20:49 
QuestionASP and Javascript Pin
berba29-Sep-11 4:16
Memberberba29-Sep-11 4:16 
AnswerRe: ASP and Javascript Pin
Morgs Morgan29-Sep-11 23:55
MemberMorgs Morgan29-Sep-11 23: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.