コード例 #1
0
        private UnitType_ DataTableToEntity(DataTable dt)
        {
            UnitType_ unitType = new UnitType_();

            if (Null.IsNotNull(dt) == true && dt.Rows.Count > 0)
            {
                if (Null.IsNotNull(dt.Rows[0]))
                {
                    DataRow dr = dt.Rows[0];
                    if (Null.IsNotNull(dr["ID"]))
                    {
                        unitType.ID = Convert.ToInt32(dr["ID"]);
                    }
                    else
                    {
                        unitType.ID = 0;
                    }
                    if (Null.IsNotNull(dr["UnitTypeName"]))
                    {
                        unitType.UnitTypeName = Convert.ToString(dr["UnitTypeName"]);
                    }
                    else
                    {
                        unitType.UnitTypeName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["ShortUnitTypeName"]))
                    {
                        unitType.ShortUnitTypeName = Convert.ToString(dr["ShortUnitTypeName"]);
                    }
                    else
                    {
                        unitType.ShortUnitTypeName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Status"]))
                    {
                        unitType.Status = Convert.ToString(dr["Status"]);
                    }
                    else
                    {
                        unitType.Status = string.Empty;
                    }
                }
            }
            return(unitType);
        }
コード例 #2
0
        public int Update(UnitType_ unitType)
        {
            UpdateCommand.Parameters["@ID"].Value                = unitType.ID;
            UpdateCommand.Parameters["@UnitTypeName"].Value      = unitType.UnitTypeName;
            UpdateCommand.Parameters["@ShortUnitTypeName"].Value = unitType.ShortUnitTypeName;
            UpdateCommand.Parameters["@Status"].Value            = unitType.Status;

            int returnValue = -1;

            try
            {
                UpdateCommand.Connection.Open();
                returnValue = UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                UpdateCommand.Connection.Close();
            }
            return(returnValue);
        }
コード例 #3
0
        public int Insert(UnitType_ unitType)
        {
            InsertCommand.Parameters["@UnitTypeName"].Value      = unitType.UnitTypeName;
            InsertCommand.Parameters["@ShortUnitTypeName"].Value = unitType.ShortUnitTypeName;
            InsertCommand.Parameters["@Status"].Value            = unitType.Status;


            int returnValue = -1;

            try
            {
                InsertCommand.Connection.Open();
                returnValue = (int)InsertCommand.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                InsertCommand.Connection.Close();
            }
            return(returnValue);
        }