private void getSoLaoDongDuBao(int i, int check) { String matruong = dgvTruong.Rows[i].Cells["ma_truong"].Value.ToString(); if (dgvTruong.Rows[i].Cells["du_bao_tuyen_sinh"].Value.ToString() == "0") { DAL_TS ts = new DAL_TS(); List <DTO_CT> listCt = ts.getListTS(matruong); int n = listCt.Count; int dubao_ts = 0; if (n != 0) { dubao_ts = bptoithieu(listCt, n, nam); } dgvTruong.Rows[i].Cells["du_bao_tuyen_sinh"].Value = dubao_ts; double tile = 0; if (dgvTruong.Rows[i].Cells["ti_le_do"].Value != null) { tile = Convert.ToDouble(dgvTruong.Rows[i].Cells["ti_le_do"].Value.ToString()); } else { dgvTruong.Rows[i].Cells["ti_le_do"].Value = 0; } int dubao = (int)(dubao_ts * tile) / 100; if (check == 1) { object du_bao = dgvTruong.Rows[i].Cells["so_lao_dong"].Value; if (du_bao != null) { dgvTruong.Rows[i].Cells["so_lao_dong"].Value = dubao; DAL_DuBao dbcung = new DAL_DuBao(); DTO_DuBao dbao = new DTO_DuBao(matruong, (float)tile, dubao, nam, (int)dubao_ts); dbcung.updateDuBaoCung(dbao); } else { dgvTruong.Rows[i].Cells["so_lao_dong"].Value = dubao; DAL_DuBao dbcung = new DAL_DuBao(); DTO_DuBao dbao = new DTO_DuBao(matruong, (float)tile, dubao, nam, (int)dubao_ts); dbcung.addDuBaoCung(dbao); } } else { dgvTruong.Rows[i].Cells["so_lao_dong"].Value = dubao; } } }
private string checkTiLeDo(int i, int check) { if (check == 1) { object ti_le_do = dgvTruong.Rows[i].Cells["ti_le_do"].Value; if (ti_le_do == null) { string ma_truong = dgvTruong.Rows[i].Cells["ma_truong"].Value.ToString(); int chi_tieu = (int)dgvTruong.Rows[i].Cells["du_bao_tuyen_sinh"].Value; dgvTruong.Rows[i].Cells["ti_le_do"].Value = 0; dgvTruong.Rows[i].Cells["so_lao_dong"].Value = 0; DAL_DuBao dbcung = new DAL_DuBao(); DTO_DuBao dbao = new DTO_DuBao(ma_truong, 0, 0, nam, chi_tieu); dbcung.addDuBaoCung(dbao); return(ma_truong); } else { if (ti_le_do.ToString().Equals("0")) { string ma_truong = dgvTruong.Rows[i].Cells["ma_truong"].Value.ToString(); return(ma_truong); } } } else { object ti_le_do = dgvTruong.Rows[i].Cells["ti_le_do"].Value; if (ti_le_do == null) { string ma_truong = dgvTruong.Rows[i].Cells["ma_truong"].Value.ToString(); int chi_tieu = (int)dgvTruong.Rows[i].Cells["du_bao_tuyen_sinh"].Value; dgvTruong.Rows[i].Cells["ti_le_do"].Value = 0; dgvTruong.Rows[i].Cells["so_lao_dong"].Value = 0; return(ma_truong); } else { if (ti_le_do.ToString().Equals("0")) { string ma_truong = dgvTruong.Rows[i].Cells["ma_truong"].Value.ToString(); return(ma_truong); } } } return(""); }
private void getSoLaoDong(int i, string MaTruong, double TiLe, int check) { String ma_truong = dgvTruong.Rows[i].Cells["ma_truong"].Value.ToString(); if (ma_truong.Equals(MaTruong)) { double chi_tieu = Convert.ToDouble(dgvTruong.Rows[i].Cells["du_bao_tuyen_sinh"].Value.ToString()); int dubao = (int)(chi_tieu * TiLe) / 100; if (check == 1) { DAL_DuBao dbcung = new DAL_DuBao(); object tile = dgvTruong.Rows[i].Cells["ti_le_do"].Value; object db = dgvTruong.Rows[i].Cells["so_lao_dong"].Value; if (tile == null && db == null) { dgvTruong.Rows[i].Cells["ti_le_do"].Value = TiLe; dgvTruong.Rows[i].Cells["so_lao_dong"].Value = dubao; DTO_DuBao dbao = new DTO_DuBao(ma_truong, (float)TiLe, dubao, nam, (int)chi_tieu); dbcung.addDuBaoCung(dbao); } else { dgvTruong.Rows[i].Cells["ti_le_do"].Value = TiLe; dgvTruong.Rows[i].Cells["so_lao_dong"].Value = dubao; DTO_DuBao dbao = new DTO_DuBao(ma_truong, (float)TiLe, dubao, nam, (int)chi_tieu); dbcung.updateDuBaoCung(dbao); } } else { dgvTruong.Rows[i].Cells["ti_le_do"].Value = TiLe; dgvTruong.Rows[i].Cells["so_lao_dong"].Value = dubao; } } }
private void btnAdd_Click(object sender, EventArgs e) { string ma_truong = txtMaTruong.Text, ten_truong = txtTenTruong.Text, dia_chi = txtDiaChi.Text, website = txtWebsite.Text, tinh_thanh = txtTinhThanh.Text, dv_chu_quan = txtDvChuQuan.Text; string nb_2014 = txtNam2014.Text, nb_2015 = txtNam2015.Text, nb_2016 = txtNam2016.Text, nb_2017 = txtNam2017.Text; List <String> ls_nb = new List <string>(); ls_nb.Add(nb_2014); ls_nb.Add(nb_2015); ls_nb.Add(nb_2016); ls_nb.Add(nb_2017); List <DTO_TS> ls_ts = new List <DTO_TS>(); DTO_Truong truong = new DTO_Truong(ma_truong, ten_truong, dia_chi, website, tinh_thanh, dv_chu_quan); AC_Truong action = new AC_Truong(); DAL_DuBao dubao = new DAL_DuBao(); List <int> ls_nam = dubao.getNamDuBaoCung(); foreach (int nam in ls_nam) { DTO_DuBao db = new DTO_DuBao(ma_truong, 0, 0, nam, 0); dubao.addDuBaoCung(db); } string token = action.checkListString(ls_nb); if (token != "OK") { MessageBox.Show(token); } else { DAL_Truong dal = new DAL_Truong(); if (dal.checkMatruong(ma_truong)) { DTO_TS ts_2014 = new DTO_TS(ma_truong, 2014, Int32.Parse(nb_2014)); DTO_TS ts_2015 = new DTO_TS(ma_truong, 2015, Int32.Parse(nb_2015)); DTO_TS ts_2016 = new DTO_TS(ma_truong, 2016, Int32.Parse(nb_2016)); DTO_TS ts_2017 = new DTO_TS(ma_truong, 2017, Int32.Parse(nb_2017)); ls_ts.Add(ts_2014); ls_ts.Add(ts_2015); ls_ts.Add(ts_2016); ls_ts.Add(ts_2017); if (action.add_Truong(truong, ls_ts)) { MessageBox.Show("\t\t Thêm thành công.\nVui lòng nhập tỉ lệ tốt nghiệp trong file TiLeTotNghiep.xlsx"); AddTruong view = new AddTruong(); view.Show(); } } else { MessageBox.Show("Mã trường đã tồn tại"); } } }