Example #1
0
 public ActionResult Edit(DailyEntity model)
 {
     model.UserId     = Account.UserId;
     model.CreateTime = DateTime.Now;
     model.UpdateTime = DateTime.Now;
     return(Json(new { result = _service.Update(model) > 0 }));
 }
Example #2
0
 private void btnDel_All_Click(object sender, EventArgs e)
 {
     if (dgvAll.SelectedRows.Count > 0)
     {
         DataGridViewSelectedRowCollection selectedRows = dgvAll.SelectedRows;
         if (selectedRows[0].Cells["colRemindFlag_ALL"].Value.ToString() == "未处理" && MessageHandle.MessageAsk("注意:该日程还没执行!\n确定要删除该日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDailyById(selectedRows[0].Cells[0].Value.ToString());
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity = null;
                 ClearForm();
             }
             dgvAll.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
         else if (selectedRows[0].Cells["colRemindFlag_ALL"].Value.ToString() == "已处理" && MessageHandle.MessageAsk("确定要删除该日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDailyById(selectedRows[0].Cells[0].Value.ToString());
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity = null;
                 ClearForm();
             }
             dgvAll.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
     }
 }
Example #3
0
        public int Insert(DailyEntity model)
        {
            string sql = @"INSERT INTO [Daily]
                                       ([UserId]
                                       ,[DailyDate]
                                       ,[Title]
                                       ,[Summary]
                                       ,[CreateTime]
                                       ,[UpdateTime])
                                 VALUES
                                       (@UserId 
                                       ,@DailyDate
                                       ,@Title
                                       ,@Summary
                                       ,GETDATE()
                                       ,GETDATE())";

            return(Execute(OpenMsSqlConnection(), sql, new
            {
                UserId = model.UserId,
                DailyDate = model.DailyDate.Date,
                Title = model.Title,
                Summary = model.Summary
            }));
        }
Example #4
0
 public ActionResult Add(DailyEntity model)
 {
     model.UserId = Account.UserId;
     //model.DailyDate = model.DailyDate.Date;
     model.DailyDate  = DateTime.Now.Date;
     model.CreateTime = DateTime.Now;
     model.UpdateTime = DateTime.Now;
     return(Json(new { result = (_service.Count(DateTime.Now) <= 0 ? _service.Insert(model) : _service.Update(model)) > 0 }));
 }
Example #5
0
 /// <summary>
 /// 日程实例
 /// </summary>
 /// <param name="dailyEntity"></param>
 public FrmRemind(DailyEntity dailyEntity)
 {
     InitializeComponent();
     _strMusicPath = dailyEntity.D_REMIND_MUSIC_PATH;
     _strSolar     = dailyEntity.D_SOLAR_CALENDAR;
     _strLunar     = dailyEntity.D_LUNAR_CALENDAR;
     _strContent   = dailyEntity.D_CONTENT;
     _strID        = dailyEntity.ID;
     _strLevel     = dailyEntity.D_LEVEL;
 }
Example #6
0
 public void SubmitForm(DailyEntity DailyEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         DailyEntity.Modify(keyValue);
         service.Update(DailyEntity);
     }
     else
     {
         DailyEntity.Create();
         service.Insert(DailyEntity);
     }
 }
Example #7
0
        public int Update(DailyEntity model)
        {
            string sql = @"UPDATE [Daily]
                                           SET [Title] = @Title
                                              ,[Summary] = @Summary
                                              ,[UpdateTime] = GETDATE()
                                         WHERE Id = @Id";

            return(Execute(OpenMsSqlConnection(), sql, new
            {
                Id = model.Id,
                Title = model.Title,
                Summary = model.Summary
            }));
        }
Example #8
0
 private void btnDeleteAll_All_Click(object sender, EventArgs e)
 {
     if (dgvAll.Rows.Count > 0)
     {
         bool bHasToDo = false;
         if (dgvAll.Rows[0].Cells[5].Value.ToString() == "未处理")
         {
             bHasToDo = true;
         }
         if (bHasToDo && MessageHandle.MessageAsk("注意:有日程事务还没执行!\n确定要删除所有日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDailyOfAll();
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvAll.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsAll.Tables[0].Rows.Clear();
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
         else if (!bHasToDo && MessageHandle.MessageAsk("确定要删除所有日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDidDailyOfAll();
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvAll.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsAll.Tables[0].Rows.Clear();
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
     }
 }
Example #9
0
 private void btnDelDidToday_Click(object sender, EventArgs e)
 {
     if (dgvDidToday.SelectedRows.Count > 0 && MessageHandle.MessageAsk("确定要删除该日程事务?", "确定删除") == DialogResult.OK)
     {
         DataGridViewSelectedRowCollection selectedRows = dgvDidToday.SelectedRows;
         if (BusAdminDaily.DeleteDailyById(selectedRows[0].Cells[0].Value.ToString()))
         {
             if (_dailyEntity != null && _dailyEntity.ID == selectedRows[0].Cells[0].Value.ToString())
             {
                 _dailyEntity = null;
                 ClearForm();
             }
             dgvDidToday.Rows.Remove(selectedRows[0]);
             MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         }
     }
 }
Example #10
0
 private void btnAddDaily_Click(object sender, EventArgs e)
 {
     if (operType == 1)
     {
         if (MessageHandle.MessageAsk("增加将会丢失修改数据,确定要执行增加操作?", "确定增加") == DialogResult.OK)
         {
             ClearForm();
             cboLevel.Select();
         }
     }
     else
     {
         if (IsValid())
         {
             _dailyEntity                     = new DailyEntity();
             _dailyEntity.D_CONTENT           = rtbContent.Text;
             _dailyEntity.D_REMIND_MUSIC_PATH = txtMusicPath.Text;
             string grade;
             if (chkLunar.Checked)
             {
                 _dailyEntity.D_LUNAR_CALENDAR = dtpTime.Value.ToString();
                 ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value.Date, false);
                 DateTime            solar     = cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second));
                 _dailyEntity.D_SOLAR_CALENDAR = solar.ToString();
                 grade = BusAdminDaily.CalculateGrade(solar);
                 _dailyEntity.D_LEVEL = grade;
             }
             else
             {
                 _dailyEntity.D_SOLAR_CALENDAR = dtpTime.Value.ToString();
                 grade = BusAdminDaily.CalculateGrade(dtpTime.Value);
                 _dailyEntity.D_LEVEL = grade;
             }
             if (BusAdminDaily.AddDaily(_dailyEntity))
             {
                 ClearForm();
                 _dailyEntity = null;
                 BindAll();
                 if (MessageHandle.MessageInfo("恭喜,增加成功!", "提示信息") == DialogResult.OK)
                 {
                     BusAdminDaily.InitTodayUnDoDaily();
                 }
             }
         }
     }
 }
Example #11
0
        /// <summary>
        /// 构造当日未完成事务
        /// </summary>
        public static void InitTodayUnDoDaily()
        {
            DataSet ds = QueryDailyOfToday(false);

            if (ds != null)
            {
                //锁定LST_TODAY_UNDO_DAILY,防止自动提升线程调用
                lock (GlobalVariable.LST_TODAY_UNDO_DAILY)
                {
                    GlobalVariable.LST_TODAY_UNDO_DAILY.Clear();
                    DailyEntity dailyEntity;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dailyEntity = new DailyEntity(dr);
                        GlobalVariable.LST_TODAY_UNDO_DAILY.Add(dailyEntity);
                    }
                }
            }
        }
Example #12
0
        /// <summary>
        /// 添加一个日程事务
        /// </summary>
        /// <param name="dailyEntity">日程事务实体</param>
        /// <returns></returns>
        public static bool AddDaily(DailyEntity dailyEntity)
        {
            string sql = "";

            if (dailyEntity.D_LUNAR_CALENDAR == null || dailyEntity.D_LUNAR_CALENDAR == "")
            {
                sql = "insert into daily(D_SOLAR_CALENDAR,D_CONTENT,D_REMIND_MUSIC_PATH,D_LEVEL) values(#{0}#,'{1}','{2}',{3})";
                sql = string.Format(sql, dailyEntity.D_SOLAR_CALENDAR, dailyEntity.D_CONTENT, dailyEntity.D_REMIND_MUSIC_PATH, dailyEntity.D_LEVEL);
            }
            else
            {
                sql = "insert into daily(D_SOLAR_CALENDAR,D_LUNAR_CALENDAR,D_CONTENT,D_REMIND_MUSIC_PATH,D_LEVEL) values(#{0}#,#{1}#,'{2}','{3}',{4})";
                sql = string.Format(sql, dailyEntity.D_SOLAR_CALENDAR, dailyEntity.D_LUNAR_CALENDAR, dailyEntity.D_CONTENT, dailyEntity.D_REMIND_MUSIC_PATH, dailyEntity.D_LEVEL);
            }
            if (DBManager.ExecuteNonQuery(sql) == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #13
0
 private void btnClearDidToday_Click(object sender, EventArgs e)
 {
     if (dgvDidToday.SelectedRows.Count > 0 && MessageHandle.MessageAsk("确定要删除当日所有已处理日程事务?", "确定删除") == DialogResult.OK)
     {
         if (BusAdminDaily.DeleteDailyOfToday())
         {
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvDidToday.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsDidToday.Tables[0].Rows.Clear();
             MessageHandle.MessageInfo("恭喜,清空成功!", "提示信息");
         }
     }
 }
Example #14
0
 private void btnDeleteDaily_Click(object sender, EventArgs e)
 {
     if (_dailyEntity.D_REMIND_FLAG == "1" && MessageHandle.MessageAsk("注意:该日程事务还没处理!\n确定要删除该日程事务?", "确定删除") == DialogResult.OK)
     {
         BusAdminDaily.DeleteDailyById(_dailyEntity.ID);
         ClearForm();
         _dailyEntity = null;
         MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         if (mFromWhere == 1)
         {
             tbcContainer.SelectedTab = tabPageToday;
             mFromWhere = 0;
         }
         else
         {
             BindAll();
             dgvAll.Select();
         }
     }
     else if (_dailyEntity.D_REMIND_FLAG == "0" && MessageHandle.MessageAsk("你确定要删除该日程事务?", "确定删除") == DialogResult.OK)
     {
         BusAdminDaily.DeleteDailyById(_dailyEntity.ID);
         ClearForm();
         _dailyEntity = null;
         MessageHandle.MessageInfo("恭喜,删除成功!", "提示信息");
         if (mFromWhere == 1)
         {
             tbcContainer.SelectedTab = tabPageToday;
             mFromWhere = 0;
         }
         else
         {
             BindAll();
             dgvAll.Select();
         }
     }
 }
Example #15
0
 private void btnClearAll_Click(object sender, EventArgs e)
 {
     if (dgvAll.Rows.Count > 0)
     {
         if (MessageHandle.MessageAsk("确定要删除所有已处理日程事务?", "确定删除") == DialogResult.OK)
         {
             BusAdminDaily.DeleteDidDailyOfAll();
             if (_dailyEntity != null)
             {
                 foreach (DataGridViewRow dataRow in dgvAll.Rows)
                 {
                     if (_dailyEntity.ID == dataRow.Cells[0].Value.ToString())
                     {
                         ClearForm();
                         _dailyEntity = null;
                         break;
                     }
                 }
             }
             _dsAll.Tables[0].DefaultView.RowFilter = "D_REMIND_FLAG='未处理'";
             MessageHandle.MessageInfo("恭喜,清空成功!", "提示信息");
         }
     }
 }
Example #16
0
        /// <summary>
        /// 修改日程事务
        /// </summary>
        /// <param name="dailyEntity">日程事务实体</param>
        /// <returns></returns>
        public static bool ModifyDaily(DailyEntity dailyEntity)
        {
            string sql = "";

            if (dailyEntity.D_LUNAR_CALENDAR == null || dailyEntity.D_LUNAR_CALENDAR == "")
            {
                sql = "update daily set D_SOLAR_CALENDAR=#{0}#,D_LUNAR_CALENDAR=null,D_CONTENT='{1}',D_REMIND_MUSIC_PATH='{2}',D_LEVEL={3} where ID={4}";
                sql = string.Format(sql, dailyEntity.D_SOLAR_CALENDAR, dailyEntity.D_CONTENT, dailyEntity.D_REMIND_MUSIC_PATH, dailyEntity.D_LEVEL, dailyEntity.ID);
            }
            else
            {
                sql = "update daily set D_SOLAR_CALENDAR=#{0}#,D_LUNAR_CALENDAR=#{1}#,D_CONTENT='{2}',D_REMIND_MUSIC_PATH='{3}',D_LEVEL={4} where ID={5}";
                sql = string.Format(sql, dailyEntity.D_SOLAR_CALENDAR, dailyEntity.D_LUNAR_CALENDAR, dailyEntity.D_CONTENT, dailyEntity.D_REMIND_MUSIC_PATH, dailyEntity.D_LEVEL, dailyEntity.ID);
            }
            if (DBManager.ExecuteNonQuery(sql) == 1)
            {
                InitTodayUnDoDaily();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #17
0
 public ActionResult SubmitForm(DailyEntity dailyEntity, string keyValue)
 {
     dailyApp.SubmitForm(dailyEntity, keyValue);
     return(Success("操作成功。"));
 }
Example #18
0
 private void btnModifyDaily_Click(object sender, EventArgs e)
 {
     if (IsValid())
     {
         _dailyEntity.D_CONTENT           = rtbContent.Text;
         _dailyEntity.D_LEVEL             = cboLevel.SelectedValue.ToString();
         _dailyEntity.D_REMIND_MUSIC_PATH = txtMusicPath.Text;
         string grade;
         if (chkLunar.Checked)
         {
             _dailyEntity.D_LUNAR_CALENDAR = dtpTime.Value.ToString();
             ChineseCalendarInfo cCalendar = ChineseCalendarInfo.FromLunarDate(dtpTime.Value.Date, false);
             DateTime            solar     = cCalendar.SolarDate.Add(new TimeSpan(dtpTime.Value.Hour, dtpTime.Value.Minute, dtpTime.Value.Second));
             _dailyEntity.D_SOLAR_CALENDAR = solar.ToString();
             grade = BusAdminDaily.CalculateGrade(solar);
             _dailyEntity.D_LEVEL = grade;
         }
         else
         {
             _dailyEntity.D_LUNAR_CALENDAR = "";
             _dailyEntity.D_SOLAR_CALENDAR = dtpTime.Value.ToString();
             grade = BusAdminDaily.CalculateGrade(dtpTime.Value);
             _dailyEntity.D_LEVEL = grade;
         }
         if (BusAdminDaily.ModifyDaily(_dailyEntity))
         {
             if (MessageHandle.MessageInfo("恭喜,修改成功!", "提示信息") == DialogResult.OK)
             {
                 BusAdminDaily.UpdateDailyStateBySystem();
             }
             if (mFromWhere == 1)
             {
                 tbcContainer.SelectedTab = tabPageToday;
                 mFromWhere = 0;
                 foreach (DataGridViewRow dgvRow in dgvToday.SelectedRows)
                 {
                     dgvRow.Selected = false;
                 }
                 foreach (DataGridViewRow dgvRow in dgvToday.Rows)
                 {
                     if (dgvRow.Cells[0].Value.ToString() == _dailyEntity.ID)
                     {
                         dgvRow.Selected = true;
                         break;
                     }
                 }
             }
             else
             {
                 BindAll();
                 dgvAll.Select();
                 foreach (DataGridViewRow dgvRow in dgvAll.SelectedRows)
                 {
                     dgvRow.Selected = false;
                 }
                 foreach (DataGridViewRow dgvRow in dgvAll.Rows)
                 {
                     if (dgvRow.Cells[0].Value.ToString() == _dailyEntity.ID)
                     {
                         dgvRow.Selected = true;
                         break;
                     }
                 }
             }
             ClearForm();
             _dailyEntity = null;
         }
     }
 }
Example #19
0
        /// <summary>
        /// 修改日程事务
        /// </summary>
        /// <param name="selectedRows"></param>
        private void ModifyDaily(DataGridViewSelectedRowCollection selectedRows)
        {
            ClearForm();
            tbcContainer.SelectedTab = tabPageAdmin;
            DataRow   dr           = ((DataRowView)selectedRows[0].DataBoundItem).Row;
            DataTable newDataTable = dr.Table.Clone();

            dr = newDataTable.Rows.Add(dr.ItemArray);
            if (dr["D_REMIND_FLAG"].ToString() == "未处理")
            {
                dr["D_REMIND_FLAG"] = "1";
            }
            else
            {
                dr["D_REMIND_FLAG"] = "0";
            }
            switch (dr["D_LEVEL"].ToString())
            {
            case "特急":
                dr["D_LEVEL"] = "0";
                break;

            case "紧急":
                dr["D_LEVEL"] = "1";
                break;

            case "中等":
                dr["D_LEVEL"] = "2";
                break;

            case "缓慢":
                dr["D_LEVEL"] = "3";
                break;

            case "过期":
                dr["D_LEVEL"] = "4";
                break;
            }
            _dailyEntity = new DailyEntity(dr);
            if (_dailyEntity != null)
            {
                gbAddDaily.Text        = "修改日程事务";
                cboLevel.SelectedValue = _dailyEntity.D_LEVEL;
                rtbContent.Text        = _dailyEntity.D_CONTENT;
                txtMusicPath.Text      = _dailyEntity.D_REMIND_MUSIC_PATH;
                _bClearForm            = true;
                if (_dailyEntity.D_LUNAR_CALENDAR != null && _dailyEntity.D_LUNAR_CALENDAR != "")
                {
                    chkLunar.Checked = true;
                    dtpTime.Value    = Convert.ToDateTime(_dailyEntity.D_LUNAR_CALENDAR);
                }
                else
                {
                    dtpTime.Value = Convert.ToDateTime(_dailyEntity.D_SOLAR_CALENDAR);
                }
                operType    = 1;
                _bClearForm = false;

                btnDeleteDaily.Enabled = true;
                if (_dailyEntity.D_REMIND_FLAG == "0")
                {
                    chkRemindFlag.Checked = true;
                    cboLevel.Enabled      = false;
                    rtbContent.Enabled    = false;
                    txtMusicPath.Enabled  = false;
                    btnBrowseFile.Enabled = false;
                    dtpTime.Enabled       = false;
                    chkLunar.Enabled      = false;
                }
                else
                {
                    btnModifyDaily.Enabled = true;
                }
                if (mFromWhere == 1)
                {
                    foreach (DataGridViewRow dgvRow in dgvAll.SelectedRows)
                    {
                        dgvRow.Selected = false;
                    }
                    foreach (DataGridViewRow dgvRow in dgvAll.Rows)
                    {
                        if (dgvRow.Cells[0].Value.ToString() == _dailyEntity.ID)
                        {
                            dgvRow.Selected = true;
                            break;
                        }
                    }
                }
            }
        }
Example #20
0
        /// <summary>
        /// 自动更新日程等级
        /// </summary>
        public static void UpGradeBySystem()
        {
            string           sql         = "select * from daily where D_REMIND_FLAG=1";
            string           connString  = DBManager.strConnectionString;
            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sql, connString);
            DataSet          ds          = new DataSet();

            dataAdapter.Fill(ds);
            DateTime nowTime  = DateTime.Now;
            TimeSpan timeSpan = new TimeSpan();
            int      minutes  = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (dr["D_LEVEL"].ToString() != "0")
                {
                    timeSpan = Convert.ToDateTime(dr["D_SOLAR_CALENDAR"]).Subtract(nowTime);
                    minutes  = (int)timeSpan.TotalMinutes;
                    if (minutes <= 30)
                    {
                        dr["D_LEVEL"] = "0";
                    }
                    else if (30 < minutes && minutes <= 60)
                    {
                        dr["D_LEVEL"] = "1";
                    }
                    else if (60 < minutes && minutes <= 90)
                    {
                        dr["D_LEVEL"] = "2";
                    }
                    else if (90 < minutes)
                    {
                        dr["D_LEVEL"] = "3";
                    }
                }
            }
            if (ds.HasChanges())
            {
                OleDbCommandBuilder builder = new OleDbCommandBuilder();
                builder.DataAdapter       = dataAdapter;
                dataAdapter.UpdateCommand = builder.GetUpdateCommand();
                dataAdapter.Update(ds.GetChanges());
            }
            ds.AcceptChanges();
            sql = "select ID,D_SOLAR_CALENDAR,D_LUNAR_CALENDAR,D_CONTENT,D_REMIND_MUSIC_PATH,"
                  + "iif(D_LEVEL=0,'特急',iif(D_LEVEL=1,'紧急',iif(D_LEVEL=2,'中等',iif(D_LEVEL=3,'缓慢',iif(D_LEVEL=4,'过期','未知'))))) as D_LEVEL,"
                  + "iif(D_REMIND_FLAG=0,'已处理','未处理') as D_REMIND_FLAG "
                  + "from daily where  #{0}#<=D_SOLAR_CALENDAR and D_SOLAR_CALENDAR<#{1}# and D_REMIND_FLAG=1 order by D_LEVEL asc,D_SOLAR_CALENDAR asc";
            ds = new DataSet();
            dataAdapter.Fill(ds);
            if (ds != null)
            {
                //锁定LST_TODAY_UNDO_DAILY,防止主线程调用
                lock (GlobalVariable.LST_TODAY_UNDO_DAILY)
                {
                    GlobalVariable.LST_TODAY_UNDO_DAILY.Clear();
                    DailyEntity dailyEntity;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dailyEntity = new DailyEntity(dr);
                        GlobalVariable.LST_TODAY_UNDO_DAILY.Add(dailyEntity);
                    }
                }
            }
        }
Example #21
0
 public int Update(DailyEntity model)
 {
     return(_repository.Update(model));
 }
Example #22
0
 public int Insert(DailyEntity model)
 {
     return(_repository.Insert(model));
 }