private void btnAddItem_Click(object sender, EventArgs e) { GridEXRow newItem = this.gridEX1.AddItem(); //To set values in a GridEXRow, you must do it between BeginEdit, EndEdit calls newItem.BeginEdit(); newItem.Cells["Id"].Value = 0; newItem.Cells["Name"].Value = "New Item"; newItem.EndEdit(); }
private void btnAddItem_Click(object sender, EventArgs e) { //Add a new row at the end of the list specifying its cell values. GridEXRow newRow = this.gridEX1.AddItem(); //To edit values in cells of a row, call BeginEdit/EndEdit methods newRow.BeginEdit(); newRow.Cells["Name"].Value = "AddItem"; newRow.Cells["Date"].Value = DateTime.Now; newRow.EndEdit(); //Move to the new item this.gridEX1.MoveTo(newRow); }
private void btnInsertItem_Click(object sender, EventArgs e) { //Insert the item at the begining of the list. GridEXRow newRow = this.gridEX1.AddItem(this.gridEX1.Row); //To edit values in cells of a row, call BeginEdit/EndEdit methods newRow.BeginEdit(); newRow.Cells["Name"].Value = "InsertItem"; newRow.Cells["Date"].Value = DateTime.Now; newRow.EndEdit(); //Move to the new item gridEX1.MoveTo(newRow); }
private void ToggleBreakpointActive(NuGenBreakpointInformation breakpoint, bool isActive) { GridEXRow row = FindRow(breakpoint); row.BeginEdit(); breakpoint.State = (isActive ? BreakpointState.Active : BreakpointState.Inactive); if (row != null) { row.Cells[0].Value = isActive; } row.EndEdit(); NuGenProject.Instance.IsSaved = false; }
public void AddBreakpoint(NuGenBreakpointInformation breakpoint) { breakpointsGrid.AddItem(); GridEXRow row = breakpointsGrid.GetRow(breakpointsGrid.RowCount - 1); row.BeginEdit(); test = row; row.Cells[0].Value = (breakpoint.State == BreakpointState.Active); row.Cells[1].Value = breakpoint.DisplayName; row.Cells[2].Value = breakpoint.OffsetValue; NuGenHelperFunctions.TaggedObjects.Add((String)row.Cells[1].Value + (String)row.Cells[2].Value, breakpoint); row.EndEdit(); }
private void AddDetailNext(GridEXRow gridExRow) { try { string manhacungcap = ""; string NgayHethan = ""; string solo = ""; int id_thuoc = -1; decimal GiaNhap = 0m; decimal Giaban = 0m; decimal Dongia = 0m; Int32 soluongchuyen = 0; decimal vat = 0m; int isHetHan = 0; long IdThuockho = 0; int soluongthat = 0; int tongsoluongchuyen = 0; DateTime NgayNhap = DateTime.Now; decimal GiaBhyt = 0m; tongsoluongchuyen = 0; soluongthat = Utility.Int32Dbnull(gridExRow.Cells["SO_LUONG_THAT"].Value); soluongchuyen = Utility.Int32Dbnull(gridExRow.Cells["SO_LUONG_CHUYEN"].Value, 0); if (soluongchuyen > 0) { NgayHethan = Utility.sDbnull(gridExRow.Cells["NGAY_HET_HAN"].Value); solo = Utility.sDbnull(gridExRow.Cells[TPhieuNhapxuatthuocChitiet.Columns.SoLo].Value); id_thuoc = Utility.Int32Dbnull(gridExRow.Cells[TThuockho.Columns.IdThuoc].Value, -1); Dongia = Utility.DecimaltoDbnull(gridExRow.Cells[TPhieuNhapxuatthuocChitiet.Columns.DonGia].Value, 0); GiaNhap = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.GiaNhap].Value, 0); Giaban = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.GiaBan].Value, 0); GiaBhyt = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.GiaBhyt].Value, 0); NgayNhap = Convert.ToDateTime(gridExRow.Cells[TThuockho.Columns.NgayNhap].Value).Date; vat = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.Vat].Value, 0); isHetHan = Utility.Int32Dbnull(gridExRow.Cells["IsHetHan"].Value, 0); manhacungcap = Utility.sDbnull(gridExRow.Cells[TThuockho.Columns.MaNhacungcap].Value, 0); IdThuockho = Utility.Int32Dbnull(gridExRow.Cells[TThuockho.Columns.IdThuockho].Value, -1); DataRow[] arrDr = m_dtDataPhieuChiTiet.Select(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho + "=" + IdThuockho.ToString()); if (arrDr.Length <= 0) { DataRow drv = m_dtDataPhieuChiTiet.NewRow(); drv[TPhieuNhapxuatthuocChitiet.Columns.MotaThem] = String.Empty; drv[TPhieuNhapxuatthuocChitiet.Columns.IdThuoc] = id_thuoc; drv["ten_donvitinh"] = Utility.sDbnull(gridExRow.Cells["ten_donvitinh"].Value); drv["IsHetHan"] = isHetHan; DmucThuoc objLDrug = DmucThuoc.FetchByID(id_thuoc); if (objLDrug != null) { drv[DmucThuoc.Columns.TenThuoc] = Utility.sDbnull(objLDrug.TenThuoc); drv[DmucThuoc.Columns.HamLuong] = Utility.sDbnull(objLDrug.HamLuong); drv[DmucThuoc.Columns.HoatChat] = Utility.sDbnull(objLDrug.HoatChat); drv[DmucThuoc.Columns.NuocSanxuat] = Utility.sDbnull(objLDrug.NuocSanxuat); drv[DmucThuoc.Columns.HangSanxuat] = Utility.sDbnull(objLDrug.HangSanxuat); } drv[TPhieuNhapxuatthuocChitiet.Columns.NgayNhap] = NgayNhap; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaBhyt] = GiaBhyt; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaPhuthuDungtuyen] = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.PhuthuDungtuyen].Value, 0); drv[TPhieuNhapxuatthuocChitiet.Columns.GiaPhuthuTraituyen] = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.PhuthuTraituyen].Value, 0); drv[TPhieuNhapxuatthuocChitiet.Columns.Vat] = vat; drv[TPhieuNhapxuatthuocChitiet.Columns.MotaThem] = txtLydohuy.Text; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaNhap] = GiaNhap; drv[TPhieuNhapxuatthuocChitiet.Columns.MaNhacungcap] = manhacungcap; drv[TPhieuNhapxuatthuocChitiet.Columns.SoLo] = solo; drv[TPhieuNhapxuatthuocChitiet.Columns.IdThuockho] = IdThuockho; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaBan] = Giaban; drv[TPhieuNhapxuatthuocChitiet.Columns.IdChuyen] = IdThuockho; drv[TPhieuNhapxuatthuocChitiet.Columns.SoLuong] = soluongchuyen; drv[TPhieuNhapxuatthuocChitiet.Columns.DonGia] = Dongia; drv[TPhieuNhapxuatthuocChitiet.Columns.ThanhTien] = Dongia * soluongchuyen; drv[TPhieuNhapxuatthuocChitiet.Columns.ChietKhau] = 0; drv[TPhieuNhapxuatthuocChitiet.Columns.NgayHethan] = NgayHethan; drv[TPhieuNhapxuatthuocChitiet.Columns.IdPhieu] = -1; tongsoluongchuyen = soluongchuyen; m_dtDataPhieuChiTiet.Rows.Add(drv); } else { arrDr[0]["SO_LUONG"] = Utility.Int32Dbnull(arrDr[0]["SO_LUONG"]) + soluongchuyen; arrDr[0][TPhieuNhapxuatthuocChitiet.Columns.ThanhTien] = Dongia * Utility.Int32Dbnull(arrDr[0]["SO_LUONG"], 0); tongsoluongchuyen = Utility.Int32Dbnull(arrDr[0]["SO_LUONG"]); m_dtDataPhieuChiTiet.AcceptChanges(); } //Update lại dữ liệu từ kho xuất gridExRow.BeginEdit(); gridExRow.Cells["SO_LUONG"].Value = soluongthat - tongsoluongchuyen; gridExRow.Cells["SO_LUONG_CHUYEN"].Value = 0; gridExRow.IsChecked = false; gridExRow.EndEdit(); } grdKhoXuat.UpdateData(); m_dtDataThuocKho.AcceptChanges(); } catch (Exception ex) { Utility.ShowMsg("Lỗi khi chuyển thuốc:\n" + ex.Message); } }
private void FillMessage(GridEXRow selectedRow) { try { // Have a delay before we actually retrieve the message System.Threading.Thread.Sleep(200); if (selectedRow.RowIndex == -1) { return; } // Check that the event id is still the same as the one selected uint thisIndex = (uint)selectedRow.Cells["Index"].Value; if (thisIndex == lastIndex) { string message = String.Empty; if ( (selectedRow.Cells["Message"].Value == DBNull.Value) || (((string)selectedRow.Cells["Message"].Value) == String.Empty) ) { // This message has not been cached yet. Retrieve it. try { /* * int index = System.Convert.ToInt32(thisIndex - smallestRecordNumber); * message = log.Entries[index].Message; */ if (!localMachine) { // Set the event detail text to Loading... if (this.InvokeRequired) { this.Invoke(new StringDelegate(SetEventDetailText), new object[] { "Loading..." }); } else { SetEventDetailText("Loading..."); } } message = GetEventLogItemMessage(thisIndex); } catch { message = "Message not found."; } } else { message = (string)selectedRow.Cells[6].Value; } if (this.InvokeRequired) { selectedRow.BeginEdit(); this.Invoke(new RowStringDelegate(UpdateEventDetailText), new object[] { selectedRow, message }); selectedRow.EndEdit(); } else { UpdateEventDetailText(selectedRow, message); } } } catch (ObjectDisposedException) { } }
private void FillMessage(GridEXRow selectedRow) { try { // Have a delay before we actually retrieve the message System.Threading.Thread.Sleep(200); if (selectedRow.RowIndex == -1) { return; } // Check that the event id is still the same as the one selected uint thisIndex = (uint)selectedRow.Cells["Index"].Value; if (thisIndex == lastIndex) { string message = String.Empty; if ( (selectedRow.Cells["Message"].Value == DBNull.Value) || (((string)selectedRow.Cells["Message"].Value) == String.Empty) ) { // This message has not been cached yet. Retrieve it. try { /* int index = System.Convert.ToInt32(thisIndex - smallestRecordNumber); message = log.Entries[index].Message; */ if (!localMachine) { // Set the event detail text to Loading... if (this.InvokeRequired) { this.Invoke(new StringDelegate(SetEventDetailText), new object[] { "Loading..." }); } else { SetEventDetailText("Loading..."); } } message = GetEventLogItemMessage(thisIndex); } catch { message = "Message not found."; } } else { message = (string)selectedRow.Cells[6].Value; } if (this.InvokeRequired) { selectedRow.BeginEdit(); this.Invoke(new RowStringDelegate(UpdateEventDetailText), new object[] { selectedRow, message }); selectedRow.EndEdit(); } else { UpdateEventDetailText(selectedRow, message); } } } catch (ObjectDisposedException) { } }
private void AddDetailNext(GridEXRow gridExRow) { try { string manhacungcap = ""; string NgayHethan = ""; string solo = ""; int id_thuoc = -1; decimal GiaNhap = 0m; decimal Giaban = 0m; decimal Dongia = 0m; Int32 soluongchuyen = 0; decimal vat = 0m; int isHetHan = 0; long IdThuockho = 0; int soluongthat = 0; int tongsoluongchuyen = 0; DateTime NgayNhap = DateTime.Now; decimal GiaBhyt = 0m; tongsoluongchuyen = 0; soluongthat = Utility.Int32Dbnull(gridExRow.Cells["SO_LUONG_THAT"].Value); soluongchuyen = Utility.Int32Dbnull(gridExRow.Cells["SO_LUONG_CHUYEN"].Value, 0); if (soluongchuyen > 0) { NgayHethan = Utility.sDbnull(gridExRow.Cells["NGAY_HET_HAN"].Value); solo = Utility.sDbnull(gridExRow.Cells[TPhieuNhapxuatthuocChitiet.Columns.SoLo].Value); id_thuoc = Utility.Int32Dbnull(gridExRow.Cells[TThuockho.Columns.IdThuoc].Value, -1); Dongia = Utility.DecimaltoDbnull(gridExRow.Cells[TPhieuNhapxuatthuocChitiet.Columns.DonGia].Value, 0); GiaNhap = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.GiaNhap].Value, 0); Giaban = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.GiaBan].Value, 0); GiaBhyt = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.GiaBhyt].Value, 0); NgayNhap = Convert.ToDateTime(gridExRow.Cells[TThuockho.Columns.NgayNhap].Value).Date; vat = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.Vat].Value, 0); isHetHan = Utility.Int32Dbnull(gridExRow.Cells["IsHetHan"].Value, 0); manhacungcap = Utility.sDbnull(gridExRow.Cells[TThuockho.Columns.MaNhacungcap].Value, 0); IdThuockho = Utility.Int32Dbnull(gridExRow.Cells[TThuockho.Columns.IdThuockho].Value, -1); DataRow[] arrDr = m_dtDataPhieuChiTiet.Select(TPhieuNhapxuatthuocChitiet.Columns.IdThuockho + "=" + IdThuockho.ToString()); if (arrDr.Length <= 0) { DataRow drv = m_dtDataPhieuChiTiet.NewRow(); drv[TPhieuNhapxuatthuocChitiet.Columns.MotaThem] = String.Empty; drv[TPhieuNhapxuatthuocChitiet.Columns.IdThuoc] = id_thuoc; drv["ten_donvitinh"] = Utility.sDbnull(gridExRow.Cells["ten_donvitinh"].Value); drv["IsHetHan"] = isHetHan; DmucThuoc objLDrug = DmucThuoc.FetchByID(id_thuoc); if (objLDrug != null) { drv[DmucThuoc.Columns.TenThuoc] = Utility.sDbnull(objLDrug.TenThuoc); drv[DmucThuoc.Columns.HamLuong] = Utility.sDbnull(objLDrug.HamLuong); drv[DmucThuoc.Columns.HoatChat] = Utility.sDbnull(objLDrug.HoatChat); drv[DmucThuoc.Columns.NuocSanxuat] = Utility.sDbnull(objLDrug.NuocSanxuat); drv[DmucThuoc.Columns.HangSanxuat] = Utility.sDbnull(objLDrug.HangSanxuat); } drv[TPhieuNhapxuatthuocChitiet.Columns.NgayNhap] = NgayNhap; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaBhyt] = GiaBhyt; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaPhuthuDungtuyen] = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.PhuthuDungtuyen].Value, 0); drv[TPhieuNhapxuatthuocChitiet.Columns.GiaPhuthuTraituyen] = Utility.DecimaltoDbnull(gridExRow.Cells[TThuockho.Columns.PhuthuTraituyen].Value, 0); drv[TPhieuNhapxuatthuocChitiet.Columns.Vat] = vat; drv[TPhieuNhapxuatthuocChitiet.Columns.MotaThem] = txtLydohuy.Text; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaNhap] = GiaNhap; drv[TPhieuNhapxuatthuocChitiet.Columns.MaNhacungcap] = manhacungcap; drv[TPhieuNhapxuatthuocChitiet.Columns.SoLo] = solo; drv[TPhieuNhapxuatthuocChitiet.Columns.SoDky] = Utility.sDbnull(gridExRow.Cells[TPhieuNhapxuatthuocChitiet.Columns.SoDky].Value); drv[TPhieuNhapxuatthuocChitiet.Columns.SoQdinhthau] = Utility.sDbnull(gridExRow.Cells[TPhieuNhapxuatthuocChitiet.Columns.SoQdinhthau].Value); drv[TPhieuNhapxuatthuocChitiet.Columns.IdThuockho] = IdThuockho; drv[TPhieuNhapxuatthuocChitiet.Columns.GiaBan] = Giaban; drv[TPhieuNhapxuatthuocChitiet.Columns.IdChuyen] = IdThuockho; drv[TPhieuNhapxuatthuocChitiet.Columns.SoLuong] = soluongchuyen; drv[TPhieuNhapxuatthuocChitiet.Columns.DonGia] = Dongia; drv[TPhieuNhapxuatthuocChitiet.Columns.ThanhTien] = Dongia * soluongchuyen; drv[TPhieuNhapxuatthuocChitiet.Columns.ChietKhau] = 0; drv[TPhieuNhapxuatthuocChitiet.Columns.NgayHethan] = NgayHethan; drv[TPhieuNhapxuatthuocChitiet.Columns.IdPhieu] = -1; tongsoluongchuyen = soluongchuyen; m_dtDataPhieuChiTiet.Rows.Add(drv); } else { arrDr[0]["SO_LUONG"] = Utility.Int32Dbnull(arrDr[0]["SO_LUONG"]) + soluongchuyen; arrDr[0][TPhieuNhapxuatthuocChitiet.Columns.ThanhTien] = Dongia * Utility.Int32Dbnull(arrDr[0]["SO_LUONG"], 0); tongsoluongchuyen = Utility.Int32Dbnull(arrDr[0]["SO_LUONG"]); m_dtDataPhieuChiTiet.AcceptChanges(); } //Update lại dữ liệu từ kho xuất gridExRow.BeginEdit(); gridExRow.Cells["SO_LUONG"].Value = soluongthat - tongsoluongchuyen; gridExRow.Cells["SO_LUONG_CHUYEN"].Value = 0; gridExRow.IsChecked = false; gridExRow.EndEdit(); } grdKhoXuat.UpdateData(); m_dtDataThuocKho.AcceptChanges(); } catch (Exception ex) { Utility.ShowMsg("Lỗi khi chuyển thuốc:\n" + ex.Message); } }
void Huydutru() { try { int count_checked = grdList.GetCheckedRows().Count(); Int16 IDKHO = Utility.Int16Dbnull(cboKhoxuat.SelectedValue); if (count_checked <= 0) { if (Utility.isValidGrid(grdList)) { GridEXRow _currentRow = grdList.CurrentRow; if (Utility.AcceptQuestion(string.Format("Bạn có chắc chắn muốn hủy dự trù thuốc/vật tư {0} trong kho {1} hay không?", Utility.sDbnull(_currentRow.Cells[DmucThuoc.Columns.TenThuoc].Value, "không xác định"), cboKhoxuat.Text), "Cảnh báo", true)) { int IDTHUOC = 0; IDTHUOC = Utility.Int32Dbnull(_currentRow.Cells[DmucThuoc.Columns.IdThuoc].Value, 0); new Delete().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC) .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO) .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute(); _currentRow.BeginEdit(); _currentRow.Cells["COQUANHE"].Value = 0; _currentRow.Cells["SO_LUONG"].Value = 0; _currentRow.Cells["SLUONG_CANCHUYEN"].Value = 0; _currentRow.EndEdit(); grdList.UpdateData(); m_Thuoc.AcceptChanges(); Utility.ShowMsg(string.Format("Đã hủy dự trù thuốc/vật tư {0} trong kho {1} thành công!", Utility.sDbnull(_currentRow.Cells[DmucThuoc.Columns.TenThuoc].Value, "không xác định"), cboKhoxuat.Text)); } } else { Utility.ShowMsg("Bạn cần chọn ít nhất một thuốc có dự trù để có thể thực hiện thao tác hủy dự trù thuốc!"); } } else//Hủy toàn bộ { if (Utility.AcceptQuestion(string.Format("Bạn có chắc chắn muốn hủy toàn bộ dự trù thuốc/vật tư trong kho {0} hay không?", cboKhoxuat.Text), "Cảnh báo", true)) { int IDTHUOC = 0; foreach (GridEXRow _row in grdList.GetCheckedRows()) { IDTHUOC = Utility.Int32Dbnull(_row.Cells[DmucThuoc.Columns.IdThuoc].Value, 0); new Delete().From(TDutruThuoc.Schema).Where(TDutruThuoc.Columns.IdThuoc).IsEqualTo(IDTHUOC) .And(TDutruThuoc.Columns.IdKho).IsEqualTo(IDKHO) .And(TDutruThuoc.Columns.KieuThuocVt).IsEqualTo(KIEU_THUOC_VT).Execute(); _row.BeginEdit(); _row.Cells["COQUANHE"].Value = 0; _row.Cells["SO_LUONG"].Value = 0; _row.Cells["SLUONG_CANCHUYEN"].Value = 0; _row.EndEdit(); } grdList.UpdateData(); m_Thuoc.AcceptChanges(); Utility.ShowMsg(string.Format("Đã hủy toàn bộ dự trù thuốc/vật tư trong kho {0} thành công!", cboKhoxuat.Text)); } } } catch (Exception ex) { Utility.ShowMsg("Lỗi:", ex.Message); } }