protected void m_grid_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int id = e.RowIndex; m_grid.EditIndex = id; GridViewRow row = m_grid.Rows[id]; string NhanVien_Logon_id = "3d2df69a-4d7c-4d78-a4a3-075a169a109d"; string TenHangMuc = ((TextBox)row.FindControl("txtUHangMuc")).Text; string sSoLuong = ((TextBox)row.FindControl("txtUSoLuong")).Text; string sDonGia = ((TextBox)row.FindControl("txtUDonGia")).Text; double SoLuong = Convert.ToDouble(sSoLuong==""? "0": sSoLuong); double DonGia = Convert.ToDouble(sDonGia==""? "0": sDonGia); double TongTien = SoLuong * DonGia; double VAT = TongTien * 0.01; //double VAT = Convert.ToDouble(((TextBox)row.FindControl("txtIVAT")).Text); string sPhiCacLoai = ((TextBox)row.FindControl("txtUPhiCacLoai")).Text; string sGiamGia = ((TextBox)row.FindControl("txtUGiamGia")).Text; double PhiCacLoai = Convert.ToDouble(sPhiCacLoai==""? "0": sPhiCacLoai); double GiamGia = Convert.ToDouble(sGiamGia==""? "0": sGiamGia); double ThanhTien = TongTien + VAT + PhiCacLoai - GiamGia; //------------- string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLConn"].ToString(); System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); cmd.CommandText = "select * from thanhpham where tenthanhpham=N'" + TenHangMuc + "'"; cmd.Connection = sqlConnection; da = new SqlDataAdapter(cmd); da.Fill(ds); string ThanhPham_id = ""; if (ds.Tables[0].Rows.Count > 0) { ThanhPham_id = ds.Tables[0].Rows[0]["ThanhPham_Id"].ToString(); } else { ThanhPham_id = ""; } ds = new DataSet(); cmd.CommandText = "select * from thietbi where tenthietbi=N'" + TenHangMuc + "'"; cmd.Connection = sqlConnection; da = new SqlDataAdapter(cmd); da.Fill(ds); string ThietBi_id = ""; if (ds.Tables[0].Rows.Count > 0) { ThietBi_id = ds.Tables[0].Rows[0]["ThietBi_Id"].ToString(); } else { ThietBi_id = ""; } if (m_grid.DataKeys[id].Value.ToString() != "") { clsPhieuXuat objPhieuXuat = new clsPhieuXuat(); objPhieuXuat.NhanVienLogon_Id = NhanVien_Logon_id; objPhieuXuat.PhieuXuat_Id = sPhieuNhap_Id; objPhieuXuat.ThietBi_Id = ThietBi_id; objPhieuXuat.SoLuong = SoLuong; objPhieuXuat.DonGia = DonGia; objPhieuXuat.VAT = VAT; objPhieuXuat.GiamGia = GiamGia; objPhieuXuat.PhiCacLoai = PhiCacLoai; string _result = objPhieuXuat.InsertChiTiet(); } } catch (Exception ex) { ltlAnnouncement.Text = "Khong cap nhat duoc du lieu. Vui long lien he voi quan tri<br>" + ex.Message; } bindData(-1); }