//ADDING DATA - Save to DB
        private Boolean AddData(string dueDay, string dueHour, string dueMin, string taskName, string className, string desc)
        {
            try
            {
                if (ThisReminder == null)
                {
                    ThisReminder = new ReminderModel2();
                }
                var TaskTbl = new TaskTbl()
                {
                    DueDay    = dueDay,
                    DueHour   = dueHour,
                    DueMin    = dueMin,
                    TaskName  = taskName,
                    ClassName = className,
                    Desc      = desc,
                };
                ThisReminder.TaskTbls.Add(TaskTbl);

                //Persists
                ThisReminder.SaveChanges();

                //FILL DGV
                FillDGView(ThisReminder.TaskTbls.ToList());
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
        public Boolean EditData(string newDueDay, string newDueHour, string newDueMin, string taskName, string newClassName, string newDesc)
        {
            try
            {
                if (ThisReminder == null)
                {
                    ThisReminder = new ReminderModel2();
                }

                //Replace with new Data
                TaskTbl newTaskTbl = ThisReminder.TaskTbls.Find(taskName);

                /*newTaskTbl.TaskName = taskName;*/
                newTaskTbl.DueDay    = newDueDay;
                newTaskTbl.DueHour   = newDueHour;
                newTaskTbl.DueMin    = newDueMin;
                newTaskTbl.ClassName = newClassName;
                newTaskTbl.Desc      = newDesc;

                //Save
                ThisReminder.SaveChanges();

                //Update DGV
                FillDGView(ThisReminder.TaskTbls.ToList());
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
Esempio n. 3
0
 public async Task <IActionResult> Edit(long id, TaskTbl task)
 {
     // var create = _db.SiteMasterTbl.Where(m => m.SiteId == siteMaster.SiteId).First().CreatedAtSite;
     if (id != task.TaskId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         //
         //siteMaster.CreatedAtSite = create;
         task.ModifyAtTask = DateTime.Now;
         _db.Update(task);
         _db.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(task));
 }
Esempio n. 4
0
        public async Task <IActionResult> Create(TaskTbl taskTbl)
        {
            if (ModelState.IsValid)
            {
                String idrunning = "";
                idrunning = generateRunningNumber(idrunning);

                taskTbl.TaskCode      = idrunning;
                taskTbl.Date          = DateTime.Now;
                taskTbl.CreatedAtTask = DateTime.Now;
                taskTbl.ModifyAtTask  = DateTime.Now;
                _db.Add(taskTbl);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(taskTbl));
        }
 public frmTaskRemin(string dueDay, string dueHour, string dueMin, string taskName, string className, string desc)
 {
     InitializeComponent();
     mode       = Mode.Edit;
     newTaskTbl = new TaskTbl
     {
         DueDay    = dueDay,
         DueHour   = dueHour,
         DueMin    = dueMin,
         TaskName  = taskName,
         ClassName = className,
         Desc      = desc,
     };
     cbDueDay.Text    = dueDay;
     cbDueHour.Text   = dueHour;
     cbDueMin.Text    = dueMin;
     tbTaskName.Text  = taskName;
     tbClassName.Text = className;
     tbTaskDesc.Text  = desc;
 }
Esempio n. 6
0
        //=========================================================================================================
        //GENERATE RUNNING NUMBER
        private String generateRunningNumber(string id)
        {
            TaskTbl data = _db.TaskTbl.Where(x => x.TaskCode == "TC" + DateTime.Now.ToString("yyMM") + "0001").FirstOrDefault();

            string tempSubId = "";
            int    tempId;

            if (data == null)
            {
                id = "TC" + DateTime.Now.ToString("yyMM") + "0001";
            }
            else
            {
                var xx = (from a in _db.TaskTbl
                          where a.TaskCode.Substring(0, 6) == "TC" + DateTime.Now.ToString("yyMM")
                          select a).Max(a => a.TaskCode);

                tempSubId = xx.Substring(6, 4);
                tempId    = Convert.ToInt32(tempSubId);
                tempId    = tempId + 1;

                if (tempId.ToString().Length == 1)
                {
                    id = "TC" + DateTime.Now.ToString("yyMM") + "000" + tempId;
                }
                else if (tempId.ToString().Length == 2)
                {
                    id = "TC" + DateTime.Now.ToString("yyMM") + "00" + tempId;
                }
                else if (tempId.ToString().Length == 3)
                {
                    id = "TC" + DateTime.Now.ToString("yyMM") + "0" + tempId;
                }
                else if (tempId.ToString().Length == 4)
                {
                    id = "TC" + DateTime.Now.ToString("yyMM") + tempId;
                }
            }

            return(id);
        }