Beispiel #1
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            GridView    gv  = (GridView)sender;
            GridViewRow row = GridView1.Rows[e.RowIndex];

            string sID              = gv.DataKeys[e.RowIndex]["MaHD"].ToString();
            string sNewUserName     = ((TextBox)(row.Cells[1].Controls[0])).Text;
            string sNewAddress      = ((TextBox)(row.Cells[2].Controls[0])).Text;
            string sNewPhoneNumber  = ((TextBox)(row.Cells[3].Controls[0])).Text;
            string sNewRecipient    = ((TextBox)(row.Cells[4].Controls[0])).Text;
            string sNewDeliveryDate = ((TextBox)(row.Cells[5].Controls[0])).Text;
            string sNewTotal        = ((TextBox)(row.Cells[6].Controls[0])).Text;
            string sNewOrderDay     = ((TextBox)(row.Cells[7].Controls[0])).Text;


            DDatHangDTO ddhDTO = new DDatHangDTO();
            ddhDTO.MaHD         = int.Parse(sID);
            ddhDTO.Username     = sNewUserName;
            ddhDTO.DiaChi       = sNewAddress;
            ddhDTO.SDT          = sNewPhoneNumber;
            ddhDTO.TenNguoiNhan = sNewRecipient;
            ddhDTO.Newdelivery  = sNewDeliveryDate;
            ddhDTO.TongTien     = int.Parse(sNewTotal);
            ddhDTO.NewOrder     = sNewOrderDay;
            DDatHangBUS.SuaDonDatHang(ddhDTO);
            GridView1.EditIndex = -1;
            BindItemsList();
        }
        catch (Exception ex)
        {
            Response.Write("<script type='text/javascript'>"
                           + "alert('Có lỗi xảy ra. Vui Lòng điền đúng kiểu dữ liệu yêu cầu !!!');"
                           + "</script>");
        }
    }