private void CreateControls()
        {
            this.GenControls.Clear();
            this.panel1.Controls.Clear();

            foreach (DataRow row in FormFields.Rows)
            {
                var groupName   = row.Item("GroupName");
                var controlType = row.Item("ControlType");

                var control = CreateGenControl(groupName, controlType);

                control.Margin          = new System.Windows.Forms.Padding(0);
                control.FieldName       = row.Item("FieldName");
                control.FieldCaption    = row.Item("FieldCaption");
                control.LookupSource    = row.Item("LookupSource");
                control.WidthPercentage = ConvertSafe.ToInt32(row.Item("WidthPercentage"));
                control.HeightPixel     = ConvertSafe.ToInt32(row.Item("HeightPixel"));
                control.IsRequired      = ConvertSafe.ToBoolean(row.Item("IsRequired"));
                control.IsReadOnly      = ConvertSafe.ToBoolean(row.Item("IsReadOnly"));

                control.Initialize(Services);
                control.Process();
            }
        }
        public override void Process()
        {
            base.Process();

            _radioButton          = new RadioButton();
            _radioButton.Text     = _SingleChoice_View_Answer_AnswerText;
            _radioButton.AutoSize = true;
            _radioButton.Font     = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            _radioButton.Location = new System.Drawing.Point(3, 3);
            _radioButton.UseVisualStyleBackColor = true;

            _radioButton.CheckedChanged += _radioButton_CheckedChanged;
            customFlowLayoutPanel1.Controls.Add(_radioButton);

            if (ConvertSafe.ToBoolean(_SingleChoice_View_Answer_AnswerCodes_OtherSpecify) == true)
            {
                _radioButton.Width = 350;
                _textBox           = new TextEdit();
                _textBox.Width     = customFlowLayoutPanel1.Width - _radioButton.Width - 150;
                _textBox.Font      = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                customFlowLayoutPanel1.Controls.Add(_textBox);
            }

            _radioButton_CheckedChanged(null, null);
            customFlowLayoutPanel1_Resize(null, null);
        }
Пример #3
0
        internal void SelectStringValue(string p)
        {
            if (CheckExistEnable() == true)
            {
                return;
            }
            List <String> listAnswerCode = new List <string>();

            foreach (Control ctr in customFlowLayoutPanel1.Controls)
            {
                if (ctr.GetType() == typeof(GenSingleRadioButtonUnit) && ConvertSafe.ToBoolean(((GenSingleRadioButtonUnit)ctr)._SingleChoice_View_Answer_AnswerCodes_OtherSpecify) == false)
                {
                    listAnswerCode.Add(((GenSingleRadioButtonUnit)ctr)._SingleChoice_View_Answer_AnswerCoding);
                }
            }

            //lay ki tu cuoi cùng



            int maxCountLength = findMaxCountLengthAnswerCode(listAnswerCode);

            if (p.Length < maxCountLength)
            {
                return;
            }

            string lastAnswer = p.Substring(p.Length - maxCountLength, maxCountLength);

            foreach (Control ctr in customFlowLayoutPanel1.Controls)
            {
                if (ctr.GetType() == typeof(GenSingleRadioButtonUnit))
                {
                    string covertAnswerCode = ((GenSingleRadioButtonUnit)ctr)._SingleChoice_View_Answer_AnswerCoding;

                    while (covertAnswerCode.Length < maxCountLength)
                    {
                        covertAnswerCode = "0" + covertAnswerCode;
                    }

                    if (covertAnswerCode == lastAnswer && ((GenSingleRadioButtonUnit)ctr).Visible == true && ConvertSafe.ToBoolean(((GenSingleRadioButtonUnit)ctr)._SingleChoice_View_Answer_AnswerCodes_OtherSpecify) == false)
                    {
                        (ctr as GenSingleRadioButtonUnit).Checked = true;
                        //this.RaiseEvent(KeyF1Press);
                    }
                    else
                    {
                        (ctr as GenSingleRadioButtonUnit).Checked = false;
                    }
                }
            }
        }
        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            var row = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            if (row == null)
            {
                return;
            }
            SelectedProjectNo          = row.Item("ProjectNo");
            SelectedProjectID          = row.Item("ProjectID");
            SelectedCityHandle         = row.Item("CityHandle");
            SelectedIsNeedPlaceProduct = ConvertSafe.ToBoolean(row.Item("IsNeedPlaceProduct"));
            DialogResult = DialogResult.OK;
        }
        private void gvProjects_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e)
        {
            GridView View = sender as GridView;

            if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Start)
            {
                count = 0;
            }
            if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Calculate)
            {
                if (ConvertSafe.ToBoolean(View.GetDataRow(e.RowHandle).Item("ProjectIsActived")) == true)
                {
                    count = count + 1;
                }
                e.TotalValue = count;
            }
            if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Finalize)
            {
            }
        }
Пример #6
0
        public TryLoadSettingsFromSql LoadSqlMainSettingsFromSQL()
        {
            DataSet ds = null;

            ds = SqlWorks.ExecProcExt(MainSettings.JsonSettings.ConnectionString, "GetComputerSettingsViaMac", HardwareInfo.GetMacAddress());
            if (ds != null)
            {
                ComputerId    = ConvertSafe.ToInt32(ds.Tables[0].Rows[0]["ComputerId"]);
                ShopID        = ConvertSafe.ToString(ds.Tables[0].Rows[0]["ShopId"]);
                Is1CServer    = ConvertSafe.ToBoolean(ds.Tables[0].Rows[0]["Is1CServer"]);
                IsMainCashbox = ConvertSafe.ToBoolean(ds.Tables[0].Rows[0]["IsMainCashbox"]);
                return(new TryLoadSettingsFromSql());
            }
            else
            {
                ComputerId    = 0;
                ShopID        = string.Empty;
                Is1CServer    = false;
                IsMainCashbox = false;
                return(new TryLoadSettingsFromSql(false, "Компьтер не зарегистрирован."));
            }
        }
        private void btnProperties_Click(object sender, EventArgs e)
        {
            var row = gvAnswers.GetDataRow(gvAnswers.FocusedRowHandle);

            if (row == null)
            {
                return;
            }
            using (var frm = new Properties.frmPropertiesMultiChoice())
            {
                frm.Initialize(Services);
                frm.Process(row);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    //update lai table
                    var rowHandle = ConvertSafe.ToInt32(frm.MultiChoice_View_Answer_AnswerIndex) - 1;
                    gvAnswers.SetRowCellValue(rowHandle, "MultiChoice_View_Answer_AnswerText", frm.MultiChoice_View_Answer_AnswerText);
                    gvAnswers.SetRowCellValue(rowHandle, "MultiChoice_View_Answer_AnswerCodes_VariableName", frm.MultiChoice_View_Answer_AnswerCodes_VariableName);
                    gvAnswers.SetRowCellValue(rowHandle, "MultiChoice_View_Answer_AnswerCodes_UnCheckedCode", ConvertSafe.ToInt32(frm.MultiChoice_View_Answer_AnswerCodes_UnCheckedCode));
                    gvAnswers.SetRowCellValue(rowHandle, "MultiChoice_View_Answer_AnswerCodes_CheckedCode", ConvertSafe.ToInt32(frm.MultiChoice_View_Answer_AnswerCodes_CheckedCode));
                    gvAnswers.SetRowCellValue(rowHandle, "MultiChoice_View_Answer_AnswerCodes_OtherSpecify", ConvertSafe.ToBoolean(frm.MultiChoice_View_Answer_AnswerCodes_OtherSpecify));
                    gvAnswers.SetRowCellValue(rowHandle, "MultiChoice_View_Answer_AnswerCodes_OtherSpecify_VariableName", frm.MultiChoice_View_Answer_AnswerCodes_OtherSpecify_VariableName);
                    gvAnswers.SetRowCellValue(rowHandle, "MultiChoice_View_Answer_AnswerCodes_OtherSpecify_InType", frm.MultiChoice_View_Answer_AnswerCodes_OtherSpecify_InType);
                    gvAnswers.UpdateCurrentRow();
                }
            }
        }
Пример #8
0
        private void cbQuestion_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbQuestion.SelectedValue == null)
            {
                cbQuestionCode.SelectedIndex = -1;
                return;
            }

            DataTable data = (cbQuestion.DataSource as DataTable);
            var       row  = data.Rows[cbQuestion.SelectedIndex];

            if (row == null)
            {
                cbRule.SelectedIndex = -1;
                return;
            }

            var dt = new DataTable();

            dt.Columns.Add("QuestionID", typeof(string));
            dt.Columns.Add("FieldName", typeof(string));
            dt.Columns.Add("FieldValue", typeof(string));
            if (row.Item("QuestionTypeName") == "Free Text")
            {
                var new_row = dt.NewRow();
                new_row["QuestionID"] = row.Item("QuestionID");
                new_row["FieldName"]  = row.Item("FreeText_Variables_VariablesName");
                new_row["FieldValue"] = "";

                dt.Rows.Add(new_row);
            }
            if (row.Item("QuestionTypeName") == "Single Choice")
            {
                var answer_list = row.Item("SingleChoice_Answer_AnswerList").JSONToDataTable();
                foreach (DataRow r in answer_list.Rows)
                {
                    var new_row = dt.NewRow();
                    new_row["QuestionID"] = row.Item("QuestionID");
                    new_row["FieldName"]  = r.Item("SingleChoice_View_Answer_AnswerCodes_VariableName");
                    new_row["FieldValue"] = "";
                    dt.Rows.Add(new_row);

                    if (ConvertSafe.ToBoolean(r.Item("SingleChoice_View_Answer_AnswerCodes_OtherSpecify")) == true)
                    {
                        var c_new_row = dt.NewRow();
                        c_new_row["QuestionID"] = row.Item("QuestionID");
                        c_new_row["FieldName"]  = r.Item("SingleChoice_View_Answer_AnswerCodes_OtherSpecify_VariableName");
                        c_new_row["FieldValue"] = "";
                        dt.Rows.Add(c_new_row);
                    }
                }
            }

            if (row.Item("QuestionTypeName") == "Multi Choice")
            {
                var answer_list = row.Item("MultiChoice_Answer_AnswerList").JSONToDataTable();
                foreach (DataRow r in answer_list.Rows)
                {
                    var new_row = dt.NewRow();
                    new_row["QuestionID"] = row.Item("QuestionID");
                    new_row["FieldName"]  = r.Item("MultiChoice_View_Answer_AnswerCodes_VariableName");
                    new_row["FieldValue"] = "";
                    dt.Rows.Add(new_row);

                    if (ConvertSafe.ToBoolean(r.Item("MultiChoice_View_Answer_AnswerCodes_OtherSpecify")) == true)
                    {
                        var c_new_row = dt.NewRow();
                        c_new_row["QuestionID"] = row.Item("QuestionID");
                        c_new_row["FieldName"]  = r.Item("MultiChoice_View_Answer_AnswerCodes_OtherSpecify_VariableName");
                        c_new_row["FieldValue"] = "";
                        dt.Rows.Add(c_new_row);
                    }
                }
            }
            cbQuestionCode.DataSource = dt;
        }
        private DataTable GetDataView(DataTable tblQuestion, DataTable tblData)
        {
            foreach (DataRow row in tblQuestion.Rows)
            {
                row["QuestionName"] = HtmlToPlainText(row.Item("QuestionNameHTMLText"));
                int QuestionTypeID = ConvertSafe.ToInt32(row.Item("QuestionTypeID"));
                if (QuestionTypeID == 1)
                {
                    //tim tat ca nhung cau tra loi
                    var values = tblData.Select(string.Format("QuestionCode='{0}'", row.Item("QuestionCode")));
                    if (values.Count() > 0)
                    {
                        //tim value da chon luc truoc.
                        string result      = "";
                        bool   IsLocked    = false;
                        string valueSelect = tblData._FindValue("AnswerText", "FieldName", row.Item("QuestionCode"));
                        result = valueSelect;
                        //tim value khac
                        foreach (DataRow c_row in values)
                        {
                            if (c_row.Item("FieldName") != row.Item("QuestionCode"))
                            {
                                if (c_row.Item("AnswerText").IsNotEmpty())
                                {
                                    result += "[" + c_row.Item("AnswerText") + "]";
                                }
                            }

                            if (ConvertSafe.ToBoolean(c_row.Item("IsLocked")) == true)
                            {
                                IsLocked = true;
                            }
                        }
                        row["checked"]    = IsLocked;
                        row["AnswerText"] = result;
                    }
                }
                if (QuestionTypeID == 2)
                {
                    var values = tblData.Select(string.Format("QuestionCode='{0}'", row.Item("QuestionCode")));
                    if (values.Count() > 0)
                    {
                        //tim value da chon luc truoc.
                        string result   = "";
                        bool   IsLocked = false;
                        var    dt       = row.Item("MultiChoice_Answer_AnswerList").JSONToDataTable();

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            var    c_row     = dt.Rows[i];
                            string var_name  = c_row.Item("MultiChoice_View_Answer_AnswerCodes_VariableName");
                            string valuetext = tblData._FindValue("AnswerText", "FieldName", var_name);
                            if (valuetext.IsNotEmpty())
                            {
                                result += valuetext;
                                string valuetextOther = tblData._FindValue("AnswerText", "FieldName", row.Item("QuestionCode") + "_" + c_row.Item("MultiChoice_View_Answer_AnswerCodes_VariableName") + "_K");
                                if (valuetextOther.IsNotEmpty())
                                {
                                    result += "[" + valuetextOther + "]";
                                }
                                result += Environment.NewLine;
                            }
                        }
                        foreach (var row_c in values)
                        {
                            if (ConvertSafe.ToBoolean(row_c.Item("IsLocked")) == true)
                            {
                                IsLocked = true;
                            }
                        }
                        row["checked"]    = IsLocked;
                        row["AnswerText"] = result;
                    }
                }
                if (QuestionTypeID == 3)
                {
                    bool IsLocked = false;


                    row["AnswerText"] = tblData._FindValue("AnswerText", "FieldName", row.Item("QuestionCode"));

                    var values = tblData.Select(string.Format("QuestionCode='{0}'", row.Item("QuestionCode")));
                    foreach (var row_c in values)
                    {
                        if (ConvertSafe.ToBoolean(row_c.Item("IsLocked")) == true)
                        {
                            IsLocked = true;
                        }
                    }
                    row["checked"] = IsLocked;
                }

                if (QuestionTypeID == 5)
                {
                }
                if (QuestionTypeID == 6)
                {
                }
                if (QuestionTypeID == 7)
                {
                    bool IsLocked = false;
                    row["AnswerText"] = tblData._FindValue("AnswerText", "FieldName", row.Item("QuestionCode"));

                    var values = tblData.Select(string.Format("QuestionCode='{0}'", row.Item("QuestionCode")));
                    foreach (var row_c in values)
                    {
                        if (ConvertSafe.ToBoolean(row_c.Item("IsLocked")) == true)
                        {
                            IsLocked = true;
                        }
                    }

                    row["checked"] = IsLocked;
                }
            }

            return(tblQuestion);
        }
Пример #10
0
 internal void SelectValue(int p)
 {
     //kiem tra xem co textbox nao dang enable k???
     if (CheckExistEnable() == true)
     {
         return;
     }
     foreach (Control ctr in customFlowLayoutPanel1.Controls)
     {
         if (ctr.GetType() == typeof(GenSingleRadioButtonUnit))
         {
             if (((GenSingleRadioButtonUnit)ctr)._SingleChoice_View_Answer_AnswerCoding == p.ToString() && ((GenSingleRadioButtonUnit)ctr).Visible == true && ConvertSafe.ToBoolean(((GenSingleRadioButtonUnit)ctr)._SingleChoice_View_Answer_AnswerCodes_OtherSpecify) == false)
             {
                 (ctr as GenSingleRadioButtonUnit).Checked = true;
                 //this.RaiseEvent(KeyF1Press);
             }
             else
             {
                 (ctr as GenSingleRadioButtonUnit).Checked = true;
             }
         }
     }
 }