Exemplo n.º 1
0
        public RecordsCantonModel DataRowToModel(DataRow row)
        {
            RecordsCantonModel recordsCantonModel = new RecordsCantonModel();

            if (row != null)
            {
                if (((row["ID"] != null) && (row["ID"] != DBNull.Value)) && (row["ID"].ToString() != ""))
                {
                    recordsCantonModel.ID = int.Parse(row["ID"].ToString());
                }
                if ((row["Code"] != null) && (row["Code"] != DBNull.Value))
                {
                    recordsCantonModel.Code = row["Code"].ToString();
                }
                if ((row["Name"] != null) && (row["Name"] != DBNull.Value))
                {
                    recordsCantonModel.Name = row["Name"].ToString();
                }
                if ((row["Type"] != null) && (row["Type"] != DBNull.Value))
                {
                    recordsCantonModel.Type = row["Type"].ToString();
                }
            }
            return(recordsCantonModel);
        }
Exemplo n.º 2
0
        public List <RecordsCantonModel> DataTableToList(DataTable dt)
        {
            List <RecordsCantonModel> list = new List <RecordsCantonModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    RecordsCantonModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 3
0
        public bool Add(RecordsCantonModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into ARCHIVE_CANTON(");
            builder.Append("ID,Code,Name,Type)");
            builder.Append(" values (");
            builder.Append("@ID,@Code,@Name,@Type)");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@ID", MySqlDbType.Decimal),
                new MySqlParameter("@Code", MySqlDbType.String, 6),
                new MySqlParameter("@Name", MySqlDbType.String, 50),
                new MySqlParameter("@Type", MySqlDbType.String, 1)
            };
            cmdParms[0].Value = model.ID;
            cmdParms[1].Value = model.Code;
            cmdParms[2].Value = model.Name;
            cmdParms[3].Value = model.Type;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Exemplo n.º 4
0
        public bool Update(RecordsCantonModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update ARCHIVE_CANTON set ");
            builder.Append("ID=@ID,");
            builder.Append("Code=@Code,");
            builder.Append("Name=@Name,");
            builder.Append("Type=@Type");
            builder.Append(" where ");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@ID", MySqlDbType.Decimal),
                new MySqlParameter("@Code", MySqlDbType.String, 6),
                new MySqlParameter("@Name", MySqlDbType.String, 50),
                new MySqlParameter("@Type", MySqlDbType.String, 1)
            };
            cmdParms[0].Value = model.ID;
            cmdParms[1].Value = model.Code;
            cmdParms[2].Value = model.Name;
            cmdParms[3].Value = model.Type;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Exemplo n.º 5
0
 public bool Update(RecordsCantonModel model)
 {
     return(this.dal.Update(model));
 }
Exemplo n.º 6
0
 public bool Add(RecordsCantonModel model)
 {
     return(this.dal.Add(model));
 }