Exemple #1
0
    protected void bntThem_Click(object sender, EventArgs e)
    {
        try
        {
            if ((txtTenMon.Text != "") && (txtMaMon.Text != "") && (txtDonGia.Text != "") && (txtDVT.Text != ""))
            {
                string TenFile = "";
                if (FileAnh.HasFile)
                {
                    TenFile = FileAnh.FileName;
                    FileAnh.SaveAs(Server.MapPath("~/Images/") + TenFile);
                }
                ThemMon(txtMaMon.Text, txtTenMon.Text, DropDownMaLoai.SelectedValue.ToString(), txtDonGia.Text, txtDVT.Text, TenFile);
                DgThucDon.DataSource = dsThucDon();
                DgThucDon.DataBind();

                if (DgThucDon.Rows.Count > 0)
                {
                    DgThucDon.HeaderRow.Cells[0].Text = "Mã Món";
                    DgThucDon.HeaderRow.Cells[1].Text = "Tên Món";
                    DgThucDon.HeaderRow.Cells[2].Text = "Mã Loại";
                    DgThucDon.HeaderRow.Cells[3].Text = "Đơn Giá";
                    DgThucDon.HeaderRow.Cells[4].Text = "Đơn Vị Tính";
                    DgThucDon.HeaderRow.Cells[5].Text = "Ảnh Món";
                }
                txtMaMon.Text  = "";
                txtTenMon.Text = "";
                txtDVT.Text    = "";
                txtDonGia.Text = "";
            }
            else
            {
                txtThongBao.Text = "Không được bỏ trống các thuộc tính!";
            }
        }
        catch (Exception) { }
    }