Exemplo n.º 1
0
        public override void UpdateIn(DataTable table)
        {
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i][0].ToString().IndexOf("�ϼ�") > 0 || table.Rows[i][1].ToString().IndexOf("�ϼ�") > 0)
                    continue;
                WireCategory area = new WireCategory();
                area.Type = "40";
                foreach (DataColumn col in table.Columns)
                {
                    if (table.Rows[i][col] != null)
                    {
                            Type type = area.GetType().GetProperty(col.ColumnName).PropertyType;//.GetValue(area, null).GetType();
                            if (type == typeof(int))
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, int.Parse(table.Rows[i][col].ToString()), null);
                            else if (type == typeof(string))
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, table.Rows[i][col], null);
                            else if (type == typeof(decimal))
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, decimal.Parse(table.Rows[i][col].ToString()), null);
                            else
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, double.Parse(table.Rows[i][col].ToString()), null);
                    }
                }
                DataService.Create<WireCategory>(area);

            }
        }