Exemplo n.º 1
0
        /// <summary>
        /// Lưu dữ liệu trên UltraGrid
        /// </summary>
        protected override void SaveDetail()
        {
            try
            {
                foreach (var row in dgv_DanhSach.Rows)
                {
                    var hs = new DapAn
                    {
                        IdKyThi   = _idKythi,
                        MaMon     = row.Cells["MaMon"].Text,
                        MaDe      = row.Cells["MaDe"].Text,
                        CauHoi    = int.Parse(row.Cells["CauHoi"].Text),
                        Dapan     = row.Cells["Dapan"].Text,
                        ThangDiem = 0
                    };

                    _listAdd.Add(hs);
                }
                if (_listAdd.Count <= 0)
                {
                    return;
                }
                InsertData.ThemDapAn(_listAdd);
                MessageBox.Show(@"Đã lưu vào CSDL", FormResource.MsgCaption, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.Contains(FormResource.msgLostConnect) ? FormResource.txtLoiDB : ex.Message);
                Log2File.LogExceptionToFile(ex);
            }
        }