private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;

                //validation
                GridColumn ma_tsCol = view.Columns["MA_TS"];
                //GridColumn ma_ctCol = view.Columns["MA_CT"];
                string ma_ts = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, ma_tsCol), "");
                //string ma_ct = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, ma_ctCol), "");
                if (ma_ts.Trim().Length == 0)
                {
                    e.Valid = false;
                    if (ma_ts.Trim().Length == 0)
                        view.SetColumnError(ma_tsCol, "Mã tài sản không được rổng");
                    //if (ma_ct.Trim().Length == 0)
                    //    view.SetColumnError(ma_ctCol, "Mã chương trình không được rổng");

                    return;
                }

                _KTDMTSCDRepo = new KTDMTSCDRepo();
                //Kiểm tra đây là dòng dữ liệu mới hay cũ, nếu là mới thì mình insert
                if (view.IsNewItemRow(e.RowHandle))
                {
                    //e.RowHandle trả về giá trị int là thứ tự của dòng hiện tại
                    KT_DMTSCD obj = new KT_DMTSCD();

                    obj.MA_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TS"), "");
                    obj.TEN_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TS"), "");
                    obj.SO_LUONG = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "SO_LUONG"), 0);
                    obj.DVT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DVT"), "");
                    obj.CO_KH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "CO_KH"), "");
                    obj.TK_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_TS"), "");
                    obj.TK_CP = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_CP"), "");
                    obj.TK_HM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_HM"), "");
                    obj.DT_SUDUNG = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DT_SUDUNG"), "");
                    obj.NGUYEN_GIA = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "NGUYEN_GIA"), 0);
                    DateTime? temp = null;
                    if (Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_MUA"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_MUA"), DateTime.MinValue);
                    obj.NGAY_MUA = temp;
                    temp = null;
                    if (Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_BAN"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_BAN"), DateTime.MinValue);
                    obj.NGAY_BAN = temp;
                    temp = null;
                    if (Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_TRICH_KH"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_TRICH_KH"), DateTime.MinValue);
                    obj.NGAY_TRICH_KH = temp;
                    obj.THOI_GIAN_KH = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "THOI_GIAN_KH"), 0);
                    obj.KH_1_THANG = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "KH_1_THANG"), 0);
                    obj.LK_KH_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "LK_KH_DAUNAM"), 0);
                    obj.GT_CL_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "GT_CL_DAUNAM"), 0);
                    obj.MA_DTPN_NO = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_DTPN_NO"), "");
                    obj.MA_DTPN_CO = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_DTPN_CO"), "");
                    obj.MA_CT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_CT"), "");
                    obj.MA_YTCP_NO = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_YTCP_NO"), "");
                    obj.MA_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM"), "");
                    obj.TEN_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM"), "");
                    obj.KY_HIEU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "KY_HIEU"), "");
                    obj.NAM_SX = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "NAM_SX"), 0);
                    obj.MODEL = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MODEL"), "");
                    obj.QUY_CACH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "QUY_CACH"), "");
                    obj.NUOC_SX = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "NUOC_SX"), "");
                    obj.NGUON_VON = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "NGUON_VON"), "");
                    obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");
                    obj.TRANG_THAI = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0);

                    _KTDMTSCDRepo.Create(obj);

                }
                //Cũ thì update
                else
                {
                    int id = Utils.CIntDef(view.GetRowCellValue(gridView1.FocusedRowHandle, "ID"), 0);
                    KT_DMTSCD obj = _KTDMTSCDRepo.GetById(id);
                    if (obj != null)
                    {

                        obj.MA_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TS"), "");
                        obj.TEN_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TS"), "");
                        obj.SO_LUONG = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "SO_LUONG"), 0);
                        obj.DVT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DVT"), "");
                        obj.CO_KH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "CO_KH"), "");
                        obj.TK_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_TS"), "");
                        obj.TK_CP = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_CP"), "");
                        obj.TK_HM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_HM"), "");
                        obj.DT_SUDUNG = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DT_SUDUNG"), "");
                        obj.NGUYEN_GIA = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "NGUYEN_GIA"), 0);
                        DateTime? temp = null;
                        if (Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_MUA"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_MUA"), DateTime.MinValue);
                        obj.NGAY_MUA = temp;
                        temp = null;
                        if (Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_BAN"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_BAN"), DateTime.MinValue);
                        obj.NGAY_BAN = temp;
                        temp = null;
                        if (Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_TRICH_KH"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(view.GetRowCellValue(e.RowHandle, "NGAY_TRICH_KH"), DateTime.MinValue);
                        obj.NGAY_TRICH_KH = temp;
                        obj.THOI_GIAN_KH = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "THOI_GIAN_KH"), 0);
                        obj.KH_1_THANG = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "KH_1_THANG"), 0);
                        obj.LK_KH_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "LK_KH_DAUNAM"), 0);
                        obj.GT_CL_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "GT_CL_DAUNAM"), 0);
                        obj.MA_DTPN_NO = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_DTPN_NO"), "");
                        obj.MA_DTPN_CO = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_DTPN_CO"), "");
                        obj.MA_CT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_CT"), "");
                        obj.MA_YTCP_NO = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_YTCP_NO"), "");
                        obj.MA_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM"), "");
                        obj.TEN_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM"), "");
                        obj.KY_HIEU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "KY_HIEU"), "");
                        obj.NAM_SX = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "NAM_SX"), 0);
                        obj.MODEL = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MODEL"), "");
                        obj.QUY_CACH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "QUY_CACH"), "");
                        obj.NUOC_SX = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "NUOC_SX"), "");
                        obj.NGUON_VON = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "NGUON_VON"), "");
                        obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");
                        obj.TRANG_THAI = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0);

                        _KTDMTSCDRepo.Update(obj);
                    }

                }
                Load_Data();
            }
            catch (Exception ex)
            {
                e.Valid = false;
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void btnCapnhat_Click(object sender, EventArgs e)
        {
            if (cboMaTS.Text.Trim().Length == 0)
            {
                MessageBox.Show("Mã TS không được rỗng!","Thông báo");
                return;
            }
            _KTDMTSCDRepo = new KTDMTSCDRepo();
            var item = _KTDMTSCDRepo.GetById(Utils.CIntDef(cboMaTS.SelectedValue, 0));
            if (item != null)
            {
                #region
                item.TEN_TS = txtTenTS.Text;
                item.SO_LUONG = Utils.CDblDef(txtSoluong.Text, 0);
                item.DVT = txtDVT.Text;
                //txtDongiaVND.Text = item.d
                //txtThanhtienVND.Text = item.
                item.TY_GIA = Utils.CDblDef(txtTygia.Text, 0);
                //txtDongiaUSD.Text = item
                //txtThanhtienUSD.Text = item
                cboCokhauhao.Text = item.CO_KH;
                DateTime? temp = null;
                if (Utils.CDateDef(dtpNgaymua.Value, DateTime.MinValue) != DateTime.MinValue)
                    temp = Utils.CDateDef(dtpNgaymua.Value, DateTime.MinValue);
                item.NGAY_MUA = temp;
                temp = null;
                if (Utils.CDateDef(dtpNgaytrichKH.Value, DateTime.MinValue) != DateTime.MinValue)
                    temp = Utils.CDateDef(dtpNgaytrichKH.Value, DateTime.MinValue);
                item.NGAY_TRICH_KH = temp;
                item.TK_TS = cboTKtaisan.Text;
                item.TK_CP = cboTKchiphi.Text;
                item.TK_HM = cboTKhaomon.Text;
                item.DT_SUDUNG = txtDoituongsudung.Text;
                item.NGUYEN_GIA = Utils.CDblDef(txtNguyengiaVND.Text, 0);
                //txtNguyengiaUSD.Text = Utils.CStrDef(item.NGUYEN_GIA, "");
                item.THOI_GIAN_KH = Utils.CDblDef(txtThoigianKH.Text, 0);
                item.KH_1_THANG = Utils.CDblDef(txtKH1thangVND.Text, 0);
                //txtKH1thangUSD.Text = Utils.CStrDef(item.KH_1_THANG, "");
                item.LK_KH_DAUNAM = Utils.CDblDef(txtLuykeKHDaunamVND.Text, 0);
                //txtLuykeKHDaunamUSD.Text = Utils.CStrDef(item.LK_KH_DAUNAM, "");
                item.GT_CL_DAUNAM = Utils.CDblDef(txtGiatriCLDaunamVND.Text, 0);
                item.MA_DTPN_NO = cboDTPNNo.Text;
                item.MA_DTPN_CO = cboDTPNCo.Text;
                item.MA_YTCP_NO = cboYTCPNo.Text;
                item.MA_CT = cboCongtrinh.Text;
                //thông tin khác
                item.KY_HIEU = txtkyhieu.Text;
                item.MODEL = txtModel.Text;
                item.NUOC_SX = txtNuocsanxuat.Text;
                item.NAM_SX = Utils.CDblDef(txtNamsanxuat.Text, 0);
                item.QUY_CACH = txtQuycach.Text;
                item.MA_NHOM = cboManhom.Text;
                item.TEN_NHOM = txtTenNhom.Text;

                _KTDMTSCDRepo.Update(item);
                #endregion
            }
            else
            {
                #region
                item = new KT_DMTSCD();
                item.MA_TS = cboMaTS.Text;
                item.TEN_TS = txtTenTS.Text;
                item.SO_LUONG = Utils.CDblDef(txtSoluong.Text, 0);
                item.DVT = txtDVT.Text;
                //txtDongiaVND.Text = item.d
                //txtThanhtienVND.Text = item.
                item.TY_GIA = Utils.CDblDef(txtTygia.Text, 0);
                //txtDongiaUSD.Text = item
                //txtThanhtienUSD.Text = item
                cboCokhauhao.Text = item.CO_KH;
                DateTime? temp = null;
                if (Utils.CDateDef(dtpNgaymua.Value, DateTime.MinValue) != DateTime.MinValue)
                    temp = Utils.CDateDef(dtpNgaymua.Value, DateTime.MinValue);
                item.NGAY_MUA = temp;
                temp = null;
                if (Utils.CDateDef(dtpNgaytrichKH.Value, DateTime.MinValue) != DateTime.MinValue)
                    temp = Utils.CDateDef(dtpNgaytrichKH.Value, DateTime.MinValue);
                item.NGAY_TRICH_KH = temp;
                item.TK_TS = cboTKtaisan.Text;
                item.TK_CP = cboTKchiphi.Text;
                item.TK_HM = cboTKhaomon.Text;
                item.DT_SUDUNG = txtDoituongsudung.Text;
                item.NGUYEN_GIA = Utils.CDblDef(txtNguyengiaVND.Text, 0);
                //txtNguyengiaUSD.Text = Utils.CStrDef(item.NGUYEN_GIA, "");
                item.THOI_GIAN_KH = Utils.CDblDef(txtThoigianKH.Text, 0);
                item.KH_1_THANG = Utils.CDblDef(txtKH1thangVND.Text, 0);
                //txtKH1thangUSD.Text = Utils.CStrDef(item.KH_1_THANG, "");
                item.LK_KH_DAUNAM = Utils.CDblDef(txtLuykeKHDaunamVND.Text, 0);
                //txtLuykeKHDaunamUSD.Text = Utils.CStrDef(item.LK_KH_DAUNAM, "");
                item.GT_CL_DAUNAM = Utils.CDblDef(txtGiatriCLDaunamVND.Text, 0);
                item.MA_DTPN_NO = cboDTPNNo.Text;
                item.MA_DTPN_CO = cboDTPNCo.Text;
                item.MA_YTCP_NO = cboYTCPNo.Text;
                item.MA_CT = cboCongtrinh.Text;
                //thông tin khác
                item.KY_HIEU = txtkyhieu.Text;
                item.MODEL = txtModel.Text;
                item.NUOC_SX = txtNuocsanxuat.Text;
                item.NAM_SX = Utils.CDblDef(txtNamsanxuat.Text, 0);
                item.QUY_CACH = txtQuycach.Text;
                item.MA_NHOM = cboManhom.Text;
                item.TEN_NHOM = txtTenNhom.Text;
                
                _KTDMTSCDRepo.Create(item);

                LoadDMTSCD();
                cboMaTS.SelectedValue = item.ID;
                cboMaTS_SelectedIndexChanged(null, null);
                LoadMaTSCuoi();
                #endregion
            }
            MessageBox.Show("Cập nhật thành công!", "Thông báo");
        }
        private void Save_Duplicate()
        {
            try
            {                
                if (MessageBox.Show("Bạn có muốn copy dòng này thành dòng mới?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    _KTDMTSCDRepo = new KTDMTSCDRepo();
                    KT_DMTSCD obj = new KT_DMTSCD();

                    obj.MA_TS = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_TS"), "");
                    obj.TEN_TS = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TEN_TS"), "");
                    obj.SO_LUONG = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "SO_LUONG"), 0);
                    obj.DVT = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DVT"), "");
                    obj.CO_KH = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "CO_KH"), "");
                    obj.TK_TS = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TK_TS"), "");
                    obj.TK_CP = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TK_CP"), "");
                    obj.TK_HM = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TK_HM"), "");
                    obj.DT_SUDUNG = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DT_SUDUNG"), "");
                    obj.NGUYEN_GIA = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGUYEN_GIA"), 0);
                    DateTime? temp = null;
                    if (Utils.CDateDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGAY_MUA"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGAY_MUA"), DateTime.MinValue);
                    obj.NGAY_MUA = temp;
                    temp = null;
                    if (Utils.CDateDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGAY_BAN"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGAY_BAN"), DateTime.MinValue);
                    obj.NGAY_BAN = temp;
                    temp = null;
                    if (Utils.CDateDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGAY_TRICH_KH"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGAY_TRICH_KH"), DateTime.MinValue);
                    obj.NGAY_TRICH_KH = temp;
                    obj.THOI_GIAN_KH = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "THOI_GIAN_KH"), 0);
                    obj.KH_1_THANG = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "KH_1_THANG"), 0);
                    obj.LK_KH_DAUNAM = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "LK_KH_DAUNAM"), 0);
                    obj.GT_CL_DAUNAM = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GT_CL_DAUNAM"), 0);
                    obj.MA_DTPN_NO = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_DTPN_NO"), "");
                    obj.MA_DTPN_CO = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_DTPN_CO"), "");
                    obj.MA_CT = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_CT"), "");
                    obj.MA_YTCP_NO = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_YTCP_NO"), "");
                    obj.MA_NHOM = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_NHOM"), "");
                    obj.TEN_NHOM = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TEN_NHOM"), "");
                    obj.KY_HIEU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "KY_HIEU"), "");
                    obj.NAM_SX = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NAM_SX"), 0);
                    obj.MODEL = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MODEL"), "");
                    obj.QUY_CACH = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "QUY_CACH"), "");
                    obj.NUOC_SX = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NUOC_SX"), "");
                    obj.NGUON_VON = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NGUON_VON"), "");
                    obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "");
                    obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TRANG_THAI"), 0);

                    _KTDMTSCDRepo.Create(obj);
                    MessageBox.Show("Đã copy dòng này vào cuối bảng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }