protected void gridBarCode_Init(object sender, EventArgs e) { data = new dataHangHoa(); ASPxGridView gridBarCode = sender as ASPxGridView; object IDHangHoa = gridBarCode.GetMasterRowKeyValue(); gridBarCode.DataSource = data.GetListBarCode(IDHangHoa); gridBarCode.DataBind(); }
protected void gridBarCode_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { data = new dataHangHoa(); int ID = Int32.Parse(e.Keys["ID"].ToString()); data.XoaBarCode(ID); e.Cancel = true; ASPxGridView gridBarCode = sender as ASPxGridView; object IDHangHoa = gridBarCode.GetMasterRowKeyValue(); gridBarCode.DataSource = data.GetListBarCode(IDHangHoa); gridBarCode.DataBind(); }
protected void gridBarCode_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { data = new dataHangHoa(); ASPxGridView gridBarCode = sender as ASPxGridView; int ID = Int32.Parse(e.Keys["ID"].ToString()); object IDHangHoa = gridBarCode.GetMasterRowKeyValue(); string BarCode = e.NewValues["Barcode"] != null ? e.NewValues["Barcode"].ToString() : ""; data.CapNhatBarCode(ID, IDHangHoa, BarCode); e.Cancel = true; gridBarCode.CancelEdit(); gridBarCode.DataSource = data.GetListBarCode(IDHangHoa); gridBarCode.DataBind(); }
protected TokenCollection LoadListBarCode(object ID) { TokenCollection listBarCode = new TokenCollection(); if (ID != null) { DataTable dt = data.GetListBarCode(ID); foreach (DataRow row in dt.Rows) { listBarCode.Add(row["Barcode"].ToString()); } } return(listBarCode); }
protected void gridBarCode_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { data = new dataHangHoa(); ASPxGridView gridBarCode = sender as ASPxGridView; object IDHangHoa = gridBarCode.GetMasterRowKeyValue(); string BarCode = e.NewValues["Barcode"].ToString(); if (dataHangHoa.KiemTraBarcode(BarCode) == true) { data.ThemBarCode(IDHangHoa, BarCode); } else { throw new Exception("Lỗi:Barcode đã tồn tại"); } e.Cancel = true; gridBarCode.CancelEdit(); gridBarCode.DataSource = data.GetListBarCode(IDHangHoa); gridBarCode.DataBind(); }