private void btnClearScanRecord_Click(object sender, EventArgs e) { FrmParent.ParentForm.ResetReturnDelay(); if (CheckPDAPassword("040506")) { try { int sum = 0; DateTime dtStart = DateTime.Now; DateTime dtEnd = DateTime.Now; OptRecordServer.GetOptCount(out sum, ref dtStart, ref dtEnd); if (sum == 0) { MessageBox.Show("没有待清除的记录!"); return; } DialogResult dr = MessageBox.Show(string.Format("共{0}条操作记录:时间从{1}至{2}.", sum, dtStart.ToString("yyyy-MM-dd HH:mm:ss"), dtEnd.ToString("yyyy-MM-dd HH:mm:ss")), "确定要清除所有操作记录吗?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dr == DialogResult.Yes) { OptRecordServer.ClearOptRecord(); MessageBox.Show("清除成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void DeleteScanRecord() { try { FrmParent.ParentForm.ResetReturnDelay(); //int sum = 0; string dtStart = dtpStart.Value.ToString("yyyy-MM-dd HH:mm:ss"); string dtEnd = dtpEnd.Value.ToString("yyyy-MM-dd HH:mm:ss"); //OptRecordServer.GetOptCount(out sum, ref dtStart, ref dtEnd); //if (sum == 0) //{ // MessageBox.Show("没有待清除的记录!"); // return; //} if (string.IsNullOrEmpty(dtStart) && string.IsNullOrEmpty(dtEnd)) { return; } DialogResult dr = MessageBox.Show(string.Format("确定要删除{0}到{1}的信息?", dtStart, dtEnd), "确定要清除操作记录吗?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dr == DialogResult.Yes) { OptRecordServer.ClearOptRecordTime(dtStart, dtEnd); MessageBox.Show("清除成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 保存操作记录 /// </summary> /// <param name="optType">操作类型</param> /// <param name="content">操作内容</param> public static void SaveOptRecord(string optType, string content, DateTime orderTime, string number, int customerId) { if (!string.IsNullOrEmpty(optType) && (optType.Contains("重复扫描") || optType.Contains("扫描前请选择"))) { return; } OptRecord record = new OptRecord(); record.OptTime = orderTime.ToString("yyyy-MM-dd HH:mm:ss"); record.OptType = optType; record.Content = content.Replace("'", "''"); record.OptNumber = number; record.OptCustomerId = customerId; record.OptTypeId = GetOptTypeId(optType); OptRecordServer.AddOptRecord(record); }