コード例 #1
0
ファイル: DateFilter.cs プロジェクト: lycilph/Projects
        public bool IsMatch(Post post)
        {
            switch (Operator)
            {
            case DateOperator.Before: return(Date1.CompareTo(post.Date) > 0);

            case DateOperator.Equal: return(Date1.CompareTo(post.Date) == 0);

            case DateOperator.After: return(Date1.CompareTo(post.Date) < 0);

            case DateOperator.Range: return(Date1.CompareTo(post.Date) < 0 && Date2.CompareTo(post.Date) > 0);
            }
            return(false);
        }
コード例 #2
0
ファイル: frmBook.cs プロジェクト: gvhung/shenzhen_porsche
        //双击新增预约
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!ClsBLL.IsPower("新增预约"))
            {
                MessageBox.Show("你没有权限新增预约!");
                return;
            }
            Colindex = e.ColumnIndex;
            Rowindex = e.RowIndex;
            if (e.RowIndex < 1)
            {
                return;
            }
            DateTime Date1 = DateTime.Parse(label1.Text);
            DateTime Date2;
            string   cellval = dataGridView1.Rows[Rowindex].Cells[0].Value.ToString();

            //if (Rowindex == dataGridView1.Rows.Count)
            //{
            //    Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30);
            //}
            //else
            //{
            //    if (dataGridView1.Rows[Rowindex - 1].Cells[0].Value.ToString() == cellval)
            //    {
            //        Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30);
            //    }
            //    else
            //    {
            Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval);
            //    }
            //}
            if (Date2.CompareTo(DateTime.Now) > 0)
            {
                frmBookNew fm3 = new frmBookNew(Date2, dataGridView1.Columns[e.ColumnIndex].HeaderText);
                fm3.AddCarHandle           += new frmBookNew.AddCar(AddCarCard);
                fm3.UpdateCardHoursdHandle += new frmBookNew.UpdateCardHours(SumWorkHours);
                fm3.Show();
            }
            else
            {
                MessageBox.Show("选择的预约时间不能小于当前时间!");
            }
        }
コード例 #3
0
ファイル: frmBooking.cs プロジェクト: liquanchun/PORSCHE
        private void bt_MouseUp(object sender, MouseEventArgs e)
        {
            if (!ClsBLL.IsPower("更改预约时间"))
            {
                MessageBox.Show("你没有权限更改预约时间!");
                ((Control)sender).Top  = PcStartTop;
                ((Control)sender).Left = PcStartLeft;
                return;
            }
            if (((Control)sender).Tag.ToString() != "预约" && ((Control)sender).Tag.ToString() != "失约")
            {
                ((Control)sender).Top  = PcStartTop;
                ((Control)sender).Left = PcStartLeft;
                return;
            }
            if (IsMove)
            {
                decimal top    = decimal.Parse(Convert.ToString(((Control)sender).Top - dataGridView1.ColumnHeadersHeight));
                decimal height = decimal.Parse(dataGridView1.Rows[0].Height.ToString());
                Rowindex = int.Parse(decimal.Round(top / height, 0).ToString());
                if (Rowindex == -1)
                {
                    Rowindex = 0;
                }
                ((Control)sender).Top = Rowindex * dataGridView1.Rows[0].Height + dataGridView1.ColumnHeadersHeight;
                try
                {
                    if (Rowindex > -1)
                    {
                        //拖动完成之后更改数据库
                        int    cols        = 0;
                        string servicetype = string.Empty;
                        if (((Control)sender).Left >= dataGridView1.Columns[0].Width + dataGridView1.Columns[1].Width)
                        {
                            cols                   = 2;
                            servicetype            = "车身维修";
                            ((Control)sender).Left = dataGridView1.Columns[0].Width + dataGridView1.Columns[1].Width + Cards[Rowindex, cols] * ((Control)sender).Width;
                        }
                        else
                        {
                            cols                   = 1;
                            servicetype            = "机电维修";
                            ((Control)sender).Left = dataGridView1.Columns[0].Width + Cards[Rowindex, cols] * ((Control)sender).Width;
                        }
                        if (PcStartCol == cols && PcStartRow == Rowindex)  //如果移动有效
                        {
                            ((Control)sender).Top  = PcStartTop;
                            ((Control)sender).Left = PcStartLeft;
                        }
                        else
                        {
                            DateTime Date1 = DateTime.Parse(labDateTime.Text);
                            DateTime Date2;
                            string   cellval = dataGridView1.Rows[Rowindex].Cells[0].Value.ToString();
                            Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval);
                            if (Date2.CompareTo(DateTime.Now) < 0)  //拖动之后的时间小于当前时间,不能拖动
                            {
                                ((Control)sender).Top  = PcStartTop;
                                ((Control)sender).Left = PcStartLeft;
                                return;
                            }
                            Cards[Rowindex, cols]         = Cards[Rowindex, cols] + 1;
                            Cards[PcStartRow, PcStartCol] = Cards[PcStartRow, PcStartCol] - 1;

                            if (((Control)sender).Name != string.Empty)
                            {
                                int    recordid  = int.Parse(((Control)sender).Name);
                                string sqlstring = "Update Booking Set BookTime='" + Date2.ToString() + "', ServiceType='" + servicetype + "',State='预约' where ID=" + recordid;   //,DelayBook='延迟预约'
                                SQLDbHelper.ExecuteSql(sqlstring);
                                ((Control)sender).BackColor = Color.Yellow;
                                ((Control)sender).Tag       = "预约";
                            }
                            Button  bt = (Button)((Control)sender);
                            ToolTip tt = new ToolTip();
                            tt.SetToolTip(bt, bt.ImageKey);
                        }
                    }
                }
                catch (Exception Err)
                {
                    MessageBox.Show(Err.Message);
                }
            }
            IsMove = false;
        }
コード例 #4
0
ファイル: frmBook.cs プロジェクト: gvhung/shenzhen_porsche
 private void bt_MouseUp(object sender, MouseEventArgs e)
 {
     if (!ClsBLL.IsPower("更改预约时间"))
     {
         MessageBox.Show("你没有权限更改预约时间!");
         ((Control)sender).Top  = PcStartTop;
         ((Control)sender).Left = PcStartLeft;
         return;
     }
     if (((Control)sender).Tag.ToString() != "预约" && ((Control)sender).Tag.ToString() != "失约")
     {
         //MessageBox.Show("改预约状态为“" + ((Control)sender).Tag.ToString() + "”,不能移动。");
         ((Control)sender).Top  = PcStartTop;
         ((Control)sender).Left = PcStartLeft;
         return;
     }
     if (IsMove)
     {
         //decimal top = decimal.Parse(Convert.ToString(((Control)sender).Top - PcStartTop));
         //decimal height = decimal.Parse(dataGridView1.Rows[0].Height.ToString());
         //Rowindex += int.Parse(decimal.Round(top / height, 0).ToString());
         decimal top    = decimal.Parse(Convert.ToString(((Control)sender).Top - dataGridView1.ColumnHeadersHeight));
         decimal height = decimal.Parse(dataGridView1.Rows[0].Height.ToString());
         Rowindex = int.Parse(decimal.Round(top / height, 0).ToString());
         if (top == 0)//Math.Abs(top - height) <(height * 3/4) ||
         {
             return;
         }
         if (Rowindex == -1)
         {
             Rowindex = 0;
         }
         ((Control)sender).Top = Rowindex * dataGridView1.Rows[0].Height + dataGridView1.ColumnHeadersHeight;
         try
         {
             if (Rowindex > 0)
             {
                 //拖动完成之后更改数据库
                 int      cols  = (((Control)sender).Left - dataGridView1.Columns[0].Width) / dataGridView1.Columns[1].Width + 1;
                 DateTime Date1 = DateTime.Parse(label1.Text);
                 DateTime Date2;
                 string   cellval = dataGridView1.Rows[Rowindex].Cells[0].Value.ToString();
                 Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval);
                 //if (Rowindex == dataGridView1.Rows.Count)
                 //{
                 //    Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30);
                 //}
                 //else
                 //{
                 //    if (dataGridView1.Rows[Rowindex + 1].Cells[0].Value.ToString() == cellval)
                 //    {
                 //        Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval);
                 //    }
                 //    else
                 //    {
                 //        Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30);
                 //    }
                 //}
                 if (Date2.CompareTo(DateTime.Now) < 0)  //拖动之后的时间小于当前时间,不能拖动
                 {
                     ((Control)sender).Top  = PcStartTop;
                     ((Control)sender).Left = PcStartLeft;
                 }
                 string servicetype = dataGridView1.Columns[cols].HeaderText;
                 if (((Control)sender).Name != string.Empty)
                 {
                     int    recordid  = int.Parse(((Control)sender).Name);
                     string sqlstring = "Update Booking Set BookTime='" + Date2.ToString() + "', ServiceType='" + servicetype + "',State='预约',DelayBook='延迟预约' where ID=" + recordid;
                     SQLDbHelper.ExecuteSql(sqlstring);
                     ((Control)sender).BackColor = Color.Yellow;
                     ((Control)sender).Tag       = "预约";
                 }
                 Button  bt = (Button)((Control)sender);
                 ToolTip tt = new ToolTip();
                 tt.SetToolTip(bt, bt.ImageKey);
             }
         }
         catch (Exception Err)
         {
             MessageBox.Show(Err.Message);
         }
     }
     IsMove = false;
 }