private void btnAddSchedule_Click(object sender, EventArgs e)
        {
            if (productScheduleShow != null)
            {
                productScheduleShow.Id             = 0;
                productScheduleShow.TimeSlotLength = (int)cboDuration.SelectedValue;
                productScheduleShow.ShowTypeId     = (int)cboShowType.SelectedValue;
            }
            if (model.Id != 0)
            {
                productScheduleShow.ContractDetailId = model.Id;
            }

            var options = new TimeSlotService().GetOptionsByLengthShowType((int)cboDuration.SelectedValue, (int)cboShowType.SelectedValue);

            if (options.FirstOrDefault().Key == -1)
            {
                Utilities.ShowMessage("Không tìm thấy thời điểm có thời lượng " + (int)cboDuration.SelectedValue + " (s) !\nVui lòng thêm thiết lập trong phần [Danh mục thời điểm].");
            }
            else
            {
                ProductScheduleDetailForm contractDetailDetailForm = new ProductScheduleDetailForm(productScheduleShow, model.ContractCode);
                contractDetailDetailForm.FormClosed += new FormClosedEventHandler(DetailForm_Closed);
                contractDetailDetailForm.ShowDialog();
            }
        }
        public void LoadData()
        {
            try
            {
                if (model != null)
                {
                    _timeSlotService = new TimeSlotService();
                    model            = _timeSlotService.GetById(model.Id);
                    if (model != null)
                    {
                        cboSession.SelectedValue = model.SessionCode;
                        txtCode.Text             = model.Code;
                        txtName.Text             = model.Name;
                        txtFromHour.Text         = Utilities.GetHourFromHourInt(model.FromHour).ToString();
                        txtFromMinute.Text       = Utilities.GetMinuteFromHourInt(model.FromHour).ToString();
                        txtCode.ReadOnly         = true;

                        LoadDGV();
                    }
                    gbCostRule.Visible = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _timeSlotService = null;
                LoadingData      = false;
            }
        }
Ejemplo n.º 3
0
        // Create TimeSlot Service
        private TimeSlotService CreateTimeSlotService()
        {
            var userId  = User.Identity.GetUserId();
            var service = new TimeSlotService(userId);

            return(service);
        }
Ejemplo n.º 4
0
        private void LoadDGV()
        {
            try
            {
                _timeSlotService = new TimeSlotService();
                List <TimeSlotViewModel> timeSlotVMs        = _timeSlotService.GetAllForDetailList();
                SortableBindingList <TimeSlotViewModel> sbl = new SortableBindingList <TimeSlotViewModel>(timeSlotVMs);
                bs              = new BindingSource();
                bs.DataSource   = sbl;
                adgv.DataSource = bs;

                adgv.Columns["Id"].Visible             = false;
                adgv.Columns["StatusId"].Visible       = false;
                adgv.Columns["CreateDate"].Visible     = false;
                adgv.Columns["LastUpdateBy"].Visible   = false;
                adgv.Columns["LastUpdateDate"].Visible = false;

                adgv.Columns["Code"].HeaderText        = ADGVText.Code;
                adgv.Columns["Code"].Width             = ControlsAttribute.GV_WIDTH_NORMAL;
                adgv.Columns["Name"].HeaderText        = ADGVText.Name;
                adgv.Columns["Name"].AutoSizeMode      = DataGridViewAutoSizeColumnMode.Fill;
                adgv.Columns["FromHour"].HeaderText    = ADGVText.TimeSlot;
                adgv.Columns["FromHour"].Width         = ControlsAttribute.GV_WIDTH_NORMAL;
                adgv.Columns["SessionCode"].HeaderText = ADGVText.Session;
                adgv.Columns["SessionCode"].Width      = ControlsAttribute.GV_WIDTH_NORMAL;
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                _timeSlotService = null;
            }
        }
Ejemplo n.º 5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (Utilities.ShowConfirmMessage(CommonMessage.CONFIRM_DELETE))
     {
         try
         {
             if (timeslot != null)
             {
                 _timeSlotService = new TimeSlotService();
                 int result = _timeSlotService.DeleteTimeSlot(timeslot.Id);
                 if (result == CRUDStatusCode.SUCCESS)
                 {
                     LoadDGV();
                     Utilities.ShowMessage(CommonMessage.DELETE_SUCESSFULLY);
                     Logging.LogBusiness(string.Format("{0} {1} {2}",
                                                       Common.Session.GetUserName(),
                                                       Common.Constants.LogAction.Delete, "thời điểm phát " + timeslot.Code + " " + timeslot.FromHour),
                                         Common.Constants.BusinessLogType.Delete);
                 }
             }
         }
         catch (Exception ex)
         {
             throw;
         }
         finally
         {
             _timeSlotService = null;
         }
     }
 }
Ejemplo n.º 6
0
        // Build TimeSlot Dropdown
        private IOrderedEnumerable <SelectListItem> BuildTimeSlotDropdown(bool deliver, int selectedValue)
        {
            var userId          = User.Identity.GetUserId();
            var timeSlotService = new TimeSlotService(userId);

            var timeSlotList       = new SelectList(timeSlotService.GetTimeSlotDropDown(deliver), "SlotId", "SlotTime", selectedValue);
            var sortedTimeSlotList = timeSlotList.OrderBy(o => o.Text);

            return(sortedTimeSlotList);
        }
 private void CheckExistTimeSlotInfo()
 {
     try
     {
         _timeSlotService = new TimeSlotService();
         bool result = false;//TODO check _timeSlotService.IsExistCodeAndLength(txtCode.Text, (int)cboDuration.SelectedValue);
         if (result)
         {
             Utilities.ShowMessage(CommonMessage.USED_CODE_LENGTH);
         }
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _timeSlotService = null;
     }
 }
Ejemplo n.º 8
0
        public async Task TestGetAllNoResults()
        {
            // Arrange
            var timeSlots = new List <TimeSlot>();

            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork
            .Setup(x => x.TimeSlotRepository.GetAllAsync(It.IsAny <bool>()))
            .ReturnsAsync(timeSlots);

            var service = new TimeSlotService(mockUnitOfWork.Object, _mapper);

            // Act
            var result = await service.GetAllAsDTOAsync();

            // Assert
            Assert.NotNull(result);
            Assert.Empty(result);
        }
        private void txtCode_TextChanged(object sender, EventArgs e)
        {
            _timeSlotService = new TimeSlotService();

            try
            {
                if (!LoadingData)
                {
                    bool isExist = _timeSlotService.IsExistCode(txtCode.Text.Trim());
                    if (isExist)
                    {
                        Utilities.ShowError("Mã " + txtCode.Text.Trim() + " đã tồn tại");
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _timeSlotService = null;
            }
        }
Ejemplo n.º 10
0
 private void LoadTimeSlots()
 {
     try
     {
         _timeSlotService = new TimeSlotService();
         var options = _timeSlotService.GetOptionsByLengthShowType(model.TimeSlotLength, model.ShowTypeId);
         if (options.FirstOrDefault().Key == -1)
         {
             Utilities.ShowMessage("Không tìm thấy thời điểm có thời lượng " + model.TimeSlotLength + " (s)!\n Vui lòng thêm thiết lập trong phần [Danh mục thời điểm].");
             Close();
         }
         Utilities.LoadComboBoxOptions(cboTimeSlot, options);
     }
     catch (Exception ex)
     {
         Logging.LogSystem(ex.StackTrace, SystemLogType.Exception);
         throw;
     }
     finally
     {
         CompleteLoadData = 1;
         _timeSlotService = null;
     }
 }
Ejemplo n.º 11
0
 public TimeSlotController(TimeSlotServiceImpl timeSlotService)
 {
     _timeSlotService = timeSlotService;
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            TimeSlot result = null;

            try
            {
                _timeSlotService = new TimeSlotService();

                if (ckbUpdate.Checked)
                {
                    //Edit
                    int editResult = CRUDStatusCode.ERROR;
                    model.Code        = txtCode.Text;
                    model.Name        = txtName.Text;
                    model.FromHour    = Utilities.GetHourFromHourString(txtFromHour.Text, txtFromMinute.Text);
                    model.SessionCode = cboSession.SelectedValue.ToString();

                    editResult = _timeSlotService.EditTimeSlot(model);
                    if (editResult == CRUDStatusCode.SUCCESS)
                    {
                        Utilities.ShowMessage(CommonMessage.EDIT_SUCESSFULLY);
                        Logging.LogBusiness(string.Format("{0} {1} {2}",
                                                          Common.Session.GetUserName(),
                                                          Common.Constants.LogAction.Update, "thời điểm phát " + model.Code),
                                            Common.Constants.BusinessLogType.Update);
                    }
                }
                else
                {
                    bool isExistCode = _timeSlotService.IsExistCode(txtCode.Text.Trim());
                    if (isExistCode)
                    {
                        Utilities.ShowError("Mã " + txtCode.Text.Trim() + " đã tồn tại");
                    }
                    else
                    {
                        if (model == null)
                        {
                            //Add
                            model = new TimeSlot()
                            {
                                Code        = txtCode.Text,
                                Name        = txtName.Text,
                                FromHour    = Utilities.GetHourFromHourString(txtFromHour.Text, txtFromMinute.Text),
                                SessionCode = cboSession.SelectedValue.ToString(),
                            };
                            result = _timeSlotService.CreateTimeSlot(model);
                            if (result != null)
                            {
                                model = result;
                                Utilities.ShowMessage(CommonMessage.ADD_SUCESSFULLY);
                                gbCostRule.Visible = true;
                                Logging.LogBusiness(string.Format("{0} {1} {2}",
                                                                  Common.Session.GetUserName(),
                                                                  Common.Constants.LogAction.Create, "thời điểm phát " + model.Code),
                                                    Common.Constants.BusinessLogType.Create);
                            }
                        }
                        else
                        {
                            //TODO Check remove
                            //Edit
                            int editResult = CRUDStatusCode.ERROR;
                            model.Code        = txtCode.Text;
                            model.Name        = txtName.Text;
                            model.FromHour    = Utilities.GetHourFromHourString(txtFromHour.Text, txtFromMinute.Text);
                            model.SessionCode = cboSession.SelectedValue.ToString();

                            editResult = _timeSlotService.EditTimeSlot(model);
                            if (editResult == CRUDStatusCode.SUCCESS)
                            {
                                Utilities.ShowMessage(CommonMessage.EDIT_SUCESSFULLY);
                                Logging.LogBusiness(string.Format("{0} {1} {2}",
                                                                  Common.Session.GetUserName(),
                                                                  Common.Constants.LogAction.Update, "thời điểm phát " + model.Code),
                                                    Common.Constants.BusinessLogType.Update);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                _timeSlotService = null;
            }
        }
Ejemplo n.º 13
0
        private void btnAddTimeSlot_Click(object sender, EventArgs e)
        {
            if (numericSThours.Value < 0 ^ numericSThours.Value > 24)
            {
                numericSThours.Focus();
                errorProviderTimeSlot.SetError(numericSThours, "Enter hours");
                clear();
            }
            else if (comboBoxSTMinutes.SelectedIndex == -1)
            {
                comboBoxSTMinutes.Focus();
                errorProviderTimeSlot.SetError(comboBoxSTMinutes, "Enter Minutes");
                clear();
            }


            else if (comboBoxDuration.SelectedIndex == -1)
            {
                comboBoxDuration.Focus();
                errorProviderTimeSlot.SetError(comboBoxDuration, "Select duration time");
                clear();
            }

            else if (ETHours.Text == String.Empty)
            {
                ETHours.Focus();
                errorProviderTimeSlot.SetError(ETHours, "Click generate button");
                clear();
            }
            else if (ETMinutes.Text == String.Empty)
            {
                ETMinutes.Focus();
                errorProviderTimeSlot.SetError(ETMinutes, "Click generate button");
                clear();
            }


            else
            {
                ITimeSlotService timeSlotService = new TimeSlotService();

                #region Set Data to Object
                // Set Data to model
                timeSlot.StHours   = int.Parse(numericSThours.Value.ToString());
                timeSlot.StMinutes = int.Parse(comboBoxSTMinutes.SelectedItem.ToString());
                timeSlot.EtHours   = int.Parse(ETHours.Text.Trim());
                timeSlot.EtMinutes = int.Parse(ETMinutes.Text.Trim());
                timeSlot.Duration  = comboBoxDuration.SelectedItem.ToString();


                #endregion

                //Insert Data
                if (timeSlotService.addTimeSlots(timeSlot))
                {
                    SuccessMessage sc = new SuccessMessage("times-slot Added Successfully !");
                    sc.Show();
                    dataGridTimeSlots.Rows.Clear();
                    populateData();
                    clear();
                }
                else
                {
                    ErrorMessage ec = new ErrorMessage("There is somthing wrong in times-slot ");
                    ec.Show();
                }
            }
        }
Ejemplo n.º 14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int result = CRUDStatusCode.ERROR;

            if ((int)cboPosition.SelectedValue != 4 && ckbPosition.Checked == true)
            {
                if (!Utilities.ShowConfirmMessage("Vị trí ưu tiên xuất hiện của những quảng cáo tạo/cập nhật sau sẽ chèn" +
                                                  " lên trước những quảng cáo được tạo trước đó. Bạn có muốn tiếp tục lưu ?"))
                {
                    return;
                }
            }

            try
            {
                _productScheduleShowService = new ProductScheduleShowService();
                _timeSlotService            = new TimeSlotService();

                if (model != null)
                {
                    TimeSlot selectedTimeSlot = _timeSlotService.GetById((int)cboTimeSlot.SelectedValue);
                    if (selectedTimeSlot == null)
                    {
                        Utilities.ShowReturnMessage(result, "Thời điểm chọn không hợp lệ");
                    }
                    else
                    {
                        //Add Edit
                        ProductScheduleShow originModel = model;
                        model.TimeSlot       = cboTimeSlot.Text;
                        model.TimeSlotCode   = selectedTimeSlot.Code;
                        model.TotalCost      = (double)txtSumCost.MoneyValue;
                        model.Cost           = (double)txtCost.MoneyValue;
                        model.OrderNumber    = (int)cboPosition.SelectedValue;
                        model.TimeSlotLength = int.Parse(txtTimeSlotLength.Text);
                        model.Quantity       = 1;//TODO: mặc định là 1 //int.Parse(txtQuantity.Text);
                        model.IsAdvanced     = ckbPosition.Checked;

                        if (mpShowDate.BoldedDates.Length > 0)
                        {
                            model.ShowDate = mpShowDate.BoldedDates[0];
                        }
                        else
                        {
                            model.ShowDate = DateTime.Now;
                        }

                        model.ProductName = ProductName;
                        model.ShowTime    = Utilities.GetHourFormInt(selectedTimeSlot.FromHour);
                        model.ShowTimeInt = selectedTimeSlot.FromHour;
                        result            = AddProductSchedultShows(mpShowDate.BoldedDates, originModel);
                        Utilities.ShowReturnMessage(result, "Lưu");
                        Logging.LogBusiness(string.Format("{0} {1} {2}",
                                                          Common.Session.GetUserName(),
                                                          Common.Constants.LogAction.Update, "lịch chiếu " + model.ProductName + " " + model.TimeSlot + " " + model.ContractDetailId),
                                            Common.Constants.BusinessLogType.Update);
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.LogSystem(ex.StackTrace, SystemLogType.Exception);
                throw;
            }
            finally
            {
                _timeSlotService            = null;
                _productScheduleShowService = null;
            }
        }