Exemple #1
0
        /// <summary>
        /// WinForm 控件属性代码
        /// </summary>
        /// <param name="row">行记录集</param>
        /// <param name="uiName">UI控件名称</param>
        /// <param name="strVar">定义对象</param>
        /// <param name="strNewVar">实例化对象</param>
        /// <param name="strUIAdd">填加到窗体中</param>
        /// <returns></returns>
        private Helper.Code.Create.UIControl UI(DataRow row, string uiCode, out string uiName, out string strVar, out string strNewVar, out string strUIAdd)
        {
            Helper.Code.Create.UIControl ui = new Helper.Code.Create.UIControl();
            string cid, cname;

            StringBuilder strb = new StringBuilder();

            cid   = row["控件"].ToString();
            cname = row["字段"].ToString();
            if (uiCode == "Label")
            {
                ui = VarControl(uiCode);
            }
            else
            {
                if (cid == "0")
                {
                    ui = VarControl(uiCode);
                }
                else
                {
                    ui = VarControl(int.Parse(cid));
                }
            }
            uiName = ui.Abbreviate + VarModel(cname);

            strVar    = " private " + ui.Define + " " + uiName + ";";
            strNewVar = "this." + uiName + " = new " + ui.Define.Trim() + "();";
            strUIAdd  = "this.Controls.Add(this." + uiName + ");\r\nthis.Controls.SetChildIndex(this." + uiName + ", 0);";

            return(ui);
        }
Exemple #2
0
        /// <summary>
        /// 编辑表示层
        /// </summary>
        /// <returns></returns>
        public string Cs2()
        {
            StringBuilder strbSet = new StringBuilder();
            StringBuilder strbGet = new StringBuilder();
            DataTable     dt      = GetProperty.DataTable;

            string strResult = string.Empty;

            Helper.Code.Create.UIControl control;

            foreach (DataRow dr in dt.Rows)
            {
                string     setCode = "", getCode = "";
                ColumnInfo cols = new ColumnInfo();
                cols    = GetColumnInfo(dr);
                control = new Helper.Code.Create.UIControl();
                if (cols.UI != "0" && !string.IsNullOrEmpty(cols.UI))
                {
                    control = VarControl(int.Parse(cols.UI));
                }
                else
                {
                    control = VarControl("TextBoxExt");
                }

                if (control != null)
                {
                    setCode = control.SetValue;
                    setCode = setCode.Replace("$FieldName$", cols.ColumnName);
                    setCode = setCode.Replace("$VarFieldName$", VarModel(cols.ColumnName));
                    setCode = setCode.Replace("$FieldRemark$", IsNull(cols.Remark, cols.ColumnName));
                    strbSet.Append(setCode + "\n");

                    getCode = control.GetValue;
                    getCode = getCode.Replace("$FieldName$", cols.ColumnName);
                    getCode = getCode.Replace("$VarFieldName$", VarModel(cols.ColumnName));
                    getCode = getCode.Replace("$FieldRemark$", IsNull(cols.Remark, cols.ColumnName));
                    strbGet.Append(getCode + "\n");
                }
            }



            ////模板内容
            strResult = GetProperty.ModuleCode;

            if (!string.IsNullOrEmpty(strResult))
            {
                strResult = strResult.Replace("$SetDetail$", strbSet.ToString());
                strResult = strResult.Replace("$GetDetail$", strbGet.ToString());
            }
            else
            {
                strResult  = strbSet.ToString();
                strResult += strbGet.ToString();
            }

            return(strResult);
        }
Exemple #3
0
        /// <summary>
        /// 设置Label、TextBox等UI属性代码
        /// </summary>
        /// <returns></returns>
        private string UIProperty(int index, string uiName, string column_remark, Helper.Code.Create.UIControl ui, bool isLabel)
        {
            StringBuilder strCode = new StringBuilder();
            string        strResult = string.Empty;
            int           x = 0, y = 30;

            if (isLabel)
            {
                if (index % 2 == 0)
                {
                    x  = 220;
                    y += 20 * ((int)(index / 2) - 1);
                }
                else if (index > 0 && index % 3 == 0)
                {
                    x  = 400;
                    y += 20 * ((int)(index / 3) - 1);
                }
                else
                {
                    x  = 8;
                    y += 20 * (index - 1);
                }
            }
            if (!isLabel)
            {
                if (index % 2 == 0)
                {
                    x  = 260;
                    y += 20 * ((int)(index / 2) - 1);
                }
                else if (index > 0 && index % 3 == 0)
                {
                    x  = 450;
                    y += 20 * ((int)(index / 3) - 1);
                }
                else
                {
                    x  = 90;
                    y += 20 * index;
                }
            }
            strResult = ui.UsingCode;
            strResult = strResult.Replace("$TabIndex$", Convert.ToString(index + 1));
            strResult = strResult.Replace("$X$", Convert.ToString(x));
            strResult = strResult.Replace("$Y$", Convert.ToString(y));
            strResult = strResult.Replace("$FieldName$", uiName.Replace("\"", ""));
            strResult = strResult.Replace("$FieldCaption$", column_remark.Replace("\"", ""));
            return(strResult);
        }
Exemple #4
0
        /// <summary>
        /// WinForm �ؼ����Դ���
        /// </summary>
        /// <param name="row">�м�¼��</param>
        /// <param name="uiName">UI�ؼ�����</param>
        /// <param name="strVar">�������</param>
        /// <param name="strNewVar">ʵ��������</param>
        /// <param name="strUIAdd">��ӵ�������</param>
        /// <returns></returns>
        private Helper.Code.Create.UIControl UI(DataRow row, string uiCode, out string uiName, out string strVar, out string strNewVar, out string strUIAdd)
        {
            Helper.Code.Create.UIControl ui = new Helper.Code.Create.UIControl();
            string cid, cname;

            StringBuilder strb = new StringBuilder();
            cid = row["�ؼ�"].ToString();
            cname = row["�ֶ�"].ToString();
            if (uiCode == "Label")
                ui = VarControl(uiCode);
            else
            {
                if (cid == "0")
                {
                    ui = VarControl(uiCode);
                }
                else
                {
                    ui = VarControl(int.Parse(cid));
                }
            }
            uiName = ui.Abbreviate + VarModel(cname);

            strVar = " private " + ui.Define + " " + uiName + ";";
            strNewVar = "this." + uiName + " = new " + ui.Define.Trim() + "();";
            strUIAdd = "this.Controls.Add(this." + uiName + ");\r\nthis.Controls.SetChildIndex(this." + uiName + ", 0);";

            return ui;
        }
Exemple #5
0
        /// <summary>
        /// �༭��ʾ��
        /// </summary>
        /// <returns></returns>
        public string Cs2()
        {
            StringBuilder strbSet = new StringBuilder();
            StringBuilder strbGet = new StringBuilder();
            DataTable dt = GetProperty.DataTable;

            string strResult = string.Empty;
            Helper.Code.Create.UIControl control;

            foreach (DataRow dr in dt.Rows)
            {
                string setCode = "",getCode="";
                ColumnInfo cols = new ColumnInfo();
                cols = GetColumnInfo(dr);
                control = new Helper.Code.Create.UIControl();
                if (cols.UI != "0" && !string.IsNullOrEmpty(cols.UI))
                    control = VarControl(int.Parse(cols.UI));
                else
                    control = VarControl("TextBoxExt");

                if (control != null)
                {
                    setCode = control.SetValue;
                    setCode = setCode.Replace("$FieldName$", cols.ColumnName);
                    setCode = setCode.Replace("$VarFieldName$",VarModel(cols.ColumnName));
                    setCode = setCode.Replace("$FieldRemark$", IsNull(cols.Remark, cols.ColumnName));
                    strbSet.Append(setCode + "\n");

                    getCode = control.GetValue;
                    getCode = getCode.Replace("$FieldName$", cols.ColumnName);
                    getCode = getCode.Replace("$VarFieldName$", VarModel(cols.ColumnName));
                    getCode = getCode.Replace("$FieldRemark$", IsNull(cols.Remark, cols.ColumnName));
                    strbGet.Append(getCode + "\n");
                }
            }

            ////ģ������
            strResult = GetProperty.ModuleCode;

            if (!string.IsNullOrEmpty(strResult))
            {
                strResult = strResult.Replace("$SetDetail$", strbSet.ToString());
                strResult = strResult.Replace("$GetDetail$", strbGet.ToString());

            }
            else
            {
                strResult = strbSet.ToString();
                strResult += strbGet.ToString();
            }

            return strResult;
        }