コード例 #1
0
        public RecordsEnvironmentModel DataRowToModel(DataRow row)
        {
            RecordsEnvironmentModel recordsEnvironmentModel = new RecordsEnvironmentModel();

            if (row != null)
            {
                if (((row["ID"] != null) && (row["ID"] != DBNull.Value)) && (row["ID"].ToString() != ""))
                {
                    recordsEnvironmentModel.ID = int.Parse(row["ID"].ToString());
                }
                if ((row["RecordID"] != null) && (row["RecordID"] != DBNull.Value))
                {
                    recordsEnvironmentModel.RecordID = row["RecordID"].ToString();
                }
                if ((row["IDCardNo"] != null) && (row["IDCardNo"] != DBNull.Value))
                {
                    recordsEnvironmentModel.IDCardNo = row["IDCardNo"].ToString();
                }
                if ((row["BlowMeasure"] != null) && (row["BlowMeasure"] != DBNull.Value))
                {
                    recordsEnvironmentModel.BlowMeasure = row["BlowMeasure"].ToString();
                }
                if ((row["FuelType"] != null) && (row["FuelType"] != DBNull.Value))
                {
                    recordsEnvironmentModel.FuelType = row["FuelType"].ToString();
                }
                if ((row["DrinkWater"] != null) && (row["DrinkWater"] != DBNull.Value))
                {
                    recordsEnvironmentModel.DrinkWater = row["DrinkWater"].ToString();
                }
                if ((row["Toilet"] != null) && (row["Toilet"] != DBNull.Value))
                {
                    recordsEnvironmentModel.Toilet = row["Toilet"].ToString();
                }
                if ((row["LiveStockRail"] != null) && (row["LiveStockRail"] != DBNull.Value))
                {
                    recordsEnvironmentModel.LiveStockRail = row["LiveStockRail"].ToString();
                }
                if (((row["SignDate"] != null) && (row["SignDate"] != DBNull.Value)) && (row["SignDate"].ToString() != ""))
                {
                    recordsEnvironmentModel.SignDate = new DateTime?(DateTime.Parse(row["SignDate"].ToString()));
                }
            }
            return(recordsEnvironmentModel);
        }
コード例 #2
0
        public List <RecordsEnvironmentModel> DataTableToList(DataTable dt)
        {
            List <RecordsEnvironmentModel> list = new List <RecordsEnvironmentModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    RecordsEnvironmentModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
コード例 #3
0
        public bool UpdateServer(RecordsEnvironmentModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update ARCHIVE_ENVIRONMENT set ");
            builder.Append("RecordID=@RecordID,");
            builder.Append("IDCardNo=@IDCardNo,");
            builder.Append("BlowMeasure=@BlowMeasure,");
            builder.Append("FuelType=@FuelType,");
            builder.Append("DrinkWater=@DrinkWater,");
            builder.Append("Toilet=@Toilet,");
            builder.Append("LiveStockRail=@LiveStockRail");
            builder.Append("SignDate=@SignDate ");
            builder.Append(" where IDCardNo=@IDCardNo");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@RecordID", MySqlDbType.String, 17),
                new MySqlParameter("@IDCardNo", MySqlDbType.String, 21),
                new MySqlParameter("@BlowMeasure", MySqlDbType.String, 1),
                new MySqlParameter("@FuelType", MySqlDbType.String, 1),
                new MySqlParameter("@DrinkWater", MySqlDbType.String, 1),
                new MySqlParameter("@Toilet", MySqlDbType.String, 1),
                new MySqlParameter("@LiveStockRail", MySqlDbType.String, 1),
                new MySqlParameter("@SignDate", MySqlDbType.Date)
                //new MySqlParameter("@ID", MySqlDbType.Int32, 8)
            };
            cmdParms[0].Value = model.RecordID;
            cmdParms[1].Value = model.IDCardNo;
            cmdParms[2].Value = model.BlowMeasure;
            cmdParms[3].Value = model.FuelType;
            cmdParms[4].Value = model.DrinkWater;
            cmdParms[5].Value = model.Toilet;
            cmdParms[6].Value = model.LiveStockRail;
            cmdParms[7].Value = model.SignDate;
            //cmdParms[7].Value = model.ID;
            return(MySQLHelper.ExecuteSqlServer(builder.ToString(), cmdParms) > 0);
        }
コード例 #4
0
        public int AddServer(RecordsEnvironmentModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into ARCHIVE_ENVIRONMENT(");
            builder.Append("RecordID,IDCardNo,BlowMeasure,FuelType,DrinkWater,Toilet,LiveStockRail,SignDate)");
            builder.Append(" values (");
            builder.Append("@RecordID,@IDCardNo,@BlowMeasure,@FuelType,@DrinkWater,@Toilet,@LiveStockRail,@SignDate)");
            builder.Append(";select @@IDENTITY");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@RecordID", MySqlDbType.String, 17),
                new MySqlParameter("@IDCardNo", MySqlDbType.String, 21),
                new MySqlParameter("@BlowMeasure", MySqlDbType.String, 1),
                new MySqlParameter("@FuelType", MySqlDbType.String, 1),
                new MySqlParameter("@DrinkWater", MySqlDbType.String, 1),
                new MySqlParameter("@Toilet", MySqlDbType.String, 1),
                new MySqlParameter("@LiveStockRail", MySqlDbType.String, 1),
                new MySqlParameter("@SignDate", MySqlDbType.Date)
            };
            cmdParms[0].Value = model.RecordID;
            cmdParms[1].Value = model.IDCardNo;
            cmdParms[2].Value = model.BlowMeasure;
            cmdParms[3].Value = model.FuelType;
            cmdParms[4].Value = model.DrinkWater;
            cmdParms[5].Value = model.Toilet;
            cmdParms[6].Value = model.LiveStockRail;
            cmdParms[7].Value = model.SignDate;
            object single = MySQLHelper.GetSingleServer(builder.ToString(), cmdParms);

            if (single == null)
            {
                return(0);
            }
            return(Convert.ToInt32(single));
        }
コード例 #5
0
 public int AddServer(RecordsEnvironmentModel model)
 {
     return(this.dal.AddServer(model));
 }
コード例 #6
0
 public bool UpdateServer(RecordsEnvironmentModel model)
 {
     return(this.dal.UpdateServer(model));
 }