///
/// 比较两个日期字符串大小
///
///
///
///
public int CompareDate(string dateStr1, string dateStr2)
{
//将日期字符串转换为日期对象
DateTime t1 = Convert.ToDateTime(dateStr1);
DateTime t2 = Convert.ToDateTime(dateStr2);
//通过DateTIme.Compare()进行比较()
int compNum = DateTime.Compare(t1, t2);
return compNum;
}
//按钮加载K线
private void button1_Click(object sender, EventArgs e)
{
int count = int.Parse(this.comboBox1.Text.Trim());
half = count / 2;
string jintian = DateTime.Now.ToShortDateString().ToString();
curdate = jintian;
begindate = jintian;
this.Refresh();
string sql = "select top " + count + " begintime,dayopen,dayclose,dayhigh,daylow from zhy880301 where begintime<='" + jintian + "' order by begintime desc";
huatu(sql, count);
label1.Text = curdate;
}
//画K线的方法
private void huatu(string sql,int num)
{
Graphics g = CreateGraphics();
Pen p = new Pen(Color.Red, 1);//上涨
Pen p1 = new Pen(Color.Green, 1);//下跌
DataSet ds = null;
DataTable dt = null;
ds = db.getds(sql, “mminfo”);
dt = ds.Tables[0];
int width = 1050;
int height = 400;
int Kwidth = width / dt.Rows.Count - 10;
g.DrawRectangle(p, 80, 80, width, height);
//k线开始
Font myFont = new Font(“微软雅黑”, 8);
string begindate1 = null;
string overdate1=dt.Rows[dt.Rows.Count-1][“begintime”].ToString();
overdate =overdate1.Substring(0,overdate1.IndexOf(" “));
string begindate2 = dt.Rows[0][“begintime”].ToString();
begindate = begindate2.Substring(0, begindate2.IndexOf(” "));
decimal high =