public static List <DetailCertificateBLL> getDetailCertificateList(Int32 maphieumuon) { String sql = "SELECT * FROM [sachmuon] INNER JOIN [sach] ON sach.masach = sachmuon.masach INNER JOIN [dausach] ON sach.madausach = dausach.madausach where sachmuon.maphieumuon = " + maphieumuon; DataTable dt = CertificateDAL._condb.getDataTable(sql); List <DetailCertificateBLL> manageCertificateBLLList = new List <DetailCertificateBLL>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DetailCertificateBLL manageCertificateBLL = new DetailCertificateBLL(Int32.Parse(row["masach"].ToString()), row["tensach"].ToString()); manageCertificateBLLList.Add(manageCertificateBLL); } return(manageCertificateBLLList); } else { return(null); } }
public static List<DetailCertificateBLL> getDetailCertificateList(Int32 maphieumuon) { String sql = "SELECT * FROM [sachmuon] INNER JOIN [sach] ON sach.masach = sachmuon.masach INNER JOIN [dausach] ON sach.madausach = dausach.madausach where sachmuon.maphieumuon = "+ maphieumuon; DataTable dt = CertificateDAL._condb.getDataTable(sql); List<DetailCertificateBLL> manageCertificateBLLList = new List<DetailCertificateBLL>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DetailCertificateBLL manageCertificateBLL = new DetailCertificateBLL(Int32.Parse(row["masach"].ToString()), row["tensach"].ToString()); manageCertificateBLLList.Add(manageCertificateBLL); } return manageCertificateBLLList; } else { return null; } }
private void GetSelectedValue() { if (this.dgvCertificateStt.SelectedCells.Count > 0 && this.dgvCertificateStt.CurrentRow.Index < this.dgvCertificateStt.Rows.Count - 1) { int selectedrowindex = this.dgvCertificateStt.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = this.dgvCertificateStt.Rows[selectedrowindex]; DateTime current = new DateTime(); DateTime endtime = new DateTime(); TimeSpan tg; string name = Convert.ToString(selectedRow.Cells["clmnReaderName"].Value); bool ob = Convert.ToBoolean(selectedRow.Cells["clmnObject"].Value); string id = Convert.ToString(selectedRow.Cells["clmnReaderCode"].Value); DateTime daystart = Convert.ToDateTime(selectedRow.Cells["clmnDayStart"].Value); DateTime dayend = Convert.ToDateTime(selectedRow.Cells["clmnDayEnd"].Value); current = DateTime.Now; endtime = Convert.ToDateTime(selectedRow.Cells["clmnDayEnd"].Value); tg = endtime - current; this.txtReaderName.Text = name; this.txtReaderCode.Text = id; this.txtDayStart.Text = daystart.ToShortDateString(); this.txtDayEnd.Text = dayend.ToShortDateString(); if (ob) { this.txtObject.Text = "Cán Bộ Công Nhân Viên"; } else { this.txtObject.Text = "Sinh Viên"; } int songay = Convert.ToInt16(tg.Days); if (songay < 0) { if (selectedRow.Cells["clmnStt"].Value.ToString() != "mới tạo") { this.txtOutOfDay.Text = ""; } else { this.txtOutOfDay.Text = "trễ " + Math.Abs(songay) + " ngày"; } } /*if (id == "") * { * this.btnDelete.Enabled = false; * this.btnSave.Enabled = false; * } * else * { * this.btnDelete.Enabled = true; * this.btnSave.Enabled = true; * }*/ if (this.dgvCertificateStt.SelectedCells.Count > 0 && this.dgvCertificateStt.CurrentRow.Index < this.dgvCertificateStt.Rows.Count - 1) { this.dgvDetailCertificate.Rows.Clear(); DetailCertificateBLL manageCertificateBLL = new DetailCertificateBLL(); List <DetailCertificateBLL> manageCertificateArr = new List <DetailCertificateBLL>(); manageCertificateArr = CertificateDAL.getDetailCertificateList(Convert.ToInt32(selectedRow.Cells["clmnId"].Value)); //MessageBox.Show("ok"); foreach (DetailCertificateBLL row in manageCertificateArr) { this.dgvDetailCertificate.Rows.Add(row.Masach, row.Tensach); } } } else { this.txtReaderName.Text = ""; this.txtReaderCode.Text = ""; this.txtDayStart.Text = ""; this.txtDayEnd.Text = ""; this.txtObject.Text = ""; this.txtOutOfDay.Text = ""; this.dgvDetailCertificate.Rows.Clear(); } }
private void GetSelectedValue() { if (this.dgvCertificateStt.SelectedCells.Count > 0 && this.dgvCertificateStt.CurrentRow.Index < this.dgvCertificateStt.Rows.Count - 1) { int selectedrowindex = this.dgvCertificateStt.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = this.dgvCertificateStt.Rows[selectedrowindex]; DateTime current = new DateTime(); DateTime endtime = new DateTime(); TimeSpan tg; string name = Convert.ToString(selectedRow.Cells["clmnReaderName"].Value); bool ob = Convert.ToBoolean(selectedRow.Cells["clmnObject"].Value); string id = Convert.ToString(selectedRow.Cells["clmnReaderCode"].Value); DateTime daystart = Convert.ToDateTime(selectedRow.Cells["clmnDayStart"].Value); DateTime dayend = Convert.ToDateTime(selectedRow.Cells["clmnDayEnd"].Value); current = DateTime.Now; endtime = Convert.ToDateTime(selectedRow.Cells["clmnDayEnd"].Value); tg = endtime - current; this.txtReaderName.Text = name; this.txtReaderCode.Text = id; this.txtDayStart.Text = daystart.ToShortDateString(); this.txtDayEnd.Text = dayend.ToShortDateString(); if(ob) { this.txtObject.Text = "Cán Bộ Công Nhân Viên"; } else { this.txtObject.Text = "Sinh Viên"; } int songay = Convert.ToInt16(tg.Days); if (songay < 0) { if (selectedRow.Cells["clmnStt"].Value.ToString() != "mới tạo") { this.txtOutOfDay.Text = ""; } else { this.txtOutOfDay.Text = "trễ " + Math.Abs(songay) + " ngày"; } } /*if (id == "") { this.btnDelete.Enabled = false; this.btnSave.Enabled = false; } else { this.btnDelete.Enabled = true; this.btnSave.Enabled = true; }*/ if (this.dgvCertificateStt.SelectedCells.Count > 0 && this.dgvCertificateStt.CurrentRow.Index < this.dgvCertificateStt.Rows.Count - 1) { this.dgvDetailCertificate.Rows.Clear(); DetailCertificateBLL manageCertificateBLL = new DetailCertificateBLL(); List<DetailCertificateBLL> manageCertificateArr = new List<DetailCertificateBLL>(); manageCertificateArr = CertificateDAL.getDetailCertificateList(Convert.ToInt32(selectedRow.Cells["clmnId"].Value)); //MessageBox.Show("ok"); foreach (DetailCertificateBLL row in manageCertificateArr) { this.dgvDetailCertificate.Rows.Add(row.Masach, row.Tensach); } } } else { this.txtReaderName.Text = ""; this.txtReaderCode.Text = ""; this.txtDayStart.Text = ""; this.txtDayEnd.Text = ""; this.txtObject.Text = ""; this.txtOutOfDay.Text = ""; this.dgvDetailCertificate.Rows.Clear(); } }