private void save_data_in_grid(GridView ip_grv) { GridViewRow[] v_arr_gvr = new GridViewRow[ip_grv.Rows.Count]; System.Web.UI.WebControls.TextBox v_txt_so_chua_giai_ngan_cho_nha_thau; System.Web.UI.WebControls.TextBox v_txt_gia_tri_thuc_hien_da_nghiem_thu; LinkButton v_lb_id_gd; ip_grv.Rows.CopyTo(v_arr_gvr, 0); for (int i = 0; i < v_arr_gvr.Length; i++) { //1. Duyet tung dong cua gridview, lay du lieu tu textbox v_txt_gia_tri_thuc_hien_da_nghiem_thu = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_so_tien_ngan_sach_grid"); v_txt_so_chua_giai_ngan_cho_nha_thau = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_so_tien_quy_bao_tri_grid"); v_lb_id_gd = (LinkButton)v_arr_gvr[i].FindControl("m_lbl_delete"); if (v_lb_id_gd.CommandArgument.ToString().Equals("") | v_lb_id_gd.CommandArgument.ToString().Equals("-1")) { continue; } else { try { //update du lieu vao csdl US_GD_KHOI_LUONG v_us = new US_GD_KHOI_LUONG(CIPConvert.ToDecimal(v_lb_id_gd.CommandArgument.ToString())); v_us.dcSO_TIEN_DA_NGHIEM_THU = WinFormControls.get_so_tien(v_txt_gia_tri_thuc_hien_da_nghiem_thu.Text); v_us.dcSO_TIEN_CHUA_GIAI_NGAN = WinFormControls.get_so_tien(v_txt_so_chua_giai_ngan_cho_nha_thau.Text); v_us.Update(); } catch (Exception) { m_lbl_mess_grid.Text = "Đã có lỗi xảy ra, Xin vui lòng thực hiện lại thao tác"; m_lbl_mess_grid.Focus(); return; } } } m_lbl_mess_grid.Text = "Đã ghi dữ liệu thành công!"; load_data_to_grid(); m_lbl_mess_grid.Focus(); }
private void load_data_to_grid(decimal ip_id_quyet_dinh, decimal ip_id_loai_nhiem_vu = -1, decimal ip_id_cong_trinh = -1, decimal ip_id_du_an = -1) { if (!CValidateTextBox.IsValid(m_txt_ngay_thang, DataType.DateType, allowNull.NO)) { m_lbl_mess_qd.Text = "Bạn phải nhập ngày tháng (dd/MM/yyyy)"; return; } var v_dat_now = CIPConvert.ToDatetime(m_txt_ngay_thang.Text.Trim(), "dd/MM/yyyy"); ; //0. Chuan bi du lieu input if (ip_id_quyet_dinh != -1) { US_DM_QUYET_DINH v_us_qd = new US_DM_QUYET_DINH(ip_id_quyet_dinh); v_dat_now = v_us_qd.datNGAY_THANG; } DateTime v_dat_dau_nam = v_dat_now.AddDays(-v_dat_now.Day + 1); v_dat_dau_nam = v_dat_dau_nam.AddMonths(-v_dat_dau_nam.Month + 1); DateTime v_dat_cuoi_nam = v_dat_dau_nam.AddYears(1); //1. Update noi dung chi tu Giao kh sang Giao von US_GD_KHOI_LUONG v_us_khoi_luong = new US_GD_KHOI_LUONG(); v_us_khoi_luong.update_noi_dung_chi_from_giao_kh_sang_khoi_luong( v_dat_dau_nam , v_dat_cuoi_nam , v_dat_now , CIPConvert.ToDecimal(m_ddl_don_vi.SelectedValue)); //2. Load data tu grid_giao_von len luoi de sua thong tin DS_GRID_GIAO_VON v_ds = new DS_GRID_GIAO_VON(); US_GRID_GIAO_VON v_us = new US_GRID_GIAO_VON(); v_us.get_grid_khoi_luong(v_ds , CIPConvert.ToDecimal(m_ddl_don_vi.SelectedValue) , v_dat_now , CIPConvert.ToDecimal(m_ddl_loai_nhiem_vu.SelectedValue)); m_grv.DataSource = v_ds.Tables[0]; m_grv.DataBind(); if (!m_hdf_id_giao_kh.Value.Equals("")) { m_grv.SelectedIndex = -1; for (int i = 0; i < m_grv.Rows.Count; i++) if (CIPConvert.ToDecimal(m_grv.DataKeys[i].Value) == CIPConvert.ToDecimal(m_hdf_id_giao_kh.Value)) m_grv.SelectedIndex = i; } }