Esempio n. 1
0
        public List <RecordsCityModel> DataTableToList(DataTable dt)
        {
            List <RecordsCityModel> list = new List <RecordsCityModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    RecordsCityModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Esempio n. 2
0
        public RecordsCityModel DataRowToModel(DataRow row)
        {
            RecordsCityModel recordsCityModel = new RecordsCityModel();

            if (row != null)
            {
                recordsCityModel.ID = int.Parse(row["ID"].ToString());
                if ((row["Code"] != null) && (row["Code"] != DBNull.Value))
                {
                    recordsCityModel.Code = row["Code"].ToString();
                }
                if ((row["Name"] != null) && (row["Name"] != DBNull.Value))
                {
                    recordsCityModel.Name = row["Name"].ToString();
                }
                recordsCityModel.ProvinceID = int.Parse(row["ProvinceID"].ToString());
            }
            return(recordsCityModel);
        }
Esempio n. 3
0
        public bool Add(RecordsCityModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into ARCHIVE_CITY(");
            builder.Append("ID,Code,Name,ProvinceID)");
            builder.Append(" values (");
            builder.Append("@ID,@Code,@Name,@ProvinceID)");
            MySqlParameter[] cmdParms = new MySqlParameter[] {
                new MySqlParameter("@ID", MySqlDbType.Int32, 4),
                new MySqlParameter("@Code", MySqlDbType.String),
                new MySqlParameter("@Name", MySqlDbType.String),
                new MySqlParameter("@ProvinceID", MySqlDbType.Int32, 4)
            };
            cmdParms[0].Value = model.ID;
            cmdParms[1].Value = model.Code;
            cmdParms[2].Value = model.Name;
            cmdParms[3].Value = model.ProvinceID;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Esempio n. 4
0
        public bool Update(RecordsCityModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update ARCHIVE_CITY set ");
            builder.Append("ID=@ID,");
            builder.Append("Code=@Code,");
            builder.Append("Name=@Name,");
            builder.Append("ProvinceID=@ProvinceID");
            builder.Append(" where ");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@ID", MySqlDbType.Int32, 4),
                new MySqlParameter("@Code", MySqlDbType.String),
                new MySqlParameter("@Name", MySqlDbType.String),
                new MySqlParameter("@ProvinceID", MySqlDbType.Int32, 4)
            };
            cmdParms[0].Value = model.ID;
            cmdParms[1].Value = model.Code;
            cmdParms[2].Value = model.Name;
            cmdParms[3].Value = model.ProvinceID;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Esempio n. 5
0
 public bool Update(RecordsCityModel model)
 {
     return(this.dal.Update(model));
 }
Esempio n. 6
0
 public bool Add(RecordsCityModel model)
 {
     return(this.dal.Add(model));
 }