private bool is_exist_bill_in_db(string ip_so_bill) { US_DM_BILL v_us_dm_bill = new US_DM_BILL(); if(v_us_dm_bill.is_existed_bill(v_us_dm_bill, ip_so_bill)) { return true; } return false; }
private bool check_validate_is_having_so_bill(string ip_str_so_bill) { bool v_b_result = true; US_DM_BILL v_us_dm_bill = new US_DM_BILL(); DS_DM_BILL v_ds_dm_bill = new DS_DM_BILL(); v_us_dm_bill.FillDataset(v_ds_dm_bill, "where so_bill = '" + ip_str_so_bill + "'"); if (v_ds_dm_bill.DM_BILL.Count > 0) v_b_result = false; return v_b_result; }
private void save_grid_to_database() { US_DM_BILL v_us_dm_bill; GridViewRow[] v_arr_gvr = new GridViewRow[m_grv_dm_bill.Rows.Count]; System.Web.UI.WebControls.TextBox v_txt_so_bill; System.Web.UI.WebControls.TextBox v_txt_ma_phong_ban; System.Web.UI.WebControls.TextBox v_txt_nguoi_nhan; System.Web.UI.WebControls.TextBox v_txt_nguoi_gui; System.Web.UI.WebControls.TextBox v_txt_noi_nhan; System.Web.UI.WebControls.TextBox v_txt_noi_dung_gui; System.Web.UI.WebControls.TextBox v_txt_noi_ghi_chu; System.Web.UI.WebControls.RadioButton v_rdb_trong_nuoc; //eWorld.UI.CalendarPopup v_dat_ngay_gui; m_grv_dm_bill.Rows.CopyTo(v_arr_gvr, 0); //Phải chia nhỏ để insert nếu số lượng bản ghi lớn int start_number = 0; //vị trí bản ghi bắt đầu insert int numbers_record_limited = v_arr_gvr.Length; // số bản ghi được insert k vượt quá 50 //int numbers_record_remain = v_arr_gvr.Length; //số bản ghi còn lại sau mỗi lần insert //while (numbers_record_remain >= 0) //{ // if (numbers_record_remain - 50 > 0) // numbers_record_limited = 50; // else // numbers_record_limited = numbers_record_remain; for (int i = start_number; i < numbers_record_limited; i++) { v_txt_so_bill = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_so_bill_grid"); v_txt_ma_phong_ban = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_ma_phong_ban_grid"); v_txt_nguoi_nhan = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_nguoi_nhan_grid"); v_txt_nguoi_gui = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_nguoi_gui_grid"); v_txt_noi_nhan = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_noi_nhan_grid"); v_txt_noi_dung_gui = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_noi_dung_grid"); v_txt_noi_ghi_chu = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_ghi_chu_grid"); v_rdb_trong_nuoc = (System.Web.UI.WebControls.RadioButton)v_arr_gvr[i].FindControl("m_rdb_trong_nuoc"); //v_dat_ngay_gui = (eWorld.UI.CalendarPopup)v_arr_gvr[i].FindControl("m_dat_ngay_gui"); System.Web.UI.WebControls.TextBox v_txt_ngay_gui = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_ngay_gui_grid"); US_DM_PHONG_BAN v_us_dm_phong_ban = new US_DM_PHONG_BAN(); DS_DM_PHONG_BAN v_ds_dm_phong_ban = new DS_DM_PHONG_BAN(); // chỗ này kiêm tra điêu kiên phân quyen du lieu // chi cho luu du lieu cua phong ban duoc phan quyen //em bỏ check ơr ma phong ban roi if (CIPConvert.ToDecimal(m_hdf_so_ban_ghi.Value) == m_grv_dm_bill.PageIndex) return; v_us_dm_phong_ban.FillDataset(v_ds_dm_phong_ban, "where id=" + CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value)); if (v_ds_dm_phong_ban.DM_PHONG_BAN.Count < 1) continue; else { v_us_dm_bill = new US_DM_BILL(); //v_us_dm_bill.BeginTransaction(); v_us_dm_bill.dcID_PHONG_BAN = CIPConvert.ToDecimal(v_ds_dm_phong_ban.DM_PHONG_BAN[0][0]); v_us_dm_bill.dcID_TRANG_THAI = CONST_ID_TRANG_THAI_THU.ID_DA_NHAN_NOI_BO; v_us_dm_bill.strSO_BILL = v_txt_so_bill.Text.Trim(); v_us_dm_bill.strGHI_CHU = v_txt_noi_ghi_chu.Text.Trim(); v_us_dm_bill.strNGUOI_GUI = v_txt_nguoi_gui.Text.Trim(); v_us_dm_bill.strNGUOI_NHAN = v_txt_nguoi_nhan.Text.Trim(); v_us_dm_bill.strNOI_NHAN = v_txt_noi_nhan.Text.Trim(); v_us_dm_bill.strNOI_DUNG = v_txt_noi_dung_gui.Text.Trim(); //v_us_dm_bill.datNGAY_GUI = v_dat_ngay_gui.SelectedDate; v_us_dm_bill.datNGAY_GUI = CIPConvert.ToDatetime(v_txt_ngay_gui.Text.Trim(), "dd/MM/yyyy"); if (v_rdb_trong_nuoc.Checked == true) { v_us_dm_bill.strTRONG_NUOC = "x"; v_us_dm_bill.SetNUOC_NGOAINull(); } else { v_us_dm_bill.SetTRONG_NUOCNull(); v_us_dm_bill.strNUOC_NGOAI = "x"; } v_us_dm_bill.Insert(); thong_bao("Đã import thành công " + (m_grv_dm_bill.PageIndex + 1) + "/" + m_grv_dm_bill.PageCount, true); } //} //if (numbers_record_limited == 50) // start_number = start_number + 50; // lấy vị trí bản ghi tiếp theo sẽ dc insert nếu còn //numbers_record_remain = numbers_record_remain - 50; // tính số bản ghi còn lại chưa insert } m_grv_dm_bill.PageIndex = m_grv_dm_bill.PageIndex + 1; if (CIPConvert.ToDecimal(m_hdf_so_ban_ghi.Value) == m_grv_dm_bill.PageIndex) { m_grv_dm_bill.DataSource = null; m_grv_dm_bill.Visible = false; } m_grv_dm_bill.DataBind(); }
private void us_object_to_form() { US_DM_BILL v_us_dm_bill = new US_DM_BILL(CIPConvert.ToDecimal(m_hdf_id_bill.Value)); m_txt_so_bill.Text = v_us_dm_bill.strSO_BILL.Trim(); m_txt_nguoi_nhan.Text = v_us_dm_bill.strNGUOI_NHAN.Trim(); m_txt_noi_nhan.Text = v_us_dm_bill.strNOI_NHAN.Trim(); m_txt_nguoi_gui.Text = v_us_dm_bill.strNGUOI_GUI.Trim(); m_txt_noi_dung.Text = v_us_dm_bill.strNOI_DUNG.Trim(); m_txt_ghi_chu.Text = v_us_dm_bill.strGHI_CHU.Trim(); m_txt_ngay_gui.Text = v_us_dm_bill.datNGAY_GUI.ToString("dd/MM/yyyy"); if (v_us_dm_bill.strTRONG_NUOC == "x") { m_rdb_trong_nuoc.Checked = true; } if (v_us_dm_bill.strNUOC_NGOAI == "x") { m_rdb_nuoc_ngoai.Checked = false; } }
private void change_state_of_bill(decimal ip_dc_id_bill, decimal ip_dc_id_trang_thai) { US_DM_BILL v_us_dm_bill = new US_DM_BILL(ip_dc_id_bill); v_us_dm_bill.dcID_TRANG_THAI = ip_dc_id_trang_thai; v_us_dm_bill.Update(); }
private bool check_validate_is_ok() { string v_form_mode = get_form_mode(m_hdf_form_mode); if (v_form_mode.Equals(LOAI_FORM.THEM) || v_form_mode.Equals(LOAI_FORM.SUA)) { //if (m_txt_so_bill.Text.Trim().Length != 8) //{ // thong_bao("Số Bill gồm 8 chữ số!"); // m_txt_so_bill.Focus(); // return false; //} } //Kiểm tra nhập trùng số Bill if (v_form_mode.Equals(LOAI_FORM.THEM)) { if (m_us_dm_bill.check_is_having_so_bill(m_txt_so_bill.Text)) { thong_bao("Số Bill đã tồn tại! "); return false; } } if (v_form_mode.Equals(LOAI_FORM.SUA)) { US_DM_BILL v_us_dm_bill = new US_DM_BILL(CIPConvert.ToDecimal(m_hdf_id_bill.Value)); if (!m_txt_so_bill.Text.Equals(v_us_dm_bill.strSO_BILL)) { if (m_us_dm_bill.check_is_having_so_bill(m_txt_so_bill.Text)) { thong_bao("Số Bill đã tồn tại! "); return false; } } } if (m_txt_so_bill.Text == null || m_txt_so_bill.Text == "") { thong_bao("Chưa nhập số Bill! "); m_txt_so_bill.Focus(); return false; } if (m_txt_nguoi_gui.Text == null || m_txt_nguoi_gui.Text == "") { thong_bao("Chưa nhập người gửi! "); m_txt_nguoi_gui.Focus(); return false; } if (m_txt_nguoi_nhan.Text == null || m_txt_nguoi_nhan.Text == "") { thong_bao("Chưa nhập người nhận! "); m_txt_nguoi_nhan.Focus(); return false; } if (m_txt_noi_nhan.Text == null || m_txt_noi_nhan.Text == "") { thong_bao("Chưa nhập nơi nhận! "); m_txt_noi_nhan.Focus(); return false; } return true; }
private void form_to_us_object() { switch (get_form_mode(m_hdf_form_mode)) { case LOAI_FORM.SUA: m_us_dm_bill.dcID = CIPConvert.ToDecimal(m_hdf_id_bill.Value); break; default: m_us_dm_bill = new US_DM_BILL(); break; } m_us_dm_bill.strSO_BILL = m_txt_so_bill.Text.Trim(); m_us_dm_bill.strNGUOI_NHAN = m_txt_nguoi_nhan.Text.Trim(); m_us_dm_bill.strNOI_NHAN = m_txt_noi_nhan.Text.Trim(); m_us_dm_bill.strNGUOI_GUI = m_txt_nguoi_gui.Text.Trim(); m_us_dm_bill.strNOI_DUNG = m_txt_noi_dung.Text.Trim(); m_us_dm_bill.strGHI_CHU = m_txt_ghi_chu.Text.Trim(); m_us_dm_bill.dcSO_TIEN = 0; m_us_dm_bill.datNGAY_GUI = CIPConvert.ToDatetime(m_txt_ngay_gui.Text, "dd/MM/yyyy"); m_us_dm_bill.dcID_PHONG_BAN = CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value); m_us_dm_bill.dcID_TRANG_THAI = CONST_ID_TRANG_THAI_THU.ID_DA_NHAN_NOI_BO; if (m_rdb_trong_nuoc.Checked == true) { m_us_dm_bill.strTRONG_NUOC = "x"; } if (m_rdb_nuoc_ngoai.Checked == true) { m_us_dm_bill.strNUOC_NGOAI = "x"; } }
private int dem_so_dong_bang_lay_boi_ma_so_bill(string ip_str_ma_so) { int v_int_count = 0; DS_DM_BILL v_ds_dm_bill = new DS_DM_BILL(); US_DM_BILL v_us_dm_bill = new US_DM_BILL(); m_us_dm_dang_ky_gui.load_dm_by_so_bill(v_ds_dm_bill, nullToString(ip_str_ma_so)); DataTable v_dt = v_ds_dm_bill.Tables[0]; v_int_count = v_dt.Rows.Count; return v_int_count; }
private void add_danh_sach_du_lieu() { US_DM_BILL v_us_dm_bill = new US_DM_BILL(); DS_DM_BILL v_ds_dm_bill = new DS_DM_BILL(); try { m_lbl_loading.Visible = true; v_us_dm_bill.BeginTransaction(); for (int v_int_row = m_fg_load_file.Rows.Fixed; v_int_row <= m_fg_load_file.Rows.Count - 1; v_int_row++) { //IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-GB", true); //DateTime theDateTime = DateTime.ParseExact(abc, "mm-dd-yyyy", theCultureInfo); v_us_dm_bill.strNOI_DUNG = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NOI_DUNG]); v_us_dm_bill.strNOI_NHAN = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NOI_NHAN]); v_us_dm_bill.strNGUOI_NHAN = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NGUOI_NHAN]); v_us_dm_bill.strTRONG_NUOC = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.TRONG_NUOC]); v_us_dm_bill.strNUOC_NGOAI = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NUOC_NGOAI]); v_us_dm_bill.strSO_BILL = CIPConvert.ToStr(m_fg_load_file[v_int_row, (int)e_col_Number.SO_BILL]); v_us_dm_bill.strNGUOI_GUI = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NGUOI_GUI]); v_us_dm_bill.datNGAY_GUI = Convert.ToDateTime(m_fg_load_file[v_int_row, (int)e_col_Number.NGAY_GUI].ToString()); v_us_dm_bill.strGHI_CHU = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.GHI_CHU]); v_us_dm_bill.dcID_PHONG_BAN = CIPConvert.ToDecimal(m_cbo_phong_ban.SelectedValue.ToString()); v_us_dm_bill.SetSO_TIENNull(); v_us_dm_bill.dcID_TRANG_THAI = CONST_ID_TRANG_THAI_THU.ID_DA_NHAN_NOI_BO; v_us_dm_bill.Insert(); } v_us_dm_bill.CommitTransaction(); m_lbl_load.Visible = false; ghi_log_he_thong(); m_i_flag = 0; BaseMessages.MsgBox_Infor("Đã import dữ liệu nhận từ Bưu cục thành công"); } catch (Exception v_e) { v_us_dm_bill.Rollback(); CDBExceptionHandler v_exceptionHander = new CDBExceptionHandler(v_e, new CDBClientDBExceptionInterpret()); v_exceptionHander.showErrorMessage(); } }
private DataTable database_2_datatable(DateTime ip_dau_thang, DateTime ip_cuoi_thang) { DS_DM_BILL v_ds_dm_bill = new DS_DM_BILL(); US_DM_BILL v_us_dm_bill = new US_DM_BILL(); //v_us_dm_bill.FillDataset(v_ds_dm_bill, "where NGAY_GUI >='"+ip_dau_thang +"' and NGAY_GUI <= '"+ip_cuoi_thang+"'"); v_us_dm_bill.get_dm_bill(ip_dau_thang, ip_cuoi_thang, v_ds_dm_bill); DataTable v_dt = v_ds_dm_bill.DM_BILL; return v_dt; }
public bool is_so_tien_null(US_DM_BILL ip_us_dm_bill, string ip_so_bill) { CStoredProc v_proc = new CStoredProc("pr_is_so_tien_null"); v_proc.addNVarcharInputParam("@SO_BILL", ip_so_bill); SqlParameter v_obj_is_so_tien_null = v_proc.addDecimalOutputParam("@SO_TIEN", 0); v_proc.ExecuteCommand(ip_us_dm_bill); if(CIPConvert.ToDecimal(v_obj_is_so_tien_null.Value) == -1) { return true; } return false; }
v_us.Delete(); v_us.CommitTransaction(); m_grv_bill.Rows.Remove(m_grv_bill.Row); } catch (Exception v_e) { v_us.Rollback(); CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e, new CDBClientDBExceptionInterpret());
protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } private void delete_v_dm_bill() { if (!CGridUtils.IsThere_Any_NonFixed_Row(m_grv_bill)) return; if (!CGridUtils.isValid_NonFixed_RowIndex(m_grv_bill, m_grv_bill.Row)) return; if (BaseMessages.askUser_DataCouldBeDeleted(8) != BaseMessages.IsDataCouldBeDeleted.CouldBeDeleted) return; US_DM_BILL v_us = new US_DM_BILL(); dm_grid2us_object(v_us, m_grv_bill.Row); try {
private bool check_so_tien_is_null(US_DM_BILL ip_us_dm_bill, string ip_so_bill) { return ip_us_dm_bill.is_so_tien_null(ip_us_dm_bill, ip_so_bill); }
private bool check_so_bill_in_db(string ip_so_bill) { US_DM_BILL v_us_dm_bill = new US_DM_BILL(); return v_us_dm_bill.is_existed_bill(v_us_dm_bill, ip_so_bill); }
private void so_sanh() { //Concept: Kiểm tra từng số bill ở trong file excel của NCC, //nếu tồn tại trong CSDL (bảng DM bill) thì update số tiền bằng mã bill //Bản ghi nào update xong thì trên lưới xóa bỏ hàng đó đi, cuối cùng còn chừa lại những mã bill của ncc chưa đc //update vào pm (do trên phần mềm ko có mã bill đó hoặc nhập sai) C1.Win.C1FlexGrid.CellStyle v_cell_style_not_in_db = this.m_fg.Styles.Add("RowColorNotInDb"); v_cell_style_not_in_db.BackColor = Color.Red; C1.Win.C1FlexGrid.CellStyle v_cell_style_ton_tai_tien = this.m_fg.Styles.Add("RowColorTonTaiTien"); v_cell_style_ton_tai_tien.BackColor = Color.Gold; C1.Win.C1FlexGrid.CellStyle v_cell_style_ok = this.m_fg.Styles.Add("RowColorOk"); v_cell_style_ok.BackColor = Color.Yellow; List<CError_ton_tai_bill> v_listError_ton_tai_bill = new List<CError_ton_tai_bill>(); List<CError_ton_tai_tien> v_listError_ton_tai_tien = new List<CError_ton_tai_tien>(); int v_amount_row = m_fg.Rows.Count - 1; Int64 count_bill_update = 0; //Kiểm tra các tổng tiền đúng chưa? for(int v_row = m_fg.Rows.Fixed; v_row < v_amount_row; v_row++) { /* Kiểm tra xem số bill có trên csdl chưa. Nếu không có thì kệ trên lưới, xuất lỗi ra listbox*/ if(m_fg[v_row, (int)e_col_Number.barcode] == null || m_fg[v_row, (int)e_col_Number.barcode].ToString() == "") { return; } string v_so_bill = CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]); if(!check_so_bill_in_db(CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]))) { CError_ton_tai_bill v_error_exist = new CError_ton_tai_bill(); v_error_exist.name = CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]); v_error_exist.value = CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]);; v_listError_ton_tai_bill.Add(v_error_exist); m_fg.SetCellStyle(v_row, (int)e_col_Number.barcode, v_cell_style_not_in_db); continue; } //Kiểm tra xem bill đã có tiền chưa? US_DM_BILL v_us_dm_bill = new US_DM_BILL(); if(!check_so_tien_is_null(v_us_dm_bill, CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]))) { CError_ton_tai_tien v_error_null = new CError_ton_tai_tien(); v_error_null.name = CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]); v_error_null.value = CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]); ; v_listError_ton_tai_tien.Add(v_error_null); m_fg.SetCellStyle(v_row, (int)e_col_Number.barcode, v_cell_style_ton_tai_tien); continue; } else { m_fg.SetCellStyle(v_row, (int)e_col_Number.barcode, v_cell_style_ok); v_us_dm_bill.update_tien_by_so_bill(CIPConvert.ToStr(m_fg[v_row, (int)e_col_Number.barcode]), CIPConvert.ToDecimal(m_fg[v_row, (int)e_col_Number.tien])); count_bill_update = count_bill_update + 1; } if(m_fg.Rows.Count == 3) m_fg.Rows[1].Clear(C1.Win.C1FlexGrid.ClearFlags.All); else { m_fg.RemoveItem(v_row); v_row = v_row - 1; } } MessageBox.Show("Đã cập nhật số tiền chi phí cho " + count_bill_update + " bill, " + (v_amount_row - 1 - count_bill_update) + " bill chưa cập nhật!"); //Gán lôi không tồn tại bill m_lbox_ds_loi_bill.DataSource = v_listError_ton_tai_bill; m_lbox_ds_loi_bill.DisplayMember = "name"; m_lbox_ds_loi_bill.ValueMember = "value"; //Gán lỗi đã có số tiền m_lbox_ds_loi_tien.DataSource = v_listError_ton_tai_tien; m_lbox_ds_loi_tien.DisplayMember = "name"; m_lbox_ds_loi_tien.ValueMember = "value"; }