Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            List <*****@*****.**> listeChamps;
            bool idPresent = false;

            _monClient.retourneProprieteConnexion().reportXmlRpcError = true;
            listeChamps = _monClient.getFieldsList(textBox1.Text);
            if (listeChamps != null)
            {
                richTextBox1.AppendText("using IMDEV.OpenERP.models.@base;\r\n");
                richTextBox1.AppendText("using IMDEV.OpenERP.models.fields.relations;\r\n");
                richTextBox1.AppendText("\r\n");
                richTextBox1.AppendText("public class " + textBox1.Text.Replace(".", "_") + ":anOpenERPObject\r\n");
                richTextBox1.AppendText("{\r\n");
                foreach ([email protected] champs in listeChamps)
                {
                    if (champs.Name.ToLower() == "id")
                    {
                        idPresent = true;
                    }
                    ecrireUnePropriete(champs);
                    richTextBox1.AppendText("\r\n");
                }
                if (!idPresent)
                {
                    [email protected] champsId = new [email protected]();
                    champsId.Name = "id";
                    champsId.Type = [email protected]_TYPE.INTEGER;
                    ecrireUnePropriete(champsId);
                }
                richTextBox1.AppendText("public override string resource_name() {\r\n");
                richTextBox1.AppendText("return " + (char)34 + textBox1.Text + (char)34 + ";");
                richTextBox1.AppendText("}\r\n");
                richTextBox1.AppendText("}\r\n");
            }
        }
Example #2
0
        private void ecrireUnePropriete([email protected] champs)
        {
            string typeChampsCS = typeCS(champs.Type);

            if ((champs.Type == [email protected]_TYPE.MANY2MANY) || (champs.Type == [email protected]_TYPE.MANY2ONE) || (champs.Type == [email protected]_TYPE.ONE2MANY) || (champs.Type == [email protected]_TYPE.ONE2ONE))
            {
                richTextBox1.AppendText("private " + typeChampsCS + " _f_" + champs.Name + " = new " + typeChampsCS + "(); //" + champs.Relation + "\r\n");
                richTextBox1.AppendText("public " + typeChampsCS + " " + champs.Name + " {\r\n");
                richTextBox1.AppendText("get { return _f_" + champs.Name + "; }\r\n");
                richTextBox1.AppendText("}\r\n");
            }
            else if (champs.Type == [email protected]_TYPE.SELECTION)
            {
                string cle;
                richTextBox1.AppendText("public enum ENUM_" + champs.Name.ToUpper() + " {\r\n");
                richTextBox1.AppendText("NULL\r\n");
                string key;
                foreach (object keypair in champs.Selection.Keys)
                {
                    key = keypair.ToString();
                    if (key == "")
                    {
                        richTextBox1.AppendText(",_EMPTY_\r\n");
                    }
                    else
                    {
                        cle = key.Replace("+", "_PLUS_").Replace("-", "_LESS_").Replace("!", "_EXCLAMATION_").Replace("/", "_").Replace(" ", "_SPACE_").Replace("?", "_INTERROGATION_").Replace("\\", "_");
                        richTextBox1.AppendText(",@" + cle + "\r\n");
                    }
                }
                richTextBox1.AppendText("}\r\n");
                string constructRealCode = "private string[] _frv_" + champs.Name + " = new string[] {" + (char)34 + "NULL" + (char)34 + ",";
                foreach (object keypair in champs.Selection.Keys)
                {
                    key = keypair.ToString();
                    constructRealCode += (char)34 + key + (char)34 + ",";
                }
                constructRealCode = constructRealCode.Substring(0, constructRealCode.Length - 1) + "};\r\n";
                richTextBox1.AppendText(constructRealCode);

                string constructLibelle = "private string[] _fl_" + champs.Name + " = new string[] {" + (char)34 + "NULL" + (char)34 + ",";
                foreach (object keypair in champs.Selection.Keys)
                {
                    constructLibelle += (char)34 + champs.Selection[keypair].ToString() + (char)34 + ",";
                }
                constructLibelle = constructLibelle.Substring(0, constructLibelle.Length - 1) + "};\r\n";
                richTextBox1.AppendText(constructLibelle);
                richTextBox1.AppendText("private ENUM_" + champs.Name.ToUpper() + " _fv_" + champs.Name + ";\r\n");
                richTextBox1.AppendText("public ENUM_" + champs.Name.ToUpper() + " " + champs.Name + " {\r\n");
                richTextBox1.AppendText("get { return _fv_" + champs.Name + "; }\r\n");
                richTextBox1.AppendText("set { _fv_" + champs.Name + " = value; }\r\n");
                richTextBox1.AppendText("}\r\n");
                richTextBox1.AppendText("public string LIBELLE_" + champs.Name + " {\r\n");
                richTextBox1.AppendText("get { return _fl_" + champs.Name + "[(int)_fv_" + champs.Name + "]; }\r\n");
                richTextBox1.AppendText("}\r\n");
                richTextBox1.AppendText("public string CODE_" + champs.Name + " {\r\n");
                richTextBox1.AppendText("get { return _frv_" + champs.Name + "[(int)_fv_" + champs.Name + "]; }\r\n");
                richTextBox1.AppendText("}\r\n");
            }
            else
            {
                richTextBox1.AppendText("public " + typeChampsCS + " " + champs.Name + " {\r\n");
                richTextBox1.AppendText("get { return (" + typeChampsCS + ")listProperties.value(" + (char)34 + champs.Name + (char)34 + ",aField.FIELD_TYPE." + champs.Type + "); }\r\n");
                if (!champs.ReadOnly)
                {
                    richTextBox1.AppendText("set { listProperties.setValue(" + (char)34 + champs.Name + (char)34 + ",value); }\r\n");
                }
                richTextBox1.AppendText("}\r\n");
                if (champs.Translate)
                {
                    richTextBox1.AppendText("private IMDEV.OpenERP.models.fields.texteMultilangue _" + champs.Name + "_multilangue;\r\n");
                    richTextBox1.AppendText("public IMDEV.OpenERP.models.fields.texteMultilangue " + champs.Name + "_multilangue { \r\n");
                    richTextBox1.AppendText("get\r\n");
                    richTextBox1.AppendText("{\r\n");
                    richTextBox1.AppendText("if (_" + champs.Name + "_multilangue==null) _" + champs.Name + "_multilangue=new IMDEV.OpenERP.models.fields.texteMultilangue(this," + (char)34 + champs.Name + (char)34 + ");\r\n");
                    richTextBox1.AppendText("return _" + champs.Name + "_multilangue;\r\n");
                    richTextBox1.AppendText("} \r\n");
                    richTextBox1.AppendText("}\r\n");
                }
            }
        }