private void insert_chi_tiet_phieu_thu(decimal ip_id_phieu_thu) { try { m_us_gd_ct_phieu_thu.BeginTransaction(); for (int v_i_cur_row = m_fg.Rows.Fixed; v_i_cur_row < m_fg.Rows.Count; v_i_cur_row++) { US_V_F340_LOP_MON_CUA_HS v_us_lm_hs = new US_V_F340_LOP_MON_CUA_HS(); grid2us_object(v_us_lm_hs, v_i_cur_row); m_us_gd_ct_phieu_thu.dcID_LOP_MON = v_us_lm_hs.dcID_LOP_MON; m_us_gd_ct_phieu_thu.dcSO_TIEN = CIPConvert.ToDecimal(m_fg.Rows[v_i_cur_row][(int)e_col_Number.SO_TIEN].ToString().Trim());////Cho nay de chet, can sua sau m_us_gd_ct_phieu_thu.Insert(); } m_us_gd_ct_phieu_thu.CommitTransaction(); } catch (Exception v_e) { if (m_us_gd_phieu_thu.is_having_transaction()) { m_us_gd_phieu_thu.Rollback(); } CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e, new CDBClientDBExceptionInterpret()); v_objErrHandler.showErrorMessage(); } }
private void insert_phieu_thu_ct_phieu_thu() { try { form_2_us_gd_phieu_thu(); //Đẩy dữ liệu trước vào max số phiếu US_MAX_SO_PHIEU_THEO_THANG v_us_ma_sp = new US_MAX_SO_PHIEU_THEO_THANG(); v_us_ma_sp.dcID_LOAI_PHIEU = m_us_gd_phieu_thu.dcID_LOAI_PHIEU_THU; if (m_us_gd_phieu_thu.datNGAY_THU.Month.ToString().Length == 1) { v_us_ma_sp.strTHANG = "0" + m_us_gd_phieu_thu.datNGAY_THU.Month.ToString(); } else { v_us_ma_sp.strTHANG = m_us_gd_phieu_thu.datNGAY_THU.Month.ToString(); } if (m_str_loai_form == "PHAI_THU") { v_us_ma_sp.strTIEN_TO_PHIEU = "PT-"; } else if (m_str_loai_form == "THUC_THU") { v_us_ma_sp.strTIEN_TO_PHIEU = "TT-"; } else if (m_str_loai_form == "GIAM_TRU") { v_us_ma_sp.strTIEN_TO_PHIEU = "GT-"; } else { v_us_ma_sp.strTIEN_TO_PHIEU = ""; } v_us_ma_sp.strMAX_SO_PHIEU = m_us_gd_phieu_thu.strSO_PHIEU.Substring(m_us_gd_phieu_thu.strSO_PHIEU.LastIndexOf("-") + 1); //Xoa phieu thu da co if (m_str_loai_form == "PHAI_THU") { if (check_phieu_is_exist()) { //BaseMessages.MsgBox_Error("Tháng này bạn đã lập phiếu thực thu rồi. Bạn kiểm tra lại nhé!"); //BaseMessages.MsgBox_YES_NO_CANCEL("Tháng này bạn đã lập phiếu thực thu rồi. Bạn có muốn lập lại phiếu không?"); if (BaseMessages.MsgBox_YES_NO_CANCEL("Học sinh này đã có phiếu phải thu trong tháng này rồi. Bạn có muốn lập lại phiếu không?") == DialogResult.Yes) { delete_phieu_cu(); //tao_phieu(); //BaseMessages.MsgBox_Infor("Đã tạo phiếu phải thu tự động cho lớp " + m_cbo_lop_mon.Text); m_us_gd_phieu_thu.BeginTransaction(); m_us_gd_phieu_thu.Insert(); m_us_gd_ct_phieu_thu.UseTransOfUSObject(m_us_gd_phieu_thu); m_us_gd_ct_phieu_thu.dcID_GD_PHIEU_THU = m_us_gd_phieu_thu.dcID; for (int v_i_cur_row = m_fg.Rows.Fixed; v_i_cur_row < m_fg.Rows.Count; v_i_cur_row++) { US_V_F340_LOP_MON_CUA_HS v_us_lm_hs = new US_V_F340_LOP_MON_CUA_HS(); grid2us_object(v_us_lm_hs, v_i_cur_row); m_us_gd_ct_phieu_thu.dcID_LOP_MON = v_us_lm_hs.dcID_LOP_MON; m_us_gd_ct_phieu_thu.dcSO_TIEN = CIPConvert.ToDecimal(m_fg.Rows[v_i_cur_row][(int)e_col_Number.SO_TIEN].ToString().Trim());////Cho nay de chet, can sua sau m_us_gd_ct_phieu_thu.Insert(); } //Insert vao bang Max so phieu v_us_ma_sp.UseTransOfUSObject(m_us_gd_phieu_thu); v_us_ma_sp.Insert(); //Day du lieu vao us_chi_tiet_phieu_thu m_us_gd_phieu_thu.CommitTransaction(); //insert_bang_max_so_phieu dong_y = 0; return; } else { dong_y = 1; DialogResult v_dlg = BaseMessages.MsgBox_YES_NO_CANCEL("Bạn có muốn nhập phiếu khác?"); switch (v_dlg) { case DialogResult.Yes: refresh_form(); break; case DialogResult.No: this.Close(); break; case DialogResult.Cancel: break; default: break; } return; } } } //Kết thúc đẩy m_us_gd_phieu_thu.BeginTransaction(); m_us_gd_phieu_thu.Insert(); m_us_gd_ct_phieu_thu.UseTransOfUSObject(m_us_gd_phieu_thu); m_us_gd_ct_phieu_thu.dcID_GD_PHIEU_THU = m_us_gd_phieu_thu.dcID; for (int v_i_cur_row = m_fg.Rows.Fixed; v_i_cur_row < m_fg.Rows.Count; v_i_cur_row++) { US_V_F340_LOP_MON_CUA_HS v_us_lm_hs = new US_V_F340_LOP_MON_CUA_HS(); grid2us_object(v_us_lm_hs, v_i_cur_row); m_us_gd_ct_phieu_thu.dcID_LOP_MON = v_us_lm_hs.dcID_LOP_MON; m_us_gd_ct_phieu_thu.dcSO_TIEN = CIPConvert.ToDecimal(m_fg.Rows[v_i_cur_row][(int)e_col_Number.SO_TIEN].ToString().Trim());////Cho nay de chet, can sua sau m_us_gd_ct_phieu_thu.Insert(); } //Insert vao bang Max so phieu v_us_ma_sp.UseTransOfUSObject(m_us_gd_phieu_thu); v_us_ma_sp.Insert(); //Day du lieu vao us_chi_tiet_phieu_thu m_us_gd_phieu_thu.CommitTransaction(); //insert_bang_max_so_phieu } catch (Exception v_e) { if (m_us_gd_phieu_thu.is_having_transaction()) { m_us_gd_phieu_thu.Rollback(); } throw v_e; //CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e, // new CDBClientDBExceptionInterpret()); //v_objErrHandler.showErrorMessage(); } }
private void grid2us_object(US_V_F340_LOP_MON_CUA_HS i_us , int i_grid_row) { DataRow v_dr; v_dr = (DataRow)m_fg.Rows[i_grid_row].UserData; m_obj_trans.GridRow2DataRow(i_grid_row, v_dr); i_us.DataRow2Me(v_dr); }
private void delete_phieu_cu() { DS_V_RPT_CHI_TIET_PHIEU_THU v_ds_v_rpt_chi_tiet_phieu_thu = new DS_V_RPT_CHI_TIET_PHIEU_THU(); US_V_RPT_CHI_TIET_PHIEU_THU v_us_v_rpt_chi_tiet_phieu_thu = new US_V_RPT_CHI_TIET_PHIEU_THU(); for (int v_i_cur_row = m_fg.Rows.Fixed; v_i_cur_row < m_fg.Rows.Count; v_i_cur_row++) { US_V_F340_LOP_MON_CUA_HS v_us_lm_hs = new US_V_F340_LOP_MON_CUA_HS(); grid2us_object(v_us_lm_hs, v_i_cur_row); v_us_v_rpt_chi_tiet_phieu_thu.FillDataset(v_ds_v_rpt_chi_tiet_phieu_thu, CIPConvert.ToDecimal(v_us_lm_hs.dcID_LOP_MON), m_dat_ngay_thu.Value.Date); for (int i = 0; i < v_ds_v_rpt_chi_tiet_phieu_thu.Tables[0].Rows.Count; i++) { US_V_RPT_CHI_TIET_PHIEU_THU v_us_v_rpt_chi_tiet_phieu_thu_detail = new US_V_RPT_CHI_TIET_PHIEU_THU(v_ds_v_rpt_chi_tiet_phieu_thu.Tables[0].Rows[i]); v_us_v_rpt_chi_tiet_phieu_thu_detail.BeginTransaction(); v_us_v_rpt_chi_tiet_phieu_thu_detail.DeleteByID(v_us_v_rpt_chi_tiet_phieu_thu_detail.dcID); v_us_v_rpt_chi_tiet_phieu_thu_detail.CommitTransaction(); } } }
private bool check_phieu_is_exist() { DS_V_RPT_CHI_TIET_PHIEU_THU v_ds_v_rpt_chi_tiet_phieu_thu = new DS_V_RPT_CHI_TIET_PHIEU_THU(); US_V_RPT_CHI_TIET_PHIEU_THU v_us_v_rpt_chi_tiet_phieu_thu = new US_V_RPT_CHI_TIET_PHIEU_THU(); int check_phieu_is_exist = 0; for (int v_i_cur_row = m_fg.Rows.Fixed; v_i_cur_row < m_fg.Rows.Count; v_i_cur_row++) { US_V_F340_LOP_MON_CUA_HS v_us_lm_hs = new US_V_F340_LOP_MON_CUA_HS(); grid2us_object(v_us_lm_hs, v_i_cur_row); v_us_v_rpt_chi_tiet_phieu_thu.FillDataset_by_id_lm_id_hs(v_ds_v_rpt_chi_tiet_phieu_thu, CIPConvert.ToDecimal(v_us_lm_hs.dcID_HOC_SINH), CIPConvert.ToDecimal(v_us_lm_hs.dcID_LOP_MON), m_dat_ngay_thu.Value.Date); if (v_ds_v_rpt_chi_tiet_phieu_thu.Tables[0].Rows.Count != 0) { check_phieu_is_exist = check_phieu_is_exist + 1; } } if (check_phieu_is_exist != 0) { return true; } else { return false; } }
private void save_data() { if (!check_validate_data()) { return; } if (!check_tong_tien_grid_textbox()) { return; } decimal v_dc_id_phieu_thu = 0; try { switch (m_e_form_mode) { case DataEntryFormMode.InsertDataState: if (!is_exist_so_phieu(ref v_dc_id_phieu_thu)) { insert_phieu_thu_ct_phieu_thu(); } else { BaseMessages.MsgBox_Infor("Số phiếu này đã được nhập trước đây rồi!"); return; } //insert_chi_tiet_phieu_thu(v_dc_id_phieu_thu); if (check_phieu_is_exist() == true && dong_y == 0) { DialogResult v_dlg = BaseMessages.MsgBox_YES_NO_CANCEL("Đã cập nhật thành công phiếu này. Bạn có muốn nhập phiếu khác"); switch (v_dlg) { case DialogResult.Yes: refresh_form(); break; case DialogResult.No: this.Close(); break; case DialogResult.Cancel: break; default: break; } } break; case DataEntryFormMode.UpdateDataState: form_2_us_gd_phieu_thu(); m_us_gd_phieu_thu.BeginTransaction(); m_us_gd_phieu_thu.Update(); //Delete het chi tiet phieu thu tu id_phieu_thu US_GD_CHI_TIET_PHIEU_THU v_us_gd_ct_pt = new US_GD_CHI_TIET_PHIEU_THU(); v_us_gd_ct_pt.deleteAllFromIDPhieuThu(m_us_gd_phieu_thu.dcID); //Insert lai chi tiet phieu thu for (int v_i_cur_row = m_fg.Rows.Fixed; v_i_cur_row < m_fg.Rows.Count; v_i_cur_row++) { US_V_F340_LOP_MON_CUA_HS v_us_lm_hs = new US_V_F340_LOP_MON_CUA_HS(); grid2us_object(v_us_lm_hs, v_i_cur_row); m_us_gd_ct_phieu_thu.dcID_LOP_MON = v_us_lm_hs.dcID_LOP_MON; m_us_gd_ct_phieu_thu.dcID_GD_PHIEU_THU = m_us_gd_phieu_thu.dcID; m_us_gd_ct_phieu_thu.dcSO_TIEN = CIPConvert.ToDecimal(m_fg.Rows[v_i_cur_row][(int)e_col_Number.SO_TIEN].ToString().Trim());////Cho nay de chet, can sua sau m_us_gd_ct_phieu_thu.UseTransOfUSObject(m_us_gd_phieu_thu); m_us_gd_ct_phieu_thu.Insert(); } m_us_gd_phieu_thu.CommitTransaction(); BaseMessages.MsgBox_Infor("Đã cập nhật thành công"); break; default: break; } } catch (Exception v_e) { if (m_us_gd_phieu_thu.is_having_transaction()) { m_us_gd_phieu_thu.Rollback(); } throw v_e; } }
private void load_data_2_grid() { m_obj_trans = get_trans_object(m_fg); DS_V_F340_LOP_MON_CUA_HS v_ds = new DS_V_F340_LOP_MON_CUA_HS(); US_V_F340_LOP_MON_CUA_HS v_us = new US_V_F340_LOP_MON_CUA_HS(); v_ds.Clear(); v_ds.EnforceConstraints = false; if (m_str_trang_thai_phieu != "F430") { v_us.FillDatasetByIdHS(v_ds, m_us_v_hoc_sinh.dcID); } else { v_us.FillDatasetDuLieuDaCo(v_ds, m_id_gd_phieu_thu); } m_fg.Redraw = false; CGridUtils.Dataset2C1Grid(v_ds, m_fg, m_obj_trans); CGridUtils.MakeSoTT(0, m_fg); m_fg.Redraw = true; }