public SoundReadConfig BuildModel() { SoundReadConfig model = null; try { if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("Lỗi: Tên cấu hình không được để trống"); } else { model = new SoundReadConfig(); model.Id = idReadNSConfig; model.Name = txtName.Text; model.Description = txtDescription.Text; model.IsActive = chkIsActive.Checked; model.IdChuyen = idChuyen; model.ConfigType = configType; if (dgListItem.Rows != null && dgListItem.Rows.Count > 0) { foreach (DataGridViewRow row in dgListItem.Rows) { SoundReadItem item = new SoundReadItem(); item.IntType = int.Parse(row.Cells["IndexTypeSelect"].Value.ToString()); if (item.IntType == 0) { item.IdIntConfig = int.Parse(row.Cells["IdObj"].Value.ToString()); } else { item.IsSound = int.Parse(row.Cells["IdObj"].Value.ToString()); } item.OrderIndex = int.Parse(row.Cells["ThuTuDoc"].Value.ToString()); item.IsActive = bool.Parse(row.Cells["IsActiveOfDetail"].Value.ToString()); model.listItem.Add(item); } } } } catch (Exception ex) { throw ex; } return(model); }
public SoundReadConfig GetInfoById(int Id) { SoundReadConfig config = null; try { string sqlSelectConfig = "select * from SOUND_ReadConfig where Id=" + Id + " and IsDeleted=0;"; DataTable dt = dbclass.TruyVan_TraVe_DataTable(sqlSelectConfig); if (dt != null && dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; config = new SoundReadConfig(); config.Id = int.Parse(row["Id"].ToString()); config.Name = row["Name"].ToString(); config.Description = row["Description"].ToString(); bool isActive = false; bool.TryParse(row["IsActive"].ToString(), out isActive); config.IsActive = isActive; string sqlSelectListItem = "select * from SOUND_ReadConfigDetail where IdReadConfig=" + config.Id + " and IsDeleted=0"; DataTable dtList = dbclass.TruyVan_TraVe_DataTable(sqlSelectListItem); if (dtList != null && dtList.Rows.Count > 0) { foreach (DataRow rowItem in dtList.Rows) { SoundReadItem item = new SoundReadItem(); item.IntType = int.Parse(rowItem["IntType"].ToString()); item.OrderIndex = int.Parse(rowItem["OrderIndex"].ToString()); item.IsSound = int.Parse(rowItem["IdSound"].ToString()); item.IdIntConfig = int.Parse(rowItem["IdIntConfig"].ToString()); bool isActiveItem = false; bool.TryParse(rowItem["IsActive"].ToString(), out isActiveItem); item.IsActive = isActiveItem; config.listItem.Add(item); } } } } catch (Exception ex) { throw ex; } return(config); }