示例#1
0
文件: WDatePicker.C 项目: LifeGo/wt
void WDatePicker::setDate(const WDate& date)
{
  if (!date.isNull()) {
    forEdit_->setText(date.toString(format_));
    calendar_->select(date);
    calendar_->browseTo(date);
  }
}
示例#2
0
void WDateEdit::setDate(const WDate& date)
{
  if (!date.isNull()) {
    setText(date.toString(format()));
    calendar_->select(date);
    calendar_->browseTo(date);
  }
}
示例#3
0
void WDateEdit::setFromCalendar()
{
  if (!calendar_->selection().empty()) {
    WDate calDate = Utils::first(calendar_->selection());
    setText(calDate.toString(format()));
    changed().emit();
  }
}
示例#4
0
文件: Calendar.C 项目: 913862627/wt
void Calendar::select(const WDate& date)
{
  selection_.clear();
  selection_.insert(date);

  if (isRendered())
    addUpdateJS(elVar() + ".setValue(Date.parseDate('"
		+ date.toString("dd/MM/yyyy").toUTF8() + "','d/m/Y');");
}
void PriceEditDialog::handleFinish(DialogCode result)
{
    if (result == WDialog::Accepted)
    {
        /*
         * Update the model with data from the edit widgets.
         *
         * You will want to do some validation here...
         *
         * Note that we directly update the source model to avoid
         * problems caused by the dynamic sorting of the proxy model,
         * which reorders row numbers, and would cause us to switch to editing
         * the wrong data.
         */

        if(m_chbCostEnabled->isChecked() && m_chbPercentEnabled->isChecked())
        {
            WMessageBox::show("Error", WString(tr("msg.ambiguous.select")), Ok);
            return;
        }


        /*! При выставленном варианте расчета статический Поле цена не доступна
            1) Вариант расчета 0 Динамический  1 Статический
            2) Устанавливается Цена или процент
            3) Процента или Цена

        */
        WAbstractItemModel *m = m_model;
        //int id =
        int modelRow = m_item.row();
        int valueType = 0;
        int modifyStatic = 0;
        //int staticValue = 0;
        double value = 0.00;
        //char number[50];

        WAbstractProxyModel *proxyModel = dynamic_cast<WAbstractProxyModel *>(m);
        if (proxyModel)
        {
            m = proxyModel->sourceModel();
            modelRow = proxyModel->mapToSource(m_item).row();
        }
            //modelRow++;



        if(m_chbPercentEnabled->isChecked())
        {
            valueType = 2;
            //sprintf(number,"%.2f%%",boost::lexical_cast<double>(m_lePercent->text().toUTF8()));
            //m->setData(modelRow, 3, boost::any(std::string("0.00")));
            m->setData(modelRow, 5, boost::any(m_lePercent->text().toUTF8()+"%"));/// Процент
            m->setData(modelRow, 2, boost::any(value = boost::lexical_cast<double>(m_lePercent->text().toUTF8())),UserRole);/// Процент

        }else if(m_chbCostEnabled->isChecked())
        {
            valueType = 1;
            //m->setData(modelRow, 3, boost::any(boost::lexical_cast<double>(m_leCost->text().toUTF8())));/// Цена
            //sprintf(number,"%.2f%%",boost::lexical_cast<double>(m_leCost->text().toUTF8()));
            //m->setData(modelRow, 2, boost::any(std::string("0.00%")));
            m->setData(modelRow, 6, boost::any(m_leCost->text().toUTF8()));/// Цена
            m->setData(modelRow, 2, boost::any(value = boost::lexical_cast<double>(m_leCost->text().toUTF8())),UserRole);/// Цена
        }else{
            if(atof(m_leCost->text().toUTF8().c_str()) || atof(m_lePercent->text().toUTF8().c_str()))
                WMessageBox::show("Error", WString(tr("msg.notselected.valuetype")), Ok);

        }

        if(m_chbModifyStatic->isChecked())
            modifyStatic = 1;
        //log("info")<<" Percetn "<<valueType<<" Dinamic "<<m_rbGroup->checkedId();
        m->setData(modelRow, 3, boost::any(valueType),UserRole); /// Value type Процент / Цена
        m->setData(modelRow, 4, boost::any(m_rbGroup->checkedId()),UserRole); /// PriceType Динамический статический
        m->setData(modelRow, 5, boost::any(modifyStatic),UserRole); /// Изменять фиксированные цены
        m->setData(modelRow, 6, boost::any(m_dpModified->date()),UserRole);
        m->setData(modelRow, 7, boost::any(m_roundingMethod->currentIndex()+1),UserRole);

        int priceType = ((m_rbGroup->checkedId()-1)<<1) | (valueType-1);
        bool changeFixed = false;
        WDate modifiDate = WDate::currentDate();

#ifdef DEBUG
        log("info")<<"updateUserPrice(m_id "<<m_id<<",valueType "<<valueType<<",value "<<value<<",priceType "<<priceType<<",changeFixed "<<changeFixed<<",modifiDate "<<modifiDate.toString()<<" rounding "<<m_roundingMethod->currentIndex()+1<<" ) "<<__LINE__;
#endif

        ((Portal *)WApplication::instance())->getSession()->updateUserPrice(m_id,valueType,value,priceType,changeFixed,modifiDate,m_roundingMethod->currentIndex()+1);
    }

    delete this;
}
示例#6
0
文件: DateField.C 项目: 913862627/wt
void DateField::setDate(const WDate& date)
{
  lineEdit()->setText(date.toString(format_));
}