private void btn_them_Click(object sender, EventArgs e) { for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { string id_sim = dataGridView1.Rows[i].Cells["IDSIM"].Value.ToString(); DateTime Tgbd = DateTime.Parse(dataGridView1.Rows[i].Cells["TGBD"].Value.ToString()); DateTime Tgkt = DateTime.Parse(dataGridView1.Rows[i].Cells["TGKT"].Value.ToString()); DateTime TGBD = DateTime.Parse(dataGridView1.Rows[i].Cells["TGBD"].Value.ToString()); DateTime TGKT = DateTime.Parse(dataGridView1.Rows[i].Cells["TGKT"].Value.ToString()); TimeSpan tmp = TGKT - TGBD; int sophut = tmp.Hours * 60 + tmp.Minutes; int Sophutsudung = sophut; int Cuocphi = TinhCuoc(TGBD, TGKT, sophut); //ctsd.ID = maxid; DTO_CTSD ctsd = new DTO_CTSD(id_sim, Tgbd, Tgkt, Sophutsudung, Cuocphi); bctsd.Insert_ctsd(ctsd); } }
public bool Insert_CTSD(DTO_CTSD dct) { string sql = "Insert into " + table + " values('" + dct.Id_sim + "','" + dct.Tgbd.ToString("yyyy-MM-dd HH:mm:ss") + "','" + dct.Tgkt.ToString("yyyy-MM-dd HH:mm:ss") + "','" + dct.Sophutsudung + "','" + dct.Cuocphi + "')"; return(Update(sql)); }
public bool Insert_ctsd(DTO_CTSD dcs) { return(dalcs.Insert_CTSD(dcs)); }