Esempio n. 1
0
        void btnOk_Click(object sender, EventArgs e)
        {
            #region 延伸服务支付XML
            string xmlQuesInfo = TmoShare.XML_TITLE +
                                 @"<tmo_extendservice_list>
      <service_id></service_id>
      <user_code></user_code>
      <user_times></user_times>
      <money></money>
      <doc_code></doc_code>
      <is_del></is_del>
      <pay_time></pay_time>
      </tmo_extendservice_list>";
            #endregion

            if (string.IsNullOrEmpty(money.Text))
            {
                DXMessageBox.Show("请您先输入金额!", MessageIcon.Warning, MessageButton.OK);
                money.Focus();
                return;
            }

            if (!TmoShare.IsNumeric(money.Text))
            {
                DXMessageBox.Show("请您输入金额有误!", MessageIcon.Warning, MessageButton.OK);
                money.Text = "";
                money.Focus();
                return;
            }

            DataSet ds  = TmoShare.getDataSetFromXML(xmlQuesInfo, true);
            DataRow dr0 = ds.Tables[0].NewRow();
            foreach (DataColumn dc in ds.Tables[0].Columns)
            {
                switch (dc.ColumnName)
                {
                case "money":
                    dr0[dc] = money.Text;
                    break;

                case "user_code":
                    dr0[dc] = user_code.Text;
                    break;

                case "user_times":
                    dr0[dc] = user_times.Text;
                    break;

                case "doc_code":
                    dr0[dc] = TmoComm.login_docInfo.doc_id;
                    break;

                default:
                    break;
                }
            }
            ds.Tables[0].Rows.Add(dr0);
            ds.AcceptChanges();
            string quesXml = ds.GetXml();
            quesXml = TmoShare.XML_TITLE + quesXml;

            object obj = TmoServiceClient.InvokeServerMethodT <bool>(funCode.UpdatePayType, quesXml);
            if (Convert.ToBoolean(obj))
            {
                DXMessageBox.Show("产品购买成功!", true);
                if (this.ParentForm != null)
                {
                    this.ParentForm.DialogResult = DialogResult.OK;
                    this.ParentForm.Close();
                }
            }
            else
            {
                DXMessageBox.Show("产品购买失败!", true);
            }
        }
Esempio n. 2
0
        public UCQuestion(tmo_questionnaire question)
        {
            InitializeComponent();
            BackColor = Color.Transparent;                //背景透明

            Question = question;                          //题目赋值
            //题目类型 1-判断题 2-选择题 3-多项选择题 4-填空题 5-问答题
            if (question.q_type == 2)                     //选择题
            {
                if (question.q_value_type.Equals("bool")) //bool类型
                {
                    _type = typeof(bool?);
                    var tmp = new UcRadioGroup <bool?>(question.q_value, question.QuestionnaireResult.qr_result);
                    tmp.SelectedChanged += (sender, args) => OnValueChanged();
                    _valueControls.Add(tmp);
                }
                else if (question.q_value_type.Equals("datetime")) //date类型
                {
                    _type = typeof(DateTime);
                    var tmp = new UcRadioGroup <DateTime>(question.q_value, question.QuestionnaireResult.qr_result);
                    tmp.SelectedChanged += (sender, args) => OnValueChanged();
                    _valueControls.Add(tmp);
                }
                else if (question.q_value_type.Equals("float")) //float类型
                {
                    _type = typeof(float);
                    var tmp = new UcRadioGroup <float>(question.q_value, question.QuestionnaireResult.qr_result);
                    tmp.SelectedChanged += (sender, args) => OnValueChanged();
                    _valueControls.Add(tmp);
                }
                else if (question.q_value_type.Equals("string")) //string类型
                {
                    _type = typeof(string);
                    var tmp = new UcRadioGroup <string>(question.q_value, question.QuestionnaireResult.qr_result);
                    tmp.SelectedChanged += (sender, args) => OnValueChanged();
                    _valueControls.Add(tmp);
                }
            }

            if (question.q_type == 3)                      //多选题
            {
                if (question.q_value_type.Equals("int[]")) //int类型
                {
                    _type = typeof(int[]);
                    var tmp = new CheckBoxGroup <int>(question.q_value, question.QuestionnaireResult.qr_result);
                    tmp.SelectedChanged += (sender, args) => OnValueChanged();
                    _valueControls.Add(tmp);
                }
            }

            if (question.q_type == 4)                      //填空题
            {
                if (question.q_value_type.Equals("float")) //float类型
                {
                    _type = typeof(float);
                }

                flowLayoutPanel1.FlowDirection = FlowDirection.LeftToRight;
                string[] values = TmoShare.GetValueFromJson <string[]>(Question.QuestionnaireResult.qr_result, false);
                if (values == null)
                {
                    values = new[] { TmoShare.GetValueFromJson <string>(question.QuestionnaireResult.qr_result) }
                }
                ;
                int    vindex = 0;
                string tmp    = question.q_name;
                int    index  = -1;
                do
                {
                    index = tmp.IndexOf('{');
                    string thisstr = index == -1 ? tmp : tmp.Substring(0, index);
                    if (_valueControls.Count == 0)
                    {
                        lblQuestion.Text = string.Format("{0:00}. {1}", question.q_no, thisstr);
                    }
                    else
                    {
                        Label lbl = new Label();
                        lbl.Margin   = new Padding(0, top, 0, 0);
                        lbl.Text     = thisstr;
                        lbl.Font     = lblQuestion.Font;
                        lbl.AutoSize = true;
                        flowLayoutPanel1.Controls.Add(lbl);
                    }

                    if (index != -1)
                    {
                        string laststr   = tmp.Remove(0, index + 1);
                        string lengthstr = new string(laststr.TakeWhile(x => TmoShare.IsNumeric(x)).ToArray());
                        laststr = laststr.Remove(0, lengthstr.Length + 1);

                        string value = null;
                        if (vindex < values.Length)
                        {
                            value = values[vindex];
                            vindex++;
                        }

                        TextBox txtBox = new TextBox();
                        txtBox.Width        = Convert.ToInt32(lengthstr);
                        txtBox.Text         = value;
                        txtBox.Margin       = new Padding(0);
                        txtBox.TextChanged += (sender, args) => OnValueChanged();
                        flowLayoutPanel1.Controls.Add(txtBox);
                        _valueControls.Add(txtBox);

                        tmp = laststr;
                    }
                } while (index != -1);
            }
            else
            {
                lblQuestion.Text = string.Format("{0}. {1}", question.q_no.ToString("00"), question.q_name);
                flowLayoutPanel1.Controls.AddRange(_valueControls.ToArray());
            }

            SetupLocation();
        }

        /// <summary>
        /// 设置控件位置
        /// </summary>
        void SetupLocation()
        {
            Width        = width; //设置整体宽度
            picIcon.Left = left;
            picIcon.Top  = top + 2;
            //flowLayoutPanel1.Left = left + picIcon.Width + 3;
            flowLayoutPanel1.Width = flowLayoutPanel2.Width = width - left - picIcon.Width - 3;
            lblQuestion.Margin     = lblTip.Margin = new Padding(0, top, 0, 0);

            //Size size = new Size(flowLayoutPanel1.Width, int.MaxValue);
            //lblQuestion.Size = TextRenderer.MeasureText(lblQuestion.Text, lblQuestion.Font, size);
            if (_valueControls.Any())
            {
                if (flowLayoutPanel1.FlowDirection == FlowDirection.LeftToRight)
                {
                    _valueControls.ForEach(x => x.Margin = new Padding(0, top, 0, 0));
                    Height = top + lblQuestion.Height + top;
                }
                else
                {
                    _valueControls.ForEach(x => x.Margin = new Padding(25, 3, 0, 0));
                    Height = top + lblQuestion.Height + 3 + _valueControls.First().Height + top;
                }
            }
            else
            {
                Height = top + lblQuestion.Height + top;
            }

            //flowLayoutPanel1.Height = Height;
        }