コード例 #1
0
        /// <summary>
        /// Selects the cell action.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="column">The column.</param>
        /// <param name="isMmouse">if set to <c>true</c> [is mmouse].</param>
        private void SelectCellAction(int index, int column, bool isMmouse)
        {
            dataGridView.Rows[index].Selected = true;
            if (!isMmouse)
            {
                dataGridView[0, index].Value = !Convert.ToBoolean(dataGridView.Rows[index].Cells[0].Value);
            }
            else
            {
                if (column == 0)
                {
                    dataGridView[0, index].Value = !Convert.ToBoolean(dataGridView.Rows[index].Cells[0].Value);
                }
            }
            var selectedRows = (from row in dataGridView.Rows.Cast <DataGridViewRow>() where Convert.ToBoolean(row.Cells["CB"].Value) select row).ToList();

            currentModel       = (ChiTietHdnModel)dataGridView.CurrentSelected(currentHoaDonNhapModel.ChiTietHDN);
            bntLuaChon.Enabled = (dataGridView.CurrentRow != null);
            if (isEditMode)
            {
                bntLuu.Enabled    = true;
                bntTaoMoi.Enabled = true;
                bntXoa.Enabled    = selectedRows.Count > 0;
            }
        }
コード例 #2
0
 /// <summary>
 /// To the entity.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="destination">The destination.</param>
 /// <returns>ChiTietHDN.</returns>
 public static ChiTietHDN ToEntity(this ChiTietHdnModel model, ChiTietHDN destination)
 {
     return(model.MapTo(destination));
 }
コード例 #3
0
 /// <summary>
 /// To the entity.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns>ChiTietHDN.</returns>
 public static ChiTietHDN ToEntity(this ChiTietHdnModel model)
 {
     return(model.MapTo <ChiTietHdnModel, ChiTietHDN>());
 }
コード例 #4
0
        /// <summary>
        /// Posts the view.
        /// </summary>
        /// <param name="value">The value.</param>
        public void PostView(HoaDonNhapModel value)
        {
            currentHoaDonNhapModel = value;
            currentListDataTable   = null;

            dataGridView.Columns.Clear();
            var g = new DataGridViewCheckBoxColumn {
                Name = "CB", HeaderText = "", Width = 24, AutoSizeMode = DataGridViewAutoSizeColumnMode.None, ReadOnly = true
            };

            dataGridView.Columns.Add(g);


            dataSourceDataTable = value.ChiTietHDNModel.ToDataTable();
            dataSourceDataTable.AcceptChanges();
            dataBindingSource.DataSource = dataSourceDataTable;
            dataGridView.DataSource      = dataBindingSource;

            //dataGridView.DataSource = new BindingSource { DataSource = value.ChiTietHDNModel };

            dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.ID)].Display(false);
            dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.SanPhamID)].Display(false);
            dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.SanPham)].Display(false);
            dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.HoaDonNhapID)].Display(false);
            dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.HoaDonNhap)].Display(false);
            dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.SoHDN)].Display(false);
            dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.IDModel)].Display(false);

            if (dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.MaGiayDep)] != null)
            {
                dataGridView.Columns[Rf.Name <ChiTietHdnModel>(c => c.MaGiayDep)].DisplayIndex = 1;
            }

            if (value != null)
            {
                if (value.SoHDN != null)
                {
                    txtMaHoaDon.Text = value.SoHDN;
                }
                if (value.MaNV != null)
                {
                    txtMaNhanVien.Text = value.MaNV;
                }
                if (value.MaNCC != null)
                {
                    txtMaNCC.Text = value.MaNCC;
                }
                if (value.NgayNhap != null)
                {
                    txtNgayNhap.Text = value.NgayNhap.ToDateString();
                }
                if (value.TongTien != null)
                {
                    txtTongTien.Text = value.TongTien.ToString();
                }
            }
            txtMaNhanVien.Text = AppMediator.MANHANVIEN;
            dataGridView.ClearSelection();
            dataGridView.CurrentCell = null;

            if (isEditMode)
            {
                bntLuu.Enabled     = false;
                bntTaoMoi.Enabled  = true;
                bntXoa.Enabled     = false;
                bntLuaChon.Enabled = false;
                txtMaHoaDon.Focus();
            }
            else
            {
                bntLuu.Enabled    = false;
                bntTaoMoi.Enabled = false;
                bntXoa.Enabled    = false;
            }
            currentModel = null;
        }