프로젝트 지식 요약
12655 단어 총결산
private DataTable ListToDataTable(List<Tellyes.Model.QuestionOption> QuestionOptionList)
{
DataTable dt = new DataTable();
if (QuestionOptionList.Count > 0)
{
PropertyInfo[] propertys = QuestionOptionList[0].GetType().GetProperties();
foreach (PropertyInfo pi in propertys)
{
System.Type colType = pi.PropertyType;
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable<>)))//
{
colType = pi.PropertyType.GetGenericArguments()[0];
}
dt.Columns.Add(pi.Name, colType);
}
for (int i = 0; i < QuestionOptionList.Count; i++)
{
ArrayList al = new ArrayList();
foreach (PropertyInfo pi in propertys)
{
object obj = pi.GetValue(QuestionOptionList[i], null);
al.Add(obj);
}
object[] array = al.ToArray();
dt.LoadDataRow(array, true);
}
}
return dt;
}
2. 조회excel표를 데이터셋에 추가
public DataSet ExecleDs(string filenameurl)
{
string strConn = "Provider=Microsoft.ACE.OleDb.12.0;" + "data source=" + filenameurl + ";Extended Properties='Excel 12.0; HDR=YES; IMEX=1'";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataSet ds = new DataSet();
string strSql = string.Format("SELECT * FROM [{0}$]", "Sheet1");
OleDbDataAdapter odda = new OleDbDataAdapter(strSql, conn);
odda.Fill(ds, "hou");
return ds;
}
3. 서버에 파일을 업로드: 모든 작업이 백그라운드에 있음
string clientIP = "192.168.4.22";
string serverIP = "192.168.4.22";
string clientFilesName = "shangchuan";
string serverFilesName = @"QuestionUploadFile\" + userName;
string fileName = "111.flv";
string clientPath = @"\\" + clientIP + "\\" + clientFilesName + "\\" + fileName;
string serverPath = @"\\" + serverIP + "\\" + serverFilesName + "\\" + fileName;
System.IO.File.Copy(clientPath, serverPath,true );
전제는 파일 shangchuan,QuestionUploadFile를 공유 속성을 설정하는 동시에 보안 속성에 있어 목표 기기의 권한을 증가시키는 것이다.
4. DataTable 정렬 처리
인스턴스:
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("id", typeof(int)));
dt.Columns.Add(new DataColumn("name", typeof(string )));
dt.Columns.Add(new DataColumn("age", typeof(int)));
for (int i = 0; i < 5; i++)
{
DataRow dr = dt.NewRow();
dr["id"] = i;
dr["name"] = i + "jim";
dr["age"] = 10 - i;
dt.Rows.Add(dr);
}
DataView dv = dt.DefaultView;
dv.Sort = "age Asc";
DataTable dt2 = dv.ToTable();
5、정규 판별 사용
private void txtNumber_TextChanged(object sender, TextChangedEventArgs e)
{
e.Handled = System.Text.RegularExpressions.Regex.IsMatch(txtNumber.Text, @"^-?[0-9]\d*$");
if (txtNumber.Text != "admin")
{
if (e.Handled == false && txtNumber.Text != "")
{
CustomMessageBox.CustomMessageBox.ShowBox(" ![0~9]", " ");
txtNumber.Text = "";
Keyboard.Focus(txtNumber);
return;
}
}
}
public static bool checkString(string source)
{
Regex regExp = new Regex("[~!@#$%^&*()=+[\\]{}''\";:/?.,><`|!·¥…—()\\-、;:。,》《]");
return !regExp.IsMatch(source);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
클릭 이벤트의 누적 귀속, 클릭 한 번, 여러 번 실행최근에 업무상 클릭 이벤트가 누적되는 문제에 부딪혔다. 요소에 클릭 이벤트 효과를 추가하지만 항상 효과가 실패한다. 마지막으로 클릭 이벤트가 여러 차례 실행된 것을 발견했다. 인터넷에서 찾아봤는데 다음은 이 문제를 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.