public enum FrameStatus
{
NotReport = 0,
NormalStatus = 1,
NotNormalstatus = 2
}
but alway FrameStatus.NormalStatus how?
public FrameStatus FrameReportStatus(int Framid, string Timebet)
{
foreach (FrameCam fc in al)
{
if (fc.Timebet == Timebet && fc.IdFrame == Framid)
{
if ((int)fc.status == 1) fc.status = FrameStatus.NormalStatus;
else if ((int)fc.status == 2) fc.status = FrameStatus.NotNormalstatus;
else fc.status = FrameStatus.NotReport;
return fc.status;
}
}
return FrameStatus.NotReport;
}
my complete classs
class FrameCam
{
private ArrayList al = new ArrayList();
public string strConnect;
public FrameStatus status = FrameStatus.NormalStatus;
public string Timebet;
public int IdFrame;
public FrameCam()
{
}
public FrameCam(string st, string bt)
{
strConnect = st;
Timebet = bt;
LoadtoList();
}
public FrameStatus GetFramStatus(int Framid, string timebet)
{
foreach (FrameCam fc in al)
{
if (Framid == fc.IdFrame && timebet == fc.Timebet)
{
return fc.status;
}
}
return FrameStatus.NotReport;
}
private void LoadtoList()
{
SqlConnection conn = null;
SqlDataReader sr = null;
try
{
string query =
"SELECT * FROM FrameReport WHERE convert(varchar, GETDATE(), 101) = convert(varchar, DateTimeSign, 101) AND TimeSignBeetWeen='" +this.Timebet+"'";
conn = new SqlConnection(this.strConnect);
conn.Open();
SqlCommand sc = new SqlCommand();
sc.CommandText = query;
sc.Connection = conn;
sr = sc.ExecuteReader();
while (sr.Read())
{
FrameCam fc = new FrameCam();
fc.Timebet = sr["TimeSignBeetWeen"].ToString();
fc.IdFrame = (int)sr["IdFrame"];
if ((int)sr["Status"] == (int)FrameStatus.NormalStatus)
{
status = FrameStatus.NormalStatus;
}
if ((int)sr["Status"] == (int)FrameStatus.NotNormalstatus)
{
status = FrameStatus.NotNormalstatus;
}
else status = FrameStatus.NotReport;
al.Add(fc);
}
}
catch (Exception)
{
}
finally
{
if (sr != null) sr.Close();
if (conn != null) conn.Close();
}
}
public FrameStatus FrameReportStatus(int Framid, string Timebet)
{
foreach (FrameCam fc in al)
{
if (fc.Timebet == Timebet && fc.IdFrame == Framid)
{
if ((int)fc.status == 1) fc.status = FrameStatus.NormalStatus;
else if ((int)fc.status == 2) fc.status = FrameStatus.NotNormalstatus;
else fc.status = FrameStatus.NotReport;
return fc.status;
}
}
return FrameStatus.NotReport;
}
}