private void tao_phieu()
        {
            US_GD_PHIEU_THU v_us_gd_phieu_thu = new US_GD_PHIEU_THU();
            US_GD_CHI_TIET_PHIEU_THU v_us_gd_chi_tiet_phieu_thu = new US_GD_CHI_TIET_PHIEU_THU();

            v_us_gd_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_RPT_BAO_CAO_DANH_SACH_PHIEU_THU v_us_rpt = new US_V_RPT_BAO_CAO_DANH_SACH_PHIEU_THU();
                if (!CGridUtils.IsThere_Any_NonFixed_Row(m_fg)) return;
                if (!CGridUtils.isValid_NonFixed_RowIndex(m_fg, v_i_cur_row)) return;
                grid2us_object(v_us_rpt, v_i_cur_row);

                //form_2_us_gd_phieu_thu
                v_us_gd_phieu_thu.strSO_PHIEU = m_fg.Rows[v_i_cur_row][(int)e_col_Number.SO_PHIEU].ToString().Trim();
                v_us_gd_phieu_thu.dcID_HOC_SINH = v_us_rpt.dcID_HOC_SINH;
                v_us_gd_phieu_thu.dcID_NGUOI_THU = CIPConvert.ToDecimal(m_cbo_nhan_vien_thu.SelectedValue);
                v_us_gd_phieu_thu.dcID_NGUOI_NHAP = CIPConvert.ToDecimal(m_cbo_nhan_vien_nhap.SelectedValue);
                v_us_gd_phieu_thu.strTEN_NGUOI_NOP_TIEN = m_fg.Rows[v_i_cur_row][(int)e_col_Number.HO_TEN_PH].ToString().Trim();
                v_us_gd_phieu_thu.strNOI_DUNG = m_fg.Rows[v_i_cur_row][(int)e_col_Number.NOI_DUNG].ToString().Trim();
                v_us_gd_phieu_thu.SetSO_TIENNull();
                v_us_gd_phieu_thu.datNGAY_THU = m_dat_tai_ngay.Value.Date;
                v_us_gd_phieu_thu.datNGAY_NHAP = m_dat_ngay_nhap.Value.Date;
                v_us_gd_phieu_thu.dcID_LOAI_PHIEU_THU = CONST_ID_LOAI_PHIEU_THU.PHIEU_PHAI_THU;
                v_us_gd_phieu_thu.dcID_TRANG_THAI = CONST_ID_TRANG_THAI_BAN_GIAO.DA_THU;

                v_us_gd_phieu_thu.Insert();

                //form_2_us_gd_chi_tiet_phieu_thu
                v_us_gd_chi_tiet_phieu_thu.dcID_GD_PHIEU_THU = v_us_gd_phieu_thu.dcID;
                v_us_gd_chi_tiet_phieu_thu.dcID_LOP_MON = CIPConvert.ToDecimal(m_cbo_lop_mon.SelectedValue);
                v_us_gd_chi_tiet_phieu_thu.dcSO_TIEN = CIPConvert.ToDecimal(m_fg.Rows[v_i_cur_row][(int)e_col_Number.TIEN_PHAI_THU].ToString());
                v_us_gd_chi_tiet_phieu_thu.UseTransOfUSObject(v_us_gd_phieu_thu);
                v_us_gd_chi_tiet_phieu_thu.Insert();
            }
            v_us_gd_phieu_thu.CommitTransaction();
        }
Ejemplo n.º 2
0
        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;
            }
        }