Ejemplo n.º 1
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;
                _KTDMCongTrinhRepo = new KTDMCongTrinhRepo();
                //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_DMCongTrinh obj = new KT_DMCongTrinh();
                    obj.MA_CT = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "MA_CT"), "");
                    obj.TEN_CT = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "TEN_CT"), "");
                    obj.HOAN_THANH = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "HOAN_THANH"), 0);
                    DateTime? temp = null;
                    if (Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_HD"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_HD"), DateTime.MinValue);
                    obj.NGAY_HD = temp;
                    obj.SO_HD = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "SO_HD"), "");
                    obj.NOI_DUNG = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "NOI_DUNG"), "");
                    obj.GT_VND = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_VND"), 0);
                    obj.GT_USD = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_USD"), 0);
                    obj.GT_NT_VND = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_NT_VND"), 0);
                    obj.GT_NT_VND = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_NT_VND"), 0);
                    obj.SO_NGAY_LAM = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "SO_NGAY_LAM"), 0);
                    temp = null;
                    if (Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_NT"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_NT"), DateTime.MinValue);
                    obj.NGAY_NT = temp;
                    temp = null;
                    if (Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_KC"), DateTime.MinValue) != DateTime.MinValue)
                        temp = Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_KC"), DateTime.MinValue);
                    obj.NGAY_KC = temp;
                    obj.CP_DK_621 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_621"), 0);
                    obj.CP_DK_622 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_622"), 0);
                    obj.CP_DK_623 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_623"), 0);
                    obj.CP_DK_627 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_627"), 0);
                    obj.DO_DANG_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "DO_DANG_DK"), 0);
                    obj.DOANH_THU_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "DOANH_THU_DK"), 0);
                    obj.THUE_VAT_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "THUE_VAT_DK"), 0);
                    obj.DS_HD_DK = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "DS_HD_DK"), "");
                    obj.DS_HD_TK = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "DS_HD_TK"), "");
                    obj.TONG_CP = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "TONG_CP"), 0);
                    obj.CP_CK_621 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_621"), 0);
                    obj.CP_CK_622 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_622"), 0);
                    obj.CP_CK_623 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_623"), 0);
                    obj.CP_CK_627 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_627"), 0);
                    obj.DO_DANG_CK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "DO_DANG_CK"), 0);
                    obj.LAI_GOP = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LAI_GOP"), 0);
                    obj.TY_LE_LAI = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "TY_LE_LAI"), 0);
                    obj.TY_LE_PB = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "TY_LE_PB"), 0);
                    obj.GIA_VON_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GIA_VON_DK"), 0);
                    obj.TK_DO_DANG = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "TK_DO_DANG"), "");
                    obj.TK_GIA_VON = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "TK_GIA_VON"), "");
                    obj.LK_CPDK_621 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_621"), 0);
                    obj.LK_CPDK_622 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_622"), 0);
                    obj.LK_CPDK_623 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_623"), 0);
                    obj.LK_CPDK_627 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_627"), 0);
                    obj.LK_CPDK_TONG = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_TONG"), 0);
                    obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0);
                    obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");

                    _KTDMCongTrinhRepo.Create(obj);

                }
                //Cũ thì update
                else
                {
                    int id = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "ID"), 0);
                    KT_DMCongTrinh obj = _KTDMCongTrinhRepo.GetById(id);
                    if (obj != null)
                    {
                        obj.MA_CT = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "MA_CT"), "");
                        obj.TEN_CT = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "TEN_CT"), "");
                        obj.HOAN_THANH = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "HOAN_THANH"), 0);
                        DateTime? temp = null;
                        if (Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_HD"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_HD"), DateTime.MinValue);
                        obj.NGAY_HD = temp;
                        obj.SO_HD = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "SO_HD"), "");
                        obj.NOI_DUNG = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "NOI_DUNG"), "");
                        obj.GT_VND = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_VND"), 0);
                        obj.GT_USD = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_USD"), 0);
                        obj.GT_NT_VND = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_NT_VND"), 0);
                        obj.GT_NT_VND = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GT_NT_VND"), 0);
                        obj.SO_NGAY_LAM = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "SO_NGAY_LAM"), 0);
                        temp = null;
                        if (Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_NT"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_NT"), DateTime.MinValue);
                        obj.NGAY_NT = temp;
                        temp = null;
                        if (Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_KC"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(gridView1.GetRowCellValue(e.RowHandle, "NGAY_KC"), DateTime.MinValue);
                        obj.NGAY_KC = temp;
                        obj.CP_DK_621 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_621"), 0);
                        obj.CP_DK_622 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_622"), 0);
                        obj.CP_DK_623 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_623"), 0);
                        obj.CP_DK_627 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_DK_627"), 0);
                        obj.DO_DANG_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "DO_DANG_DK"), 0);
                        obj.DOANH_THU_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "DOANH_THU_DK"), 0);
                        obj.THUE_VAT_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "THUE_VAT_DK"), 0);
                        obj.DS_HD_DK = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "DS_HD_DK"), "");
                        obj.DS_HD_TK = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "DS_HD_TK"), "");
                        obj.TONG_CP = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "TONG_CP"), 0);
                        obj.CP_CK_621 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_621"), 0);
                        obj.CP_CK_622 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_622"), 0);
                        obj.CP_CK_623 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_623"), 0);
                        obj.CP_CK_627 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "CP_CK_627"), 0);
                        obj.DO_DANG_CK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "DO_DANG_CK"), 0);
                        obj.LAI_GOP = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LAI_GOP"), 0);
                        obj.TY_LE_LAI = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "TY_LE_LAI"), 0);
                        obj.TY_LE_PB = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "TY_LE_PB"), 0);
                        obj.GIA_VON_DK = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "GIA_VON_DK"), 0);
                        obj.TK_DO_DANG = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "TK_DO_DANG"), "");
                        obj.TK_GIA_VON = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "TK_GIA_VON"), "");
                        obj.LK_CPDK_621 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_621"), 0);
                        obj.LK_CPDK_622 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_622"), 0);
                        obj.LK_CPDK_623 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_623"), 0);
                        obj.LK_CPDK_627 = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_627"), 0);
                        obj.LK_CPDK_TONG = Utils.CDblDef(gridView1.GetRowCellValue(e.RowHandle, "LK_CPDK_TONG"), 0);
                        obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0);
                        obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");

                        _KTDMCongTrinhRepo.Update(obj);
                    }
                }
                Load_Data();
            }
            catch (Exception ex)
            {
                e.Valid = false;
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void Save_Data(bool msg)
        {
            try
            {
                _KTDMCongTrinhRepo = new KTDMCongTrinhRepo();
                int i = 0;
                foreach (int pos in _listUpdate)
                {
                    int id = Utils.CIntDef(gridView1.GetRowCellValue(pos, "ID"), 0);
                    KT_DMCongTrinh obj = _KTDMCongTrinhRepo.GetById(id);
                    if (obj != null)
                    {
                        obj.MA_CT = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_CT"), "");
                        obj.TEN_CT = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_CT"), "");
                        obj.HOAN_THANH = Utils.CDblDef(gridView1.GetRowCellValue(pos, "HOAN_THANH"), 0);
                        DateTime? temp = null;
                        if (Utils.CDateDef(gridView1.GetRowCellValue(pos, "NGAY_HD"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(gridView1.GetRowCellValue(pos, "NGAY_HD"), DateTime.MinValue);
                        obj.NGAY_HD = temp;
                        obj.SO_HD = Utils.CStrDef(gridView1.GetRowCellValue(pos, "SO_HD"), "");
                        obj.NOI_DUNG = Utils.CStrDef(gridView1.GetRowCellValue(pos, "NOI_DUNG"), "");
                        obj.GT_VND = Utils.CDblDef(gridView1.GetRowCellValue(pos, "GT_VND"), 0);
                        obj.GT_USD = Utils.CDblDef(gridView1.GetRowCellValue(pos, "GT_USD"), 0);
                        obj.GT_NT_VND = Utils.CDblDef(gridView1.GetRowCellValue(pos, "GT_NT_VND"), 0);
                        obj.GT_NT_VND = Utils.CDblDef(gridView1.GetRowCellValue(pos, "GT_NT_VND"), 0);
                        obj.SO_NGAY_LAM = Utils.CDblDef(gridView1.GetRowCellValue(pos, "SO_NGAY_LAM"), 0);
                        temp = null;
                        if (Utils.CDateDef(gridView1.GetRowCellValue(pos, "NGAY_NT"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(gridView1.GetRowCellValue(pos, "NGAY_NT"), DateTime.MinValue);
                        obj.NGAY_NT = temp;
                        temp = null;
                        if (Utils.CDateDef(gridView1.GetRowCellValue(pos, "NGAY_KC"), DateTime.MinValue) != DateTime.MinValue)
                            temp = Utils.CDateDef(gridView1.GetRowCellValue(pos, "NGAY_KC"), DateTime.MinValue);
                        obj.NGAY_KC = temp;
                        obj.CP_DK_621 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_DK_621"), 0);
                        obj.CP_DK_622 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_DK_622"), 0);
                        obj.CP_DK_623 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_DK_623"), 0);
                        obj.CP_DK_627 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_DK_627"), 0);
                        obj.DO_DANG_DK = Utils.CDblDef(gridView1.GetRowCellValue(pos, "DO_DANG_DK"), 0);
                        obj.DOANH_THU_DK = Utils.CDblDef(gridView1.GetRowCellValue(pos, "DOANH_THU_DK"), 0);
                        obj.THUE_VAT_DK = Utils.CDblDef(gridView1.GetRowCellValue(pos, "THUE_VAT_DK"), 0);
                        obj.DS_HD_DK = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DS_HD_DK"), "");
                        obj.DS_HD_TK = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DS_HD_TK"), "");
                        obj.TONG_CP = Utils.CDblDef(gridView1.GetRowCellValue(pos, "TONG_CP"), 0);
                        obj.CP_CK_621 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_CK_621"), 0);
                        obj.CP_CK_622 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_CK_622"), 0);
                        obj.CP_CK_623 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_CK_623"), 0);
                        obj.CP_CK_627 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CP_CK_627"), 0);
                        obj.DO_DANG_CK = Utils.CDblDef(gridView1.GetRowCellValue(pos, "DO_DANG_CK"), 0);
                        obj.LAI_GOP = Utils.CDblDef(gridView1.GetRowCellValue(pos, "LAI_GOP"), 0);
                        obj.TY_LE_LAI = Utils.CDblDef(gridView1.GetRowCellValue(pos, "TY_LE_LAI"), 0);
                        obj.TY_LE_PB = Utils.CDblDef(gridView1.GetRowCellValue(pos, "TY_LE_PB"), 0);
                        obj.GIA_VON_DK = Utils.CDblDef(gridView1.GetRowCellValue(pos, "GIA_VON_DK"), 0);
                        obj.TK_DO_DANG = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TK_DO_DANG"), "");
                        obj.TK_GIA_VON = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TK_GIA_VON"), "");
                        obj.LK_CPDK_621 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "LK_CPDK_621"), 0);
                        obj.LK_CPDK_622 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "LK_CPDK_622"), 0);
                        obj.LK_CPDK_623 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "LK_CPDK_623"), 0);
                        obj.LK_CPDK_627 = Utils.CDblDef(gridView1.GetRowCellValue(pos, "LK_CPDK_627"), 0);
                        obj.LK_CPDK_TONG = Utils.CDblDef(gridView1.GetRowCellValue(pos, "LK_CPDK_TONG"), 0);
                        obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(pos, "TRANG_THAI"), 0);
                        obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DANH_DAU"), "");

                        _KTDMCongTrinhRepo.Update(obj);
                        i++;
                    }
                }
                _listUpdate = new List<int>();
                //if (i > 0 && msg)
                //{
                //    MessageBox.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }            
        }
Ejemplo n.º 3
0
 private void Save_Tick()
 {
     try
     {
         _KTDMCongTrinhRepo = new KTDMCongTrinhRepo();
         int _id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID"), 0);
         KT_DMCongTrinh obj = _KTDMCongTrinhRepo.GetById(_id);
         if (obj != null)
         {
             obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "").Trim() == "T" ? "" : "T";
             _KTDMCongTrinhRepo.Update(obj);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }