コード例 #1
0
 partial void DeleteKT_TSCD(KT_TSCD instance);
コード例 #2
0
 partial void UpdateKT_TSCD(KT_TSCD instance);
コード例 #3
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;

                //validation
                GridColumn thangCol = view.Columns["THANG"];
                GridColumn ma_tsCol = view.Columns["MA_TS"];
                string thang = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, thangCol), "");
                string ma_ts = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, ma_tsCol), "");
                if (thang.Trim().Length == 0 || ma_ts.Trim().Length == 0)
                {
                    e.Valid = false;
                    if (thang.Trim().Length == 0)
                        view.SetColumnError(thangCol, "Tháng không được rổng");
                    if (ma_ts.Trim().Length == 0)
                        view.SetColumnError(ma_tsCol, "Mã tài sản không được rổng");

                    return;
                }

                _KTTSCDRepo = new KTTSCDRepo();
                //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_TSCD obj = new KT_TSCD();

                    obj.THANG = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "THANG"), "");
                    obj.NAM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "NAM"), "");
                    obj.MA_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TS"), "");
                    obj.TEN_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TS"), "");
                    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.KH_THANG_NAY = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "KH_THANG_NAY"), 0);
                    obj.GT_CL_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "GT_CL_DAUNAM"), 0);
                    obj.LK_KH_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "LK_KH_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.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");
                    obj.TRANG_THAI = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0);

                    _KTTSCDRepo.Create(obj);

                }
                //Cũ thì update
                else
                {
                    int id = Utils.CIntDef(view.GetRowCellValue(view.FocusedRowHandle, "ID"), 0);
                    KT_TSCD obj = _KTTSCDRepo.GetById(id);
                    if (obj != null)
                    {
                        obj.THANG = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "THANG"), "");
                        obj.NAM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "NAM"), "");
                        obj.MA_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TS"), "");
                        obj.TEN_TS = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TS"), "");
                        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.KH_THANG_NAY = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "KH_THANG_NAY"), 0);
                        obj.GT_CL_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "GT_CL_DAUNAM"), 0);
                        obj.LK_KH_DAUNAM = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "LK_KH_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.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");
                        obj.TRANG_THAI = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0);

                        _KTTSCDRepo.Update(obj);
                    }

                }
                Load_Data();
            }
            catch (Exception ex)
            {
                e.Valid = false;
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
 partial void InsertKT_TSCD(KT_TSCD instance);
コード例 #5
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)
                {
                    _KTTSCDRepo = new KTTSCDRepo();
                    KT_TSCD obj = new KT_TSCD();

                    obj.THANG = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "THANG"), "");
                    obj.NAM = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NAM"), "");
                    obj.MA_TS = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_TS"), "");
                    obj.TEN_TS = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TEN_TS"), "");
                    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.KH_THANG_NAY = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "KH_THANG_NAY"), 0);
                    obj.GT_CL_DAUNAM = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GT_CL_DAUNAM"), 0);
                    obj.LK_KH_DAUNAM = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "LK_KH_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.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "");
                    obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TRANG_THAI"), 0);

                    _KTTSCDRepo.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);
            }
        }