public RecordsRequiredModel DataRowToModel(DataRow row)
        {
            RecordsRequiredModel recordsRequiredModel = new RecordsRequiredModel();

            if (row != null)
            {
                if ((row["ID"] != null) && (row["ID"].ToString() != ""))
                {
                    recordsRequiredModel.ID = int.Parse(row["ID"].ToString());
                }

                if (row["BTable"] != null)
                {
                    recordsRequiredModel.BTable = row["BTable"].ToString();
                }

                if (row["Name"] != null)
                {
                    recordsRequiredModel.Name = row["Name"].ToString();
                }
                if (row["Comment"] != null)
                {
                    recordsRequiredModel.Comment = row["Comment"].ToString();
                }

                if ((row["IsRequired"] != null) && (row["IsRequired"].ToString() != ""))
                {
                    recordsRequiredModel.IsRequired = new decimal?(decimal.Parse(row["IsRequired"].ToString()));
                }

                recordsRequiredModel.RcdState = RecordsStateModel.Unchanged;
            }
            return(recordsRequiredModel);
        }
        public bool Update(RecordsRequiredModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update RecordsRequired set ");
            builder.Append("BTable=@BTable,");
            builder.Append("Name=@Name,");
            builder.Append("Comment=@Comment,");
            builder.Append("IsRequired=@IsRequired ");
            builder.Append(" where ID=@ID");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@BTable", MySqlDbType.String),
                new MySqlParameter("@Name", MySqlDbType.String),
                new MySqlParameter("@Comment", MySqlDbType.String),
                new MySqlParameter("@IsRequired", MySqlDbType.Int32),
                new MySqlParameter("@ID", MySqlDbType.Int32, 8)
            };
            cmdParms[0].Value = model.BTable;
            cmdParms[1].Value = model.Name;
            cmdParms[2].Value = model.Comment;
            cmdParms[3].Value = model.IsRequired;
            cmdParms[4].Value = model.ID;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
        public int Add(RecordsRequiredModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into RecordsRequired(");
            builder.Append("BTable,Name,Comment,IsRequired)");
            builder.Append(" values (");
            builder.Append("@BTable,@Name,@Comment,@IsRequired)");
            builder.Append(";select @@IDENTITY");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@BTable", MySqlDbType.String),
                new MySqlParameter("@Name", MySqlDbType.String),
                new MySqlParameter("@Comment", MySqlDbType.String),
                new MySqlParameter("@IsRequired", MySqlDbType.Int32)
            };
            cmdParms[0].Value = model.BTable;
            cmdParms[1].Value = model.Name;
            cmdParms[2].Value = model.Comment;
            cmdParms[3].Value = model.IsRequired;
            object single = MySQLHelper.GetSingle(builder.ToString(), cmdParms);

            if (single == null)
            {
                return(0);
            }
            return(Convert.ToInt32(single));
        }
Beispiel #4
0
        public List <RecordsRequiredModel> DataTableToList(DataTable dt)
        {
            List <RecordsRequiredModel> list = new List <RecordsRequiredModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    RecordsRequiredModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Beispiel #5
0
 public int Add(RecordsRequiredModel model)
 {
     return(this.dal.Add(model));
 }
Beispiel #6
0
 public bool Update(RecordsRequiredModel model)
 {
     return(this.dal.Update(model));
 }