Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
 private void suggest_ma_phieu()
 {
     string v_str_so_phieu = "";
     US_MAX_SO_PHIEU_THEO_THANG v_us_max_sp = new US_MAX_SO_PHIEU_THEO_THANG();
     switch (m_str_loai_form)
     {
         case "PHAI_THU":
             v_str_so_phieu = v_us_max_sp.SelectMaxSoPhieu(CONST_ID_LOAI_PHIEU_THU.PHIEU_PHAI_THU
                                                           , m_dat_ngay_thu.Value.Month);
             m_txt_so_phieu.Text = CONST_TIEN_TO_SO_PHIEU.PHAI_THU + v_str_so_phieu;
             break;
         case "THUC_THU":
             v_str_so_phieu = v_us_max_sp.SelectMaxSoPhieu(CONST_ID_LOAI_PHIEU_THU.PHIEU_THUC_THU
                                                           , m_dat_ngay_thu.Value.Month);
             m_txt_so_phieu.Text = CONST_TIEN_TO_SO_PHIEU.THUC_THU + v_str_so_phieu;
             break;
         case "GIAM_TRU":
             v_str_so_phieu = v_us_max_sp.SelectMaxSoPhieu(CONST_ID_LOAI_PHIEU_THU.PHIEU_GIAM_TRU
                                                           , m_dat_ngay_thu.Value.Month);
             m_txt_so_phieu.Text = CONST_TIEN_TO_SO_PHIEU.GIAM_TRU + v_str_so_phieu;
             break;
         default:
             break;
     }
 }