Beispiel #1
0
        private void btn_DeleteData_Click(object sender, EventArgs e)
        {
            //if (Gloabl.Userinfo.Level != EM_UserType.Admin)
            //{
            //    XtraMessageBox.Show("只有管理员才能删除数据");
            //    return;
            //}

            if (comboBoxEdit_ID.Text.Trim() == string.Empty)
            {
                XtraMessageBox.Show("请先查询数据");
                return;
            }
            TimeSpan ts  = dateEdit_End.DateTime - dateEdit_Start.DateTime;
            TimeSpan ts1 = new TimeSpan(0, 0, 0, 1);

            if (ts < ts1)
            {
                XtraMessageBox.Show("请先查询数据");
                return;
            }
            if (XtraMessageBox.Show("数据将要被删除,是否继续", "注意", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }
            Equipment eq = mainList.Find(c => c.Address == Convert.ToInt64(comboBoxEdit_ID.Text));

            int total = EquipmentDataDal.DeleteByTime(eq.ID, dateEdit_Start.DateTime, dateEdit_End.DateTime);

            gridControl_History.DataSource = null;
            chartControl_History.Series[0].Points.Clear();
            XtraMessageBox.Show(string.Format("本次删除{0}条数据", total));
        }
Beispiel #2
0
        // 删除所查数据
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkedComboBoxEdit1.Text.Trim() == string.Empty)
                {
                    XtraMessageBox.Show("请先查询数据");
                    return;
                }
                TimeSpan ts  = dateEdit2.DateTime - dateEdit1.DateTime;
                TimeSpan ts1 = new TimeSpan(0, 0, 0, 1);
                if (ts < ts1)
                {
                    XtraMessageBox.Show("请先查询数据");
                    return;
                }
                if (XtraMessageBox.Show("数据将要被删除,是否继续", "注意", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }
                int total = 0;
                foreach (CheckedListBoxItem item in checkedComboBoxEdit1.Properties.Items)
                {
                    if (item.CheckState == CheckState.Checked)
                    {
                        Equipment eq = mainList.Find(c => c.ID == Convert.ToInt32(item.Value));

                        total += EquipmentDataDal.DeleteByTime(eq.ID, dateEdit1.DateTime, dateEdit2.DateTime);
                    }
                }

                gridControl2.DataSource = null;
                chartControl2.Series.Clear();
                XtraMessageBox.Show(string.Format("本次删除{0}条数据", total));
            }
            catch (Exception ex)
            {
                LogLib.Log.GetLogger(this).Warn(ex);
            }
        }