示例#1
0
 private void Get_Data(KT_CHAM_CONG obj, int position)
 {
     try
     {
         obj.STT = Utils.CIntDef(gridView1.GetRowCellValue(position, "STT"), 0);
         obj.TEN_NV = Utils.CStrDef(gridView1.GetRowCellValue(position, "TEN_NV"), "");
         obj.NAM = Utils.CStrDef(gridView1.GetRowCellValue(position, "NAM"), "");
         obj.THANG = Utils.CStrDef(gridView1.GetRowCellValue(position, "THANG"), "");
         obj.LOAI_BL = Utils.CStrDef(gridView1.GetRowCellValue(position, "LOAI_BL"), "");
         obj.MA_NV = Utils.CStrDef(gridView1.GetRowCellValue(position, "MA_NV"), "");
         obj.PHONG_BAN = Utils.CStrDef(gridView1.GetRowCellValue(position, "PHONG_BAN"), "");
         obj.TEN_PHONG_BAN = Utils.CStrDef(gridView1.GetRowCellValue(position, "TEN_PHONG_BAN"), "");
         obj.TONG_NC = Utils.CDblDef(gridView1.GetRowCellValue(position, "TONG_NC"), 0);
         obj.TONG_NN = Utils.CDblDef(gridView1.GetRowCellValue(position, "TONG_NN"), 0);
         obj.N01 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N01"), "");
         obj.N02 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N02"), "");
         obj.N03 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N03"), "");
         obj.N04 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N04"), "");
         obj.N05 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N05"), "");
         obj.N06 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N06"), "");
         obj.N07 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N07"), "");
         obj.N08 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N08"), "");
         obj.N09 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N09"), "");
         obj.N10 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N10"), "");
         obj.N11 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N11"), "");
         obj.N12 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N12"), "");
         obj.N13 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N13"), "");
         obj.N14 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N14"), "");
         obj.N15 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N15"), "");
         obj.N16 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N16"), "");
         obj.N17 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N17"), "");
         obj.N18 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N18"), "");
         obj.N19 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N19"), "");
         obj.N20 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N20"), "");
         obj.N21 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N21"), "");
         obj.N22 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N22"), "");
         obj.N23 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N23"), "");
         obj.N24 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N24"), "");
         obj.N25 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N25"), "");
         obj.N26 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N26"), "");
         obj.N27 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N27"), "");
         obj.N28 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N28"), "");
         obj.N29 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N29"), "");
         obj.N30 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N30"), "");
         obj.N31 = Utils.CStrDef(gridView1.GetRowCellValue(position, "N31"), "");
         obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(position, "TRANG_THAI"), 0);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;
                _KTCHAMCONGRepo = new KTCHAMCONGRepo();
                //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_CHAM_CONG obj = new KT_CHAM_CONG();
                    Get_Data(obj, e.RowHandle);
                    _KTCHAMCONGRepo.Create(obj);

                }
                //Cũ thì update
                else
                {
                    int id = Utils.CIntDef(gridView1.GetRowCellValue(e.RowHandle, "ID").ToString(), 0);
                    KT_CHAM_CONG obj = _KTCHAMCONGRepo.GetById(id);
                    if (obj != null)
                    {
                        Get_Data(obj, e.RowHandle);
                        _KTCHAMCONGRepo.Update(obj);
                    }

                }
                Load_Data();
            }
            catch (Exception ex)
            {
                e.Valid = false;
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
 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)
         {
             _KTCHAMCONGRepo = new KTCHAMCONGRepo();
             KT_CHAM_CONG obj = new KT_CHAM_CONG();
             Get_Data(obj, gridView1.FocusedRowHandle);
             _KTCHAMCONGRepo.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);
     }
 }
 partial void DeleteKT_CHAM_CONG(KT_CHAM_CONG instance);
 partial void UpdateKT_CHAM_CONG(KT_CHAM_CONG instance);
 partial void InsertKT_CHAM_CONG(KT_CHAM_CONG instance);