Beispiel #1
0
        public int UpdateByFieldValue(string PKField, string PKValue, T newEntity)
        {
            PropertyInfo[] arg_18_0 = newEntity.GetType().GetProperties();
            string         text     = string.Empty;

            PropertyInfo[] array = arg_18_0;
            for (int i = 0; i < array.Length; i++)
            {
                PropertyInfo propertyInfo = array[i];
                string       text2        = null;
                this.m_PropertyFieldMap.TryGetValue(propertyInfo.Name, out text2);
                string a = null;
                this.m_ColumnsType.TryGetValue(propertyInfo.Name, out a);
                if (text2 != null && a == "0")
                {
                    string dB_TYPE = DALService.Database.DB_TYPE;
                    if (!(dB_TYPE == "SQLSERVER"))
                    {
                        if (dB_TYPE == "OLEDB")
                        {
                            Type arg_126_0 = propertyInfo.PropertyType;
                            if (propertyInfo.GetValue(newEntity, null) is string || propertyInfo.GetValue(newEntity, null) is DateTime)
                            {
                                text += string.Format("[{0}]='{1}',", text2, DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString());
                            }
                            if (propertyInfo.GetValue(newEntity, null) is int || propertyInfo.GetValue(newEntity, null) is int || propertyInfo.GetValue(newEntity, null) is double || propertyInfo.GetValue(newEntity, null) is double || propertyInfo.GetValue(newEntity, null) is float || propertyInfo.GetValue(newEntity, null) is float || propertyInfo.GetValue(newEntity, null) is decimal || propertyInfo.GetValue(newEntity, null) is decimal)
                            {
                                text += string.Format("[{0}]={1},", text2, DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString());
                            }
                            if (propertyInfo.GetValue(newEntity, null) is bool || propertyInfo.GetValue(newEntity, null) is bool)
                            {
                                text += string.Format("[{0}]={1},", text2, DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString());
                            }
                        }
                    }
                    else
                    {
                        if (propertyInfo.GetValue(newEntity, null) is bool)
                        {
                            string arg = "0";
                            if (Convert.ToBoolean(propertyInfo.GetValue(newEntity, null)))
                            {
                                arg = "1";
                            }
                            text += string.Format("{0}='{1}',", text2, arg);
                        }
                        else
                        {
                            text += string.Format("{0}='{1}',", text2, DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString());
                        }
                    }
                }
            }
            text = text.Substring(0, text.Length - 1);
            string sQLStatement = string.Format("update {0} set {1} where {2}='{3}'", new object[]
            {
                this.m_TableName,
                text,
                PKField,
                PKValue
            });

            DALService.Database.ExeSQLStatement(sQLStatement);
            return(0);
        }
Beispiel #2
0
        public int AddNew(T newEntity)
        {
            PropertyInfo[] arg_1E_0 = newEntity.GetType().GetProperties();
            string         text     = string.Empty;
            string         text2    = string.Empty;

            PropertyInfo[] array = arg_1E_0;
            for (int i = 0; i < array.Length; i++)
            {
                PropertyInfo propertyInfo = array[i];
                string       text3        = null;
                this.m_PropertyFieldMap.TryGetValue(propertyInfo.Name, out text3);
                string a = null;
                this.m_ColumnsType.TryGetValue(propertyInfo.Name, out a);
                if (text3 != null && a == "0")
                {
                    string a2 = DALService.Database.DB_TYPE;
                    if (!(a2 == "SQLSERVER"))
                    {
                        if (a2 == "OLEDB")
                        {
                            text = text + "[" + text3 + "],";
                        }
                    }
                    else
                    {
                        text = text + text3 + ",";
                    }
                    a2 = DALService.Database.DB_TYPE;
                    if (!(a2 == "SQLSERVER"))
                    {
                        if (a2 == "OLEDB")
                        {
                            a2 = propertyInfo.PropertyType.Name;
                            if (!(a2 == "String"))
                            {
                                if (!(a2 == "Int32"))
                                {
                                    if (!(a2 == "DateTime"))
                                    {
                                        if (!(a2 == "Boolean"))
                                        {
                                            text2 = text2 + "'" + DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString() + "',";
                                        }
                                        else
                                        {
                                            if ((bool)propertyInfo.GetValue(newEntity, null))
                                            {
                                                text2 += "true,";
                                            }
                                            else
                                            {
                                                text2 += "false,";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (propertyInfo.GetValue(newEntity, null) != null)
                                        {
                                            text2 = text2 + "#" + DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString() + "#,";
                                        }
                                        else
                                        {
                                            text2 += "#1901-01-01#,";
                                        }
                                    }
                                }
                                else
                                {
                                    text2 = text2 + DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString() + ",";
                                }
                            }
                            else
                            {
                                text2 = text2 + "'" + DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString() + "',";
                            }
                        }
                    }
                    else
                    {
                        if (propertyInfo.GetValue(newEntity, null) is bool)
                        {
                            string str = "0";
                            if (Convert.ToBoolean(propertyInfo.GetValue(newEntity, null)))
                            {
                                str = "1";
                            }
                            text2 = text2 + "'" + str + "',";
                        }
                        else
                        {
                            text2 = text2 + "'" + DataFormatUtilities.processValues(propertyInfo.GetValue(newEntity, null)).ToString() + "',";
                        }
                    }
                }
            }
            text  = text.Substring(0, text.Length - 1);
            text2 = text2.Substring(0, text2.Length - 1);
            string sQLStatement = string.Format("insert into {0} ({1}) values ({2})", this.m_TableName, text, text2);

            DALService.Database.ExeSQLStatement(sQLStatement);
            return(0);
        }