Beispiel #1
0
        public async Task <ActionResult <OffDay> > PostOffDay(OffDay offDay)
        {
            _context.OffDays.Add(offDay);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOffDay", new { id = offDay.ID }, offDay));
        }
        public OffDay GetOffDaysByID(long ID)
        {
            OffDay offDay       = new OffDay();
            var    responseTask = client.GetAsync("api/OffDays/" + ID);

            responseTask.Wait();

            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                //sonuçtan gelen veriyi çekiyoruz
                var readTask = result.Content.ReadAsAsync <OffDay>();
                readTask.Wait();
                //geri dönecek olan listeyi yüklüyoruz
                offDay = readTask.Result;
                return(offDay);
            }
            else
            {
                //işlem başarılı olmadığında if(result.IsSuccessStatusCode) boş bir liste döndürüyoruz ki crash olmasın hata dönsün sadece
                offDay = null;
                return(offDay);
            }
        }
Beispiel #3
0
        public OffDayWindow()
        {
            bwLoad                     = new BackgroundWorker();
            bwLoad.DoWork             += bwLoad_DoWork;
            bwLoad.RunWorkerCompleted += bwLoad_RunWorkerCompleted;

            bwSave                     = new BackgroundWorker();
            bwSave.DoWork             += bwSave_DoWork;
            bwSave.RunWorkerCompleted += bwSave_RunWorkerCompleted;

            bwRemove = new BackgroundWorker();
            bwRemove.RunWorkerCompleted += bwRemove_RunWorkerCompleted;
            bwRemove.DoWork             += bwRemove_DoWork;

            supplierDefaultList = new List <Supplier>();
            supplierCurrentList = new List <Supplier>();

            offDayCurrentList = new List <OffDay>();
            offDayMapList     = new List <OffDay_Supplier_Mapping>();

            offDay        = new OffDay();
            offDayCurrent = new OffDay();

            InitializeComponent();
        }
Beispiel #4
0
        public String SubmitOffDays(OffDay s)
        {
            if (!string.IsNullOrEmpty(s.DateFrom) && !string.IsNullOrEmpty(s.DateTo) && !string.IsNullOrEmpty(s.TimeFrom) && !string.IsNullOrEmpty(s.TimeTo) && !string.IsNullOrEmpty(s.Description))
            {
                string   datetimefrom = s.DateFrom + " " + s.TimeFrom;
                string   datetimeto   = s.DateTo + " " + s.TimeTo;
                string   f            = datetimefrom.ToString();
                string   t            = datetimeto.ToString();
                DateTime dateValueFrom;
                DateTime dateValueTo;

                string format = "MM/dd/yyyy hh:mm tt";

                DateTime.TryParseExact(f, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValueFrom);


                DateTime.TryParseExact(t, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValueTo);
                SqlConnection conn  = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMDBContext"].ToString());
                string        query = "INSERT INTO [OffDays]([EmpId],[DateFrom], [DateTo], [TimeFrom], [TimeTo], [DateTimeFrom], [DateTimeTo], [Description]) VALUES('" + s.DateFrom + "', '" + s.DateTo
                                      + "', '" + s.TimeFrom + "', '" + s.TimeTo + "', '" + s.EmpId + "', '" + dateValueFrom.ToString() + "', '" + dateValueTo.ToString() + "', '" + s.Description + "')";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader sdr = cmd.ExecuteReader();
                conn.Close();
                return("Days off Saved");
            }
            else
            {
                return("Please complete the form");
            }
        }
Beispiel #5
0
        public async Task <IActionResult> PutOffDay(long id, OffDay offDay)
        {
            if (id != offDay.ID)
            {
                return(BadRequest());
            }

            _context.Entry(offDay).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OffDayExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public IActionResult Update(OffDay offDay)
        {
            OffDayRepository.OffDayRep.Update(offDay);

            offDay = new OffDay();
            return(View("DayOffPage", offDay));
        }
Beispiel #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            OffDay DBoffDays = db.OffDaysSchedule.Find(id);

            db.OffDaysSchedule.Remove(DBoffDays);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public IActionResult DayOffPage(OffDay?offDay)
 {
     if (offDay == null)
     {
         offDay = new OffDay();
     }
     return(View(offDay));
 }
Beispiel #9
0
        private void ClearValue()
        {
            txtDescription.Clear();
            dpSelectOffDay.SelectedDate = DateTime.Now.Date;

            offDay        = new OffDay();
            offDayCurrent = new OffDay();
        }
        public IActionResult Edit(long ID)
        {
            OffDay offDay = new OffDay();

            offDay = OffDayRepository.OffDayRep.GetOffDaysByID(ID);


            return(View("DayOffPage", offDay));
        }
Beispiel #11
0
        private OffDay GetValueFromControl(OffDay offDay)
        {
            offDay.OffDayID    = Int32.Parse(txtID.Text);
            offDay.OffDate     = dpSelectOffDay.SelectedDate.Value.Date;
            offDay.Description = txtDescription.Text.Trim();
            offDay.CreatedTime = DateTime.Now;

            return(offDay);
        }
Beispiel #12
0
 public ActionResult Edit([Bind(Include = "id,DateTimeFrom,DateTimeTo,EmpId,Description")] OffDay offDays)
 {
     if (ModelState.IsValid)
     {
         db.Entry(offDays).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(offDays));
 }
        public IActionResult Delete(long ID, OffDay?offDay)
        {
            if (offDay == null)
            {
                offDay = new OffDay();
            }

            OffDayRepository.OffDayRep.Delete(ID);

            return(View("DayOffPage", offDay));
        }
Beispiel #14
0
        public ActionResult Create([Bind(Include = "id,DateTimeFrom,DateTimeTo,EmpId")] OffDay offDays)
        {
            if (ModelState.IsValid)
            {
                db.OffDaysSchedule.Add(offDays);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(offDays));
        }
        public void Update(OffDay offDay)
        {
            var PutTask = client.PutAsJsonAsync <OffDay>("api/OffDays/" + offDay.ID, offDay);

            PutTask.Wait();
            var result = PutTask.Result;

            if (!result.IsSuccessStatusCode)
            {
                throw new Exception(result.ReasonPhrase);
            }
        }
Beispiel #16
0
 // Update
 public static void Update(OffDay model)
 {
     using (var db = new MouldEntities())
     {
         var canUpdate = db.OffDays.SingleOrDefault(s => s.OffDayID == model.OffDayID);
         if (canUpdate != null)
         {
             canUpdate.OffDate     = model.OffDate;
             canUpdate.Description = model.Description;
             db.SaveChanges();
         }
     }
 }
Beispiel #17
0
        // GET: OffDays/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OffDay DBoffDays = db.OffDaysSchedule.Find(id);

            if (DBoffDays == null)
            {
                return(HttpNotFound());
            }
            return(View(DBoffDays));
        }
Beispiel #18
0
        // GET: OffDays/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OffDay DBoffDays = db.OffDaysSchedule.SingleOrDefault(ev => ev.id == id);

            if (DBoffDays == null)
            {
                return(HttpNotFound());
            }
            return(View(DBoffDays));
        }
Beispiel #19
0
 // Create
 public static void Insert(OffDay model)
 {
     using (var db = new MouldEntities())
     {
         var canInsert = db.OffDays.Where(w => w.OffDate.Value.Year == model.OffDate.Value.Year &&
                                          w.OffDate.Value.Month == model.OffDate.Value.Month &&
                                          w.OffDate.Value.Day == model.OffDate.Value.Day).ToList();
         if (canInsert.Count() == 0)
         {
             db.OffDays.Add(model);
             db.SaveChanges();
         }
     }
 }
        public void Add(OffDay offDay)
        {
            //Burada gelen objeyi post metodu ile apiye yönlendiriyoruz.
            var PostTask = client.PostAsJsonAsync <OffDay>("api/OffDays", offDay);

            PostTask.Wait();

            var result = PostTask.Result;

            if (!result.IsSuccessStatusCode)
            {
                throw new Exception(result.ReasonPhrase);
            }
        }
        public IActionResult AddOffDay(OffDay?offDays)
        {
            offDays.ModifiedDate = DateTime.Now;
            offDays.CreatedDate  = DateTime.Now;
            offDays.IsActive     = true;



            if (offDays != null)
            {
                OffDayRepository.OffDayRep.Add(offDays);
            }
            else
            {
                offDays = new OffDay();
            }

            return(View("DayOffPage", offDays));
        }
Beispiel #22
0
        private void dgOffDay_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            offDayCurrent = dgOffDay.CurrentItem as OffDay;
            if (offDayCurrent == null)
            {
                return;
            }
            insertOrUpdate = false;
            InjectModelToControl(offDayCurrent);
            HighlightItemClicked();

            var offDayMapClickedList            = OffDayMapController.Select().Where(w => w.OffDayID == offDayCurrent.OffDayID).ToList();
            var supplierID_OffDayMapClickedList = offDayMapClickedList.Select(s => s.SupplierID).Distinct().ToList();
            var supplier_OffDayMapClicked       = supplierDefaultList.Where(w => supplierID_OffDayMapClickedList.Contains(w.SupplierID)).ToList();

            supplierCurrentList.Clear();
            supplierCurrentList.AddRange(supplier_OffDayMapClicked);

            LoadSupplier(supplierCurrentList);
        }
Beispiel #23
0
        public ActionResult Create([Bind(Include = "EmpId,ID,UserId,DateFrom,DateTo,TimeFrom,TimeTo")] Schedules scheduleModel, OffDay offday)
        {
            if (ModelState.IsValid)
            {
                db.ScheduleModels.Add(scheduleModel);
                db.OffDaysSchedule.Add(offday);
                db.SaveChanges();
                return(RedirectToAction("Index/" + scheduleModel.EmpId));
            }

            return(View(scheduleModel));
        }
Beispiel #24
0
 private void InjectModelToControl(OffDay offDay)
 {
     txtID.Text = offDay.OffDayID.ToString();
     dpSelectOffDay.SelectedDate = offDay.OffDate.Value.Date;
     txtDescription.Text         = offDay.Description;
 }