//添加车辆预约卡片 private void AddCarCard(string ID, string info, int rowindex) { DoubleClickButton bt = new DoubleClickButton(); string[] strs = info.Split(new Char[] { ',' }); string startdate = strs[4]; decimal hours = decimal.Parse(strs[3]); string plancomdate = strs[5];//计划完成时间 DateTime PlanEndDate = DateTime.Now; if (plancomdate != string.Empty) { PlanEndDate = DateTime.Parse(plancomdate); } else { PlanEndDate = DateTime.Parse(startdate).AddMinutes(double.Parse(Convert.ToString(hours * 60 + ClsBLL.Pausemins(int.Parse(ID), DateTime.Parse(startdate))))); } if (strs[0] == "中断") //如果是中断,则停在做中断操作时的时间点,否则停在按计算计划完成的时间点上 { PlanEndDate = ClsBLL.PauseTime(int.Parse(ID)); } TimeSpan DtSp = PlanEndDate.Subtract(starttime); //计划完成时间和开始时间或计划开始时间的差 int hour = DtSp.Hours; //如果超出了时间范围,显示在最后一列 if (hour > dataGridView1.ColumnCount - 3) { hour = dataGridView1.ColumnCount - 3; } if (hour < 0) { hour = 0; } bt.AccessibleDescription = hour.ToString(); bt.TabIndex = rowindex; Cards[rowindex, hour] = Cards[rowindex, hour] + 1; decimal left = dataGridView1.Columns[0].Width + dataGridView1.Columns[1].Width + dataGridView1.Columns[2].Width * hour; bt.Left = int.Parse(Convert.ToString(Math.Round(left, 0))); int top = rowindex * dataGridView1.Rows[0].Height + dataGridView1.ColumnHeadersHeight + 3; bt.Height = dataGridView1.Rows[0].Height - 6; bt.Width = dataGridView1.Columns[2].Width; bt.Top = top; bt.Tag = strs[0]; //状态 bt.Name = ID; bt.ImageKey = info; dataGridView1.Controls.Add(bt); string planout = strs[7]; if (planout != string.Empty) { planout = DateTime.Parse(planout).ToString("MM-dd HH:mm"); } bt.Text = strs[1] + "\n" + planout; if (strs[8].IndexOf("分单") > -1) { string fendan = string.Empty; if (strs[8].Length > strs[8].IndexOf("分单") + 2) { fendan = strs[8].Substring(strs[8].IndexOf("分单") + 2, 1); if (!ClsBLL.IsNumber(fendan)) { fendan = string.Empty; } } if (fendan == string.Empty) { bt.Text = strs[1] + " 合\n" + planout; } else { bt.Text = strs[1] + " 合" + fendan + "\n" + planout; } } bt.Font = new Font("宋体", 11, FontStyle.Regular); ToolTip tt = new ToolTip(); tt.SetToolTip(bt, strs[strs.Length - 1]); Color cl = Color.PowderBlue; //"正式","已派工", "维修进行中", "中断", "完工", "洗车","过时","延时到明天" if (strs[0] == States[2]) { cl = Color.Green; if (strs[8].IndexOf("返修") > -1) { cl = Color.MediumSeaGreen; } if (strs[8].IndexOf("追加项目") > -1) { cl = Color.OliveDrab; } } if (strs[0] == States[3]) { cl = Color.LightGray; } if (strs[0] == States[4]) { cl = Color.Blue; } if (strs[0] == States[5]) { cl = Color.MediumOrchid; } if (strs[0] == States[6]) { cl = Color.Red; } if (strs[0] == States[7]) { cl = Color.Orange; } bt.BackColor = cl; bt.ContextMenuStrip = contextMenuStrip2; bt.MouseDown += new MouseEventHandler(bt_MouseDown); bt.MouseMove += new MouseEventHandler(bt_MouseMove); bt.MouseUp += new MouseEventHandler(bt_MouseUp); bt.DoubleClick += new EventHandler(bt_DoubleClick); //ChangeWidth(rowindex,hour,bt); }