Exemplo n.º 1
0
 public abstract List <NameValueItem> GetSourceList(ModuleInfo moduleInfo, ModuleFieldInfo fieldInfo, List <string> values);
        public BaseEdit CreateLookUpEditControl(ModuleFieldInfo fieldInfo)
        {
            //
            var expression = ExpressionUtils.ParseScript(fieldInfo.ListSource);

            if (expression.Operands.Count != 1 && expression.Operands.Count != 2)
            {
                ErrorUtils.CreateError(ERR_SYSTEM.ERR_SYSTEM_LOOKUP_EXPRESSION_REQUIRE_ONE_OR_TWO_ARGUMENTS);
            }

            foreach (var operand in expression.Operands)
            {
                if (operand.Type != OperandType.VALUE)
                {
                    ErrorUtils.CreateError(ERR_SYSTEM.ERR_SYSTEM_LOOKUP_EXPRESSION_CAN_NOT_CONTAIN_NAME);
                }
            }
            //
            var moduleLookUp = (SearchModuleInfo)((ICloneable)ModuleUtils.GetModuleInfo(expression.StoreProcName, CODES.DEFMOD.SUBMOD.MODULE_MAIN)).Clone();

            if (expression.Operands.Count == 1)
            {
                moduleLookUp.SetAsLookUpWindow(expression.Operands[0].NameOrValue);
            }
            else
            {
                moduleLookUp.SetAsLookUpWindow(expression.Operands[0].NameOrValue, expression.Operands[1].NameOrValue);
            }
            //
            var btnEdit = new ButtonEdit();

            btnEdit.Properties.Buttons[0].Tag      = moduleLookUp;
            btnEdit.Properties.Buttons[0].Shortcut = new DevExpress.Utils.KeyShortcut(Keys.F5);
            btnEdit.Properties.Buttons.Add(new EditorButton(ButtonPredefines.Delete));

            btnEdit.ButtonClick +=
                delegate(object sender, ButtonPressedEventArgs e)
            {
                if (e.Button.Kind == ButtonPredefines.Delete)
                {
                    btnEdit.EditValue = string.Empty;
                }
                else if (e.Button.Tag is ModuleInfo)
                {
                    var module = (ucSearchMaster)MainProcess.CreateModuleInstance((ModuleInfo)e.Button.Tag);
                    module.ShowDialogModule(this);

                    if (!string.IsNullOrEmpty(module.LookUpValues))
                    {
                        if (btnEdit.EditValue is string && (string)btnEdit.EditValue != string.Empty)
                        {
                            btnEdit.EditValue = string.Format("{0},{1}", btnEdit.EditValue, module.LookUpValues);
                        }
                        else
                        {
                            btnEdit.EditValue = module.LookUpValues;
                        }
                    }
                }
            };
            return(btnEdit);
        }
        protected virtual PopupContainerEdit CreateCheckedComboBoxControl(ModuleFieldInfo fieldInfo)
        {
            // 1. Create Popup Edit
            var ccbControl = new PopupContainerEdit
            {
                Name = string.Format(CONSTANTS.CHECKEDCOMBOBOX_NAME_FORMAT, fieldInfo.FieldName),
                Tag  = fieldInfo,
                EnterMoveNextControl = true,
                EditValue            = null
            };

            //ccbControl.Properties.TextEditStyle = TextEditStyles.Standard;
            ccbControl.Properties.TextEditStyle    = TextEditStyles.DisableTextEditor;
            ccbControl.Properties.PopupFormMinSize = new Size(750, 350);
            ccbControl.Properties.PopupResizeMode  = ResizeMode.FrameResize;

            // 2. Create Items & Buttons Panel
            var hozItemsPanel   = CreateItemsPanel();
            var hozButtonsPanel = CreateButtonsPanel(hozItemsPanel);

            // 3. Create Popup
            var ccbPopup = new PopupContainerControl
            {
                Tag      = fieldInfo,
                AutoSize = true
            };

            // Create Popup --> Add Popup to Edit
            ccbControl.Properties.PopupControl = ccbPopup;
            ccbControl.Properties.Tag          = hozItemsPanel;

            // 4. Create Bound Panel
            var boundPanel = new TableLayoutPanel
            {
                Dock        = DockStyle.Fill,
                RowCount    = 2,
                ColumnCount = 1
            };

            // Bound Panel --> Add Items & Buttons Panel to Bound Panel
            boundPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            boundPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));
            boundPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            boundPanel.Controls.Add(hozButtonsPanel, 0, 0);
            boundPanel.Controls.Add(hozItemsPanel, 0, 1);
            // Bound Panel --> Add to Popup
            ccbPopup.Controls.Add(boundPanel);

            // QueryPopup => Check item which has in Text
            ccbControl.QueryPopUp += delegate
            {
                hozItemsPanel.SuspendLayout();
                var list = ccbControl.Text.Split(',');
                foreach (CheckEdit value in hozItemsPanel.Controls)
                {
                    value.CheckState = list.Contains(value.Tag.ToString()) ?
                                       //value.CheckState = list.Contains(value.Text.ToString()) ?
                                       CheckState.Checked : CheckState.Unchecked;
                }
                ccbPopup.Width = ccbControl.Width;
                hozItemsPanel.ResumeLayout(true);
            };
            // QueryResultValue => Parse checked items to Text
            ccbControl.QueryResultValue += delegate(object sender, QueryResultValueEventArgs e)
            {
                var list = (from CheckEdit item in hozItemsPanel.Controls
                            where item.Checked
                            //select item.Text.ToString()).ToArray();
                            select item.Tag.ToString()).ToArray();
                e.Value = string.Join(",", list);
            };

            return(ccbControl);
        }
 public virtual void SetupControlListSourceControl(ModuleFieldInfo fieldInfo, Control edit)
 {
     SetControlListSource(edit);
 }
        //ORG: BaseEdit --> Control
        public virtual Control _CreateControl(ModuleFieldInfo fieldInfo)
        {
            switch (fieldInfo.ControlType)
            {
            case CODES.DEFMODFLD.CTRLTYPE.TEXTBOX:
                return(CreateTextBoxControl(fieldInfo));

            case CODES.DEFMODFLD.CTRLTYPE.LABEL:
                return(CreateLabelControl(fieldInfo));

            case CODES.DEFMODFLD.CTRLTYPE.FILESAVE:
                return(CreateFileSaveControl(fieldInfo));

            case CODES.DEFMODFLD.CTRLTYPE.SPINEDITOR:
                return(CreateSpinEditControl(fieldInfo));

            case CODES.DEFMODFLD.CTRLTYPE.COMBOBOX:
                var comboBoxEdit = CreateComboBoxControl(fieldInfo);
                if (fieldInfo.Nullable == CODES.DEFMODFLD.NULLABLE.YES)
                {
                    var editButton = new EditorButton(ButtonPredefines.Ellipsis);
                    comboBoxEdit.Properties.Buttons.Add(editButton);

                    comboBoxEdit.ButtonClick += delegate(object sender, ButtonPressedEventArgs e)
                    {
                        if (e.Button == editButton)
                        {
                            comboBoxEdit.EditValue = null;
                            comboBoxEdit.ClosePopup();
                        }
                    };
                }
                return(comboBoxEdit);

            case CODES.DEFMODFLD.CTRLTYPE.PASSWORD:
                return(CreatePasswordControl(fieldInfo));

            case CODES.DEFMODFLD.CTRLTYPE.TEXTAREA:
                return(CreateTextAreaControl(fieldInfo));

            case CODES.DEFMODFLD.CTRLTYPE.SUGGESTIONTEXTBOX:
                var suggestionTextEdit = CreateSuggestionTextBoxControl(fieldInfo);
                return(suggestionTextEdit);

            case CODES.DEFMODFLD.CTRLTYPE.DATETIME:
                var dateEdit = CreateDateEdit(fieldInfo);
                if (string.IsNullOrEmpty(fieldInfo.FieldFormat))
                {
                    fieldInfo.FieldFormat = CONSTANTS.DEFAULT_DATETIME_FORMAT;
                }
                return(dateEdit);

            case CODES.DEFMODFLD.CTRLTYPE.CHECKEDCOMBOBOX:
                var ccbControl = CreateCheckedComboBoxControl(fieldInfo);
                return(ccbControl);

            case CODES.DEFMODFLD.CTRLTYPE.LOOKUPVALUES:
                var editLookUp = CreateLookUpEditControl(fieldInfo);
                return(editLookUp);

            case CODES.DEFMODFLD.CTRLTYPE.UPLOADFILE:
                return(CreateOpenFileControl(fieldInfo));

            case CODES.DEFMODFLD.CTRLTYPE.RICHTEXTEDITOR:
                return(CreateRichTextEdit(fieldInfo));

            //add by TrungTT - 28.11.2011 - Create GridView Control
            case CODES.DEFMODFLD.CTRLTYPE.GRIDVIEW:
                return(CreateGridViewControl(fieldInfo));

            //End TrungTT
            //TuDQ them
            case CODES.DEFMODFLD.CTRLTYPE.RADIOGROUP:
                var radioGroupEdit = CreateRadioGroupControl(fieldInfo);
                return(radioGroupEdit);

            case CODES.DEFMODFLD.CTRLTYPE.CHECKBOX:
                var checkBoxEdit = CreateCheckBoxControl(fieldInfo);
                return(checkBoxEdit);
                //End
            }

            throw ErrorUtils.CreateError(ERR_SYSTEM.ERR_SYSTEM_CONTROL_TYPE_NOT_FOUND);
        }
Exemplo n.º 6
0
 internal void SetCondition(ModuleFieldInfo fieldInfo)
 {
     m_Condition.EditValue = fieldInfo;
 }
        //private void view_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        //{
        //    MessageBox.Show("shit");
        //}
        //ORG: BaseEdit --> Control
        public virtual Control CreateControl(ModuleFieldInfo fieldInfo)
        {
            var baseEdit = _CreateControl(fieldInfo);

#if DEBUG
            if (baseEdit is ButtonEdit && fieldInfo.FieldGroup == CODES.DEFMODFLD.FLDGROUP.COMMON)
            {
                var buttonEdit = baseEdit as ButtonEdit;
                var button     = new EditorButton(ButtonPredefines.Up)
                {
                    Tag = "DEBUG_EDIT"
                };
                buttonEdit.Properties.Buttons.Add(button);

                var context = new ContextMenuStrip();
                context.Items.Add("Edit Field", ThemeUtils.Image16.Images["EDIT"]).Click +=
                    delegate
                {
                    var ucModule = MainProcess.CreateModuleInstance("02904", "MED");
                    ucModule["P01"] = fieldInfo.ModuleID;
                    ucModule["C01"] = fieldInfo.FieldID;
                    ucModule.ShowDialogModule(this);
                };

                if (!string.IsNullOrEmpty(fieldInfo.ListSource))
                {
                    var match = Regex.Match(fieldInfo.ListSource, "^:([^.]+).([^.]+)$");
                    context.Items.Add("Translate Code", ThemeUtils.Image16.Images["CODE"]).Click +=
                        delegate
                    {
                        var ucModule = (ucEditLanguage)MainProcess.CreateModuleInstance(STATICMODULE.EDITLANG, "MMN");
                        ucModule.mainView.ActiveFilterString = string.Format("LANGNAME LIKE 'DEFCODE${0}${1}.%'", match.Groups[1].Value, match.Groups[2].Value);
                        ucModule.Execute();
                        ucModule.ShowDialogModule(this);
                    };
                }

                context.Items.Add("List Common Field", ThemeUtils.Image16.Images["COMMON"]).Click +=
                    delegate
                {
                    var ucModule = MainProcess.CreateModuleInstance("03905", "MMN");
                    ucModule["C01"] = fieldInfo.ModuleID;
                    ucModule.ShowDialogModule(this);
                    ucModule.Execute();
                };

                buttonEdit.ButtonClick +=
                    delegate(object sender, ButtonPressedEventArgs e)
                {
                    if (e.Button == button)
                    {
                        context.Show(new Point(MousePosition.X, MousePosition.Y));
                    }
                };
            }
#endif
            if (baseEdit is BaseEdit)
            {
                if (fieldInfo.ControlType == CODES.DEFMODFLD.CTRLTYPE.LABEL)
                {
                    SetReadOnly((BaseEdit)baseEdit, true);
                }
                else
                {
                    if (ModuleInfo.SubModule == CODES.DEFMOD.SUBMOD.MAINTAIN_ADD &&
                        fieldInfo.ReadOnlyOnAdd == CODES.DEFMODFLD.READONLYMODE.READONLY)
                    {
                        SetReadOnly((BaseEdit)baseEdit, true);
                    }

                    if (ModuleInfo.SubModule == CODES.DEFMOD.SUBMOD.MAINTAIN_EDIT &&
                        fieldInfo.ReadOnlyOnEdit == CODES.DEFMODFLD.READONLYMODE.READONLY)
                    {
                        SetReadOnly((BaseEdit)baseEdit, true);
                    }

                    if ((ModuleInfo.SubModule == CODES.DEFMOD.SUBMOD.MAINTAIN_VIEW ||
                         ModuleInfo.SubModule == CODES.DEFMOD.SUBMOD.MODULE_MAIN) &&
                        fieldInfo.ReadOnlyOnView == CODES.DEFMODFLD.READONLYMODE.READONLY)
                    {
                        SetReadOnly((BaseEdit)baseEdit, true);
                    }
                }

                if (fieldInfo.TabStop == CODES.DEFMODFLD.TABSTOP.NO)
                {
                    (baseEdit as BaseEdit).Properties.AllowFocused = false;
                    baseEdit.TabStop = false;
                }

                if (fieldInfo.PopupMode == CODES.DEFMODFLD.POPUPMODE.ONFOCUS)
                {
                    var popupRepo = (baseEdit as BaseEdit).Properties as RepositoryItemPopupBaseAutoSearchEdit;
                    if (popupRepo != null)
                    {
                        popupRepo.ImmediatePopup = true;
                    }
                }

                ApplyFormatInfo(fieldInfo, (BaseEdit)baseEdit);
            }

            return(baseEdit);
        }
Exemplo n.º 8
0
 public void BindData()
 {
     if (base.Request["action"] == null && base.Request["infoId"] == null)
     {
         ModuleListInfo moduleListInfo = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         if (base.Request["sortType"] != null && base.Request["sortType"] == "2")
         {
             MySqlDataReader mySqlDataReader = this.db.RunProcGetReader(string.Concat(new object[]
             {
                 "select * from [",
                 moduleListInfo.ModuleTableName,
                 "] where sortId=",
                 int.Parse(base.Request["sortId"].Trim()),
                 " order by id limit 1"
             }));
             if (mySqlDataReader.Read())
             {
                 this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo.ModuleName + "</th></tr>");
                 List <ModuleFieldInfo> list = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo.Id + " order by FieldOrder");
                 for (int i = 0; i < list.Count; i++)
                 {
                     this.sb.AppendLine(string.Concat(new string[]
                     {
                         "<tr><Td width=18% id=tdr>",
                         list[i].FieldInfo,
                         "</td><td id=tdl>",
                         this.GetHtmlStr(list[i].FieldName, list[i].HtmlType, list[i].DefaultValue, list[i].Width, list[i].Height, base.Server.HtmlEncode(mySqlDataReader[list[i].FieldName].ToString())),
                         " ",
                         list[i].FieldInfoA,
                         " </td></tr>"
                     }));
                 }
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 修 改 \" onclick=\"form.action='?moduleId=",
                     base.Request["moduleId"],
                     "&sortId=",
                     base.Request["sortId"],
                     "&action=edit&sortType=",
                     base.Request["sortType"],
                     "&infoId=",
                     mySqlDataReader["id"].ToString(),
                     "';\" /></td></tr>"
                 }));
             }
             else
             {
                 this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo.ModuleName + "</th></tr>");
                 List <ModuleFieldInfo> list2 = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo.Id + " order by FieldOrder");
                 for (int j = 0; j < list2.Count; j++)
                 {
                     this.sb.AppendLine(string.Concat(new string[]
                     {
                         "<tr><Td width=18% id=tdr>",
                         list2[j].FieldInfo,
                         "</td><td id=tdl>",
                         this.GetHtmlStr(list2[j].FieldName, list2[j].HtmlType, list2[j].DefaultValue, list2[j].Width, list2[j].Height, ""),
                         " ",
                         list2[j].FieldInfoA,
                         " </td></tr>"
                     }));
                 }
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 修 改 \" onclick=\"form.action='?moduleId=",
                     base.Request["moduleId"],
                     "&sortId=",
                     base.Request["sortId"],
                     "&action=add&sortType=",
                     base.Request["sortType"],
                     "';\" /></td></tr>"
                 }));
             }
             mySqlDataReader.Close();
             this.db.Dispose();
         }
         else
         {
             this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo.ModuleName + "</th></tr>");
             List <ModuleFieldInfo> list3 = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo.Id + " order by FieldOrder");
             for (int k = 0; k < list3.Count; k++)
             {
                 string readValue = (list3[k].FieldDataType.ToLower() == "date") ? DateTime.Now.ToString() : "";
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><Td width=18% id=tdr>",
                     list3[k].FieldInfo,
                     "</td><td id=tdl>",
                     this.GetHtmlStr(list3[k].FieldName, list3[k].HtmlType, list3[k].DefaultValue, list3[k].Width, list3[k].Height, readValue),
                     " ",
                     list3[k].FieldInfoA,
                     " </td></tr>"
                 }));
             }
             this.sb.AppendLine(string.Concat(new string[]
             {
                 "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 添 加 \" onclick=\"form.action='?moduleId=",
                 base.Request["moduleId"],
                 "&sortId=",
                 base.Request["sortId"],
                 "&action=add';\" /></td></tr>"
             }));
         }
     }
     if (base.Request["action"] == null && base.Request["infoId"] != null && base.Request["infoId"].Length > 0)
     {
         ModuleListInfo  moduleListInfo2  = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         MySqlDataReader mySqlDataReader2 = this.db.RunProcGetReader(string.Concat(new object[]
         {
             "select * from [",
             moduleListInfo2.ModuleTableName,
             "] where id=",
             int.Parse(base.Request["infoId"])
         }));
         if (mySqlDataReader2.Read())
         {
             this.sb.AppendLine("<tr><Th colspan=2>" + moduleListInfo2.ModuleName + "</th></tr>");
             List <ModuleFieldInfo> list4 = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo2.Id + " order by FieldOrder");
             for (int l = 0; l < list4.Count; l++)
             {
                 this.sb.AppendLine(string.Concat(new string[]
                 {
                     "<tr><Td width=18% id=tdr>",
                     list4[l].FieldInfo,
                     "</td><td id=tdl>",
                     this.GetHtmlStr(list4[l].FieldName, list4[l].HtmlType, list4[l].DefaultValue, list4[l].Width, list4[l].Height, base.Server.HtmlEncode(mySqlDataReader2[list4[l].FieldName].ToString())),
                     " ",
                     list4[l].FieldInfoA,
                     " </td></tr>"
                 }));
             }
             this.sb.AppendLine(string.Concat(new string[]
             {
                 "<tr><td></td><td id=tdl><input type=\"submit\" id=\"s_add\" name=\"s_add\" value=\" 修改 \" onclick=\"form.action='?moduleId=",
                 base.Request["moduleId"],
                 "&sortId=",
                 base.Request["sortId"],
                 "&action=edit&infoId=",
                 base.Request["infoId"],
                 "';\" /></td></tr>"
             }));
         }
         mySqlDataReader2.Close();
         this.db.Dispose();
     }
     if (base.Request["action"] != null && base.Request.QueryString["action"].Trim() == "add")
     {
         ModuleListInfo         moduleListInfo3 = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         List <ModuleFieldInfo> list5           = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo3.Id + " order by FieldOrder");
         string text  = "";
         string text2 = "";
         for (int m = 0; m < list5.Count; m++)
         {
             text  = text + "[" + list5[m].FieldName + "],";
             text2 = text2 + "@" + list5[m].FieldName + ",";
         }
         text = text.Trim().TrimEnd(new char[]
         {
             ','
         });
         text2 = text2.Trim().TrimEnd(new char[]
         {
             ','
         });
         MySqlCommand mySqlCommand = this.db.CreateCmd(string.Concat(new string[]
         {
             "insert into [",
             moduleListInfo3.ModuleTableName,
             "]([sortId],",
             text,
             ")values(@sortId,",
             text2,
             ")"
         }));
         mySqlCommand.Parameters.Add("@sortId", MySqlDbType.Int16).Value = int.Parse(base.Request["sortId"].Trim());
         for (int n = 0; n < list5.Count; n++)
         {
             mySqlCommand.Parameters.Add("@" + list5[n].FieldName, this.GetDbType(list5[n].FieldDataType)).Value = base.Request["g_" + list5[n].FieldName].ToString();
         }
         mySqlCommand.ExecuteNonQuery();
         this.db.Dispose();
         base.Response.Write(string.Concat(new string[]
         {
             "<script>alert('添加成功');location.href='InfoEdit.aspx?moduleId=",
             base.Request["moduleId"],
             "&sortId=",
             base.Request["sortId"],
             "&sortType=",
             base.Request["sortType"],
             "';</script>"
         }));
     }
     if (base.Request["action"] != null && base.Request.QueryString["action"].Trim() == "edit" && base.Request["infoId"] != null && base.Request["infoId"].Trim().Length > 0)
     {
         ModuleListInfo         moduleListInfo4 = ModuleListInfo.Read(int.Parse(base.Request.QueryString["moduleId"]));
         List <ModuleFieldInfo> list6           = ModuleFieldInfo.ReadList(" where ModuleId=" + moduleListInfo4.Id + " order by FieldOrder");
         string text3 = "";
         for (int num = 0; num < list6.Count; num++)
         {
             string text4 = text3;
             text3 = string.Concat(new string[]
             {
                 text4,
                 "[",
                 list6[num].FieldName,
                 "]=@",
                 list6[num].FieldName,
                 ","
             });
         }
         text3 = text3.Trim().TrimEnd(new char[]
         {
             ','
         });
         MySqlCommand mySqlCommand2 = this.db.CreateCmd(string.Concat(new object[]
         {
             "update [",
             moduleListInfo4.ModuleTableName,
             "] set ",
             text3,
             " where id=",
             int.Parse(base.Request["infoId"].Trim())
         }));
         for (int num2 = 0; num2 < list6.Count; num2++)
         {
             mySqlCommand2.Parameters.Add("@" + list6[num2].FieldName, this.GetDbType(list6[num2].FieldDataType)).Value = base.Request["g_" + list6[num2].FieldName].ToString();
         }
         mySqlCommand2.ExecuteNonQuery();
         this.db.Dispose();
         base.Response.Write(string.Concat(new string[]
         {
             "<script>alert('修改成功');location.href='InfoEdit.aspx?moduleId=",
             base.Request["moduleId"],
             "&infoId=",
             base.Request["infoId"].Trim(),
             "';</script>"
         }));
     }
 }
Exemplo n.º 9
0
        public static string GetHtmlControl(this ModuleFieldInfo field, List <CodeInfoModel> dataComboBoxs = null, List <LanguageInfo> languageInfos = null, string subMod = "", List <dynamic> dataEdit = null, string modName = "", string keyEdit = "", int pageSlide = 0, List <ModuleFieldInfo> fieldSubmited = null)
        {
            if (languageInfos == null)
            {
                languageInfos = new List <LanguageInfo>();
            }
            AppConfiguration app = new AppConfiguration();
            var hostUrl          = app.HostAddress;
            var valueControl     = "";

            if (dataEdit != null)
            {
                foreach (var item in dataEdit)
                {
                    var dataRows = ((Newtonsoft.Json.Linq.JContainer)item);
                    if (field.ControlType == "IMG")
                    {
                        var valueControlTemp = "";
                        var parramTemp       = "";
                        foreach (var column in dataRows)
                        {
                            var columnName = ((Newtonsoft.Json.Linq.JProperty)column).Name;
                            if (columnName.ToUpper() == field.FieldName.ToUpper())
                            {
                                if (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value != null)
                                {
                                    valueControlTemp = (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value).ToString().Trim();
                                }
                            }
                            else if (columnName.ToUpper() == field.ParameterName.ToUpper())
                            {
                                if (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value != null)
                                {
                                    parramTemp = (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value).ToString().Trim();
                                }
                            }
                        }
                        valueControl += parramTemp + "$" + valueControlTemp + ",";
                    }
                    else
                    {
                        foreach (var column in dataRows)
                        {
                            var columnName = ((Newtonsoft.Json.Linq.JProperty)column).Name;
                            if (columnName.ToUpper() == field.FieldName.ToUpper())
                            {
                                if (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value != null)
                                {
                                    valueControl += (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value).ToString().Trim() + ",";
                                }
                            }
                        }
                    }
                }
            }
            valueControl = valueControl.Trim(',');
            var validate    = "";
            var classCustom = "";

            if (field.FieldType == EFieldType.INT.ToString() || field.FieldType == EFieldType.LNG.ToString())
            {
                classCustom = " text-number";
            }
            if (field.Nullable == EYesNo.N.ToString())
            {
                validate += " required='' aria-required='true'";
            }
            if (field.MaxLength > 0)
            {
                validate += string.Format(" maxlength='{0}'", field.MaxLength);
            }
            //validate = "";
            var languageText = field.FieldName;
            var nameCheck    = string.Format("{0}${1}.Label", modName, field.FieldName);
            var langCheck    = languageInfos.Where(x => x.LanguageName.ToUpper() == nameCheck.ToUpper());

            if (langCheck.Any())
            {
                languageText = langCheck.First().LanguageValue;
            }
            if (string.IsNullOrEmpty(valueControl) && fieldSubmited != null)
            {
                var checkValue = fieldSubmited.Where(x => x.FieldName.ToLower() == field.FieldName.ToLower());
                if (checkValue.Any())
                {
                    valueControl = checkValue.First().FieldID;
                }
            }
            switch (field.ControlType)
            {
            case "TB":
                var disable = "";
                if ((dataEdit != null && dataEdit.Count() > 0) && field.DisableEdit == "Y")
                {
                    disable = "disabled='disabled'";
                }
                if (field.AutoCode == "Y" && (dataEdit == null || dataEdit.Count() == 0))
                {
                    var currDate = DateTime.Now.ToString("ddMMyyhhmmss");
                    if (field.MaxLength - currDate.Length > 0)
                    {
                        valueControl = CommonFunction.RandomString(field.MaxLength - currDate.Length) + currDate;
                    }
                }
                if (!string.IsNullOrEmpty(field.Mod_Enter))
                {
                    return(string.Format("<InputText id='{0}' name='{1}' value='{2}' {3} class='form-control {4} {8}  @bind-Value='moduleFieldInfo[0].FieldId' enter-go-mod' placeholder='{5}' mod-enter='{6}' {7} {9}/>", field.FieldName, field.FieldName, valueControl, validate, classCustom, languageText, field.Mod_Enter, disable, string.IsNullOrEmpty(field.Callback) ? "" : "call-back", "callback='" + field.Callback + "'"));
                }
                return(string.Format("<input type='text' id='{0}' name='{1}' {2} {3} class='form-control {4} {7}'  @bind='abcd' placeholder='{5}' {6} {8}/>", field.FieldName, field.FieldName, valueControl, validate, classCustom, languageText, disable, string.IsNullOrEmpty(field.Callback) ? "" : "call-back", "callback='" + field.Callback + "'"));

            case "CHK":
                var check = "";
                if ((valueControl.ToUpper() == "Y" || valueControl == "1") && field.DefaultValue == "Y")
                {
                    check = "checked='checked'";
                }
                else if (string.IsNullOrEmpty(valueControl) && field.DefaultValue != "Y")
                {
                    check = "";
                }
                return(string.Format("<input type='checkbox' id='{0}' name='{1}' value='{2}' {3} />", field.FieldName, field.FieldName, field.DefaultValue, check));

            case "DT":
                return(string.Format("<input type='text' id='{0}' name='{1}' value='{2}' class='form-control datepicker' data-validation='date' data-validation-format='dd-mm-yyyy' {3}  placeholder='{4}' />", field.FieldName, field.FieldName, valueControl, validate, languageText));

            case "TA":
                return(string.Format("<textarea id='{0}' name='{1}' class='form-control' rows='4' {3} cols='50'  placeholder={4}>{2}</textarea>", field.FieldName, field.FieldName, valueControl, validate, languageText));

            case "CB":
                var disableCb = "";
                if ((dataEdit != null && dataEdit.Count() > 0) && field.DisableEdit == "Y")
                {
                    disableCb = "disabled='disabled'";
                }
                var text = string.Format("<select id='{0}' name='{1}' class='form-control select2 {5}' {2} placeholder='{3}' {4} {6}>", field.FieldName, field.FieldName, validate, languageText, disableCb, string.IsNullOrEmpty(field.Callback) ? "" : "call-back", "callback='" + field.Callback + "'");
                text += string.Format("<option selected='selected' value='{0}'>{1}</option>", "", String.Format("-- Chọn {0}--", languageText));
                if (dataComboBoxs != null)
                {
                    var options = dataComboBoxs.Where(x => x.Name.ToUpper() == field.FieldName.ToUpper());
                    if (options != null && options.Any())
                    {
                        foreach (var item in options.First().CodeInfos)
                        {
                            if (valueControl.ToUpper() == "True".ToUpper())
                            {
                                valueControl = "Y";
                            }
                            else if (valueControl.ToUpper() == "FALSE")
                            {
                                valueControl = "N";
                            }
                            if (item.CodeValue == valueControl || item.CodeValue == field.DefaultValue)
                            {
                                text += string.Format("<option selected='selected' value='{0}'>{1}</option>", item.CodeValue, item.CodeValueName);
                            }
                            else
                            {
                                text += string.Format("<option value='{0}'>{1}</option>", item.CodeValue, item.CodeValueName);
                            }
                        }
                    }
                }

                text += "</select>";
                return(text);

            case "MCB":
                var disableMCb = "";
                if ((dataEdit != null && dataEdit.Count() > 0) && field.DisableEdit == "Y")
                {
                    disableMCb = "disabled='disabled'";
                }
                var textMCB = string.Format("<select id='{0}' name='{1}' class='form-control select2' {2} placeholder={3} {4} multiple='multiple'>", field.FieldName, field.FieldName, validate, languageText, disableMCb);
                //textMCB += string.Format("<option selected='selected' value='{0}'>{1}</option>", "", String.Format("-- Chọn {0}--", languageText));
                if (dataComboBoxs != null)
                {
                    var options = dataComboBoxs.Where(x => x.Name.ToUpper() == field.FieldName.ToUpper());
                    if (options != null && options.Any())
                    {
                        foreach (var item in options.First().CodeInfos)
                        {
                            if (valueControl.ToUpper() == "True".ToUpper())
                            {
                                valueControl = "Y";
                            }
                            else if (valueControl.ToUpper() == "FALSE")
                            {
                                valueControl = "N";
                            }
                            if (item.CodeValue == valueControl || item.CodeValue == field.DefaultValue)
                            {
                                textMCB += string.Format("<option selected='selected' value='{0}'>{1}</option>", item.CodeValue, item.CodeValueName);
                            }
                            else
                            {
                                textMCB += string.Format("<option value='{0}'>{1}</option>", item.CodeValue, item.CodeValueName);
                            }
                        }
                    }
                }

                textMCB += "</select>";
                return(textMCB);

            case "CC":
                var textCC = string.Format("<select id='{0}' name='{1}' class='form-control select2 {4}' {2}  placeholder='{3}' {5}>", field.FieldName, field.FieldName, validate, languageText, string.IsNullOrEmpty(field.Callback) ? "" : "call-back", "callback='" + field.Callback + "'");
                textCC += string.Format("<option selected='selected' value='{0}'>{1}</option>", "", String.Format("-- Chọn {0}--", languageText));
                if (dataComboBoxs != null)
                {
                    var options = dataComboBoxs.Where(x => x.Name.ToUpper() == field.FieldName.ToUpper());
                    if (options != null && options.Any())
                    {
                        foreach (var item in options.First().CodeInfos)
                        {
                            if (item.CodeValue == valueControl)
                            {
                                textCC += string.Format("<option selected='selected' value='{0}'>{1}</option>", item.CodeValue, item.CodeValueName);
                            }
                            else
                            {
                                textCC += string.Format("<option value='{0}'>{1}</option>", item.CodeValue, item.CodeValueName);
                            }
                        }
                    }
                }

                textCC += "</select>";
                return(textCC);

            case "SP":
                return(string.Format("<textarea id='{0}' name='{1}' class='form-control ckeditor' rows='4' cols='50'  placeholder='{2}'></textarea>", field.FieldName, field.FieldName, languageText));

            case "PDF":
                string urlFile = "";
                string page    = "";
                if (dataComboBoxs != null)
                {
                    var options = dataComboBoxs.Where(x => x.Name.ToUpper() == field.FieldName.ToUpper());
                    if (options != null)
                    {
                        foreach (var item in options.First().CodeInfos)
                        {
                            urlFile = item.CodeValueName;
                            page    = item.CodeValue;
                        }
                    }
                }

                if (string.IsNullOrEmpty(urlFile))
                {
                    return("");
                }

                var slideControl = string.Format("<iframe id='iframe' src='{0}/pdfjs-2.2.228-dist/web/viewer.html?file={0}/Uploads/{1}&page={2}' style='width:100%;min-height:40vh;'></iframe>", hostUrl, urlFile, int.Parse(page) + pageSlide);;
                return(slideControl);

            case "LCB":
                var textLCB = "";
                if (dataComboBoxs != null)
                {
                    var arrValues = valueControl.ToStringArrayUpper(',');
                    var options   = dataComboBoxs.Where(x => x.Name.ToUpper() == field.FieldName.ToUpper());
                    if (options != null && options.Any())
                    {
                        int index = 0;
                        foreach (var item in options.First().CodeInfos)
                        {
                            if (valueControl.ToUpper() == "True".ToUpper())
                            {
                                valueControl = "Y";
                            }
                            else if (valueControl.ToUpper() == "FALSE")
                            {
                                valueControl = "N";
                            }
                            if (arrValues.Contains(item.CodeValue.ToUpper()))
                            {
                                //if (string.IsNullOrEmpty(item.CodeValueName.GetLanguageTitle(languageInfos))) {
                                //    var a = 1;
                                //}

                                textLCB += string.Format("<div class='col-lg-6 col-6'><input type='checkbox' checked='checked' name='{0}[{2}]' id='{0}' value='{1}'/> {3}</div>", field.FieldName, item.CodeValue, index, item.CodeValueName.GetLanguageTitle(languageInfos));
                            }
                            else
                            {
                                textLCB += string.Format("<div class='col-lg-6 col-6'><input type='checkbox' name='{0}[{2}]' id='{0}' value='{1}'/> {3}</div>", field.FieldName, item.CodeValue, index, item.CodeValueName.GetLanguageTitle(languageInfos));
                            }
                            index++;
                        }
                    }
                }
                return(textLCB);

                break;

            case "UL":    //Upload
                var ulControl = "";
                ulControl = String.Format("<div class='input-group'><div class='custom-file'><input type = 'file' class='custom-file-input' multiple id='{0}' name='{0}'><label class='custom-file-label' for='exampleInputFile'/>{1}</label></div></div>", field.FieldName, (String.IsNullOrEmpty(valueControl) ? "Choose file" : valueControl), valueControl);
                return(ulControl);

            case "SCL":    //Schedule
                var schedule = String.Format(@"<div class='wrap'><div id='{0}' class='calendar-schedule'></div><div style = 'clear:both'></div>", field.FieldName);
                return(schedule);

            case "IMG":    //Image
                var imgControl = "";
                var split      = valueControl.Split(',');
                foreach (var item in split)
                {
                    var valueParr = item.Split("$");
                    if (valueParr.Length > 1)
                    {
                        //string modId,string fieldName, string parr = ""
                        var actionLink = string.Format("{0}/Home/GoToMod?modId={1}&fieldName={2}&parr={3}&key={4}", hostUrl, field.Mod_Enter, field.ParameterName, valueParr[0], keyEdit);
                        imgControl += string.Format(@"<div class='form-group no-padding col-lg-6 col-6'><div class='card no-padding'><div class='col-12 left text-center no-padding card-body border-screen' style='height:100%'><a href='{3}'><img name ='{0}' id='{0}' class='img img-control' src='{1}/Uploads/{2}'/></div></div></div>", field.FieldName, hostUrl, valueParr[1], actionLink);
                    }
                    else
                    {
                        imgControl += string.Format(@"<div class='form-group no-padding col-lg-6 col-6'><div class='card no-padding'><div class='col-12 left text-center no-padding card-body border-screen' style='height:100%'><img name ='{0}' id='{0}' class='img img-control' src='{1}/Uploads/{2}'/></div></div></div>", field.FieldName, hostUrl, item);
                    }
                }

                return(imgControl);

            case "BC":    //Barcode
                disable = "";
                if ((dataEdit != null && dataEdit.Count() > 0) && field.DisableEdit == "Y")
                {
                    disable = "disabled='disabled'";
                }
                if (!string.IsNullOrEmpty(field.Mod_Enter))
                {
                    return(string.Format("<div class='input-group'><input type='text' id='{0}' name='{1}' value='{2}' {3} class='form-control {4} barcode enter-go-mod' placeholder='{5}'  mod-enter='{6}' {7}/><button id='btnGoToMod' class='btn btn-default on-mobile' type='button'>Kiểm tra</button></div>", field.FieldName, field.FieldName, valueControl, validate, classCustom, languageText, field.Mod_Enter, disable));
                }
                return(string.Format("<input type='text' id='{0}' name='{1}' value='{2}' {3} class='form-control {4} barcode' placeholder='{5}' {6}/>", field.FieldName, field.FieldName, valueControl, validate, classCustom, languageText, disable));

            default:
                return(string.Format("<input type='text' id='{0}' name='{1}' value='{2}' class='form-control'  placeholder={3} />", field.FieldName, field.FieldName, valueControl, languageText));
            }
        }
Exemplo n.º 10
0
 public static string GetGroupFieldTextBtn(this ModuleFieldInfo field, List <LanguageInfo> languages)
 {
     return("");
 }
Exemplo n.º 11
0
    public void BindData()
    {
        int recordConnt = 0;
        int num         = this.page = ((base.Request["page"] != null) ? int.Parse(base.Request.QueryString["page"]) : 1);

        this.moduleId = int.Parse(base.Request["moduleId"]);
        this.sortId   = int.Parse(base.Request["sortId"]);
        ModuleListInfo moduleListInfo = ModuleListInfo.Read(this.moduleId);

        this.pager.PageSize = 15;
        DataView dataView = this.db.RunProcGetDataView(string.Concat(new object[]
        {
            "select * from [",
            moduleListInfo.ModuleTableName,
            "] where sortId=",
            this.sortId,
            " order by id desc"
        }), (num - 1) * this.pager.PageSize, this.pager.PageSize, out recordConnt);
        List <ModuleFieldInfo> list = ModuleFieldInfo.ReadList("where moduleId=" + this.moduleId + " and isShow=1 order by fieldOrder");

        this.sb.AppendLine("<table width=100% border=1><tr>");
        this.sb.AppendLine("<th width=60>编号</th>");
        for (int i = 0; i < list.Count; i++)
        {
            this.sb.AppendLine(string.Concat(new string[]
            {
                "<th width=",
                list[i].ListWidth,
                ">",
                list[i].FieldInfo,
                "</th>"
            }));
        }
        this.sb.AppendLine("<th width=120>查看</th>");
        this.sb.AppendLine("<th width=60>选择</th>");
        this.sb.AppendLine("</tr>");
        for (int j = 0; j < dataView.Count; j++)
        {
            this.sb.AppendLine("<tr>");
            this.sb.AppendLine("<td align=center>" + dataView[j]["id"].ToString() + "</td>");
            for (int k = 0; k < list.Count; k++)
            {
                this.sb.AppendLine("<td align=center>" + this.GetFieldStr(dataView[j][list[k].FieldName].ToString(), list[k].DefaultValue, list[k].HtmlType) + "</td>");
            }
            this.sb.AppendLine(string.Concat(new object[]
            {
                "<td align=center><a href='InfoEdit.aspx?moduleId=",
                this.moduleId,
                "&infoId=",
                dataView[j]["id"].ToString(),
                "'>查看详细</a></td><td align=center><input id=\"selectId\" type=\"checkbox\" name=\"selectId\" value=\"",
                dataView[j]["id"].ToString(),
                "\" /></td>"
            }));
            this.sb.AppendLine("</tr>");
        }
        this.sb.AppendLine("</table>");
        this.pager.RecordConnt = recordConnt;
        this.pager.CurrentPage = num;
        this.pager.UrlFormat   = string.Concat(new object[]
        {
            "InfoList.aspx?moduleId=",
            this.moduleId,
            "&sortId=",
            this.sortId,
            "&page={0}"
        });
        this.sb.AppendLine("<table width=100%><Tr><Td id=pager> " + this.pager.CreaterHtml() + "</td>");
        this.sb.AppendLine("<td align=right width=183><input id=\"CheckAll\" type=\"checkbox\" onClick=\"mm()\" /> 全选 <input type=\"submit\" name=\"bt_delete\" value=\" 删除选中 \" onclick=\"return confirm('确定要删除吗');\" id=\"bt_delete\" /> </td></tr></table>");
        if (base.Request["action"] != null && base.Request["action"] == "delete")
        {
            if (base.Request["selectId"] != null && base.Request["selectId"].Trim().Length > 0)
            {
                this.db.RunNonQurey(string.Concat(new string[]
                {
                    "delete from [",
                    moduleListInfo.ModuleTableName,
                    "] where id in(",
                    base.Request["selectId"].Trim().Replace("'", "").Replace("\"", ""),
                    ")"
                }));
                this.db.Dispose();
            }
            base.Response.Redirect(string.Concat(new object[]
            {
                "InfoList.aspx?moduleId=",
                this.moduleId,
                "&sortId=",
                this.sortId,
                "&page=",
                this.page
            }));
        }
    }
Exemplo n.º 12
0
 public override List <NameValueItem> GetSourceList(ModuleInfo moduleInfo, ModuleFieldInfo fieldInfo, List <string> values)
 {
     return(null);
 }