コード例 #1
0
ファイル: DictMarriage.cs プロジェクト: myonhu/PEIS-PEIS
        public int Add(PEIS.Model.DictMarriage model)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("insert into DictMarriage(");
            stringBuilder.Append("MarriageName,IsMarried,InputCode)");
            stringBuilder.Append(" values (");
            stringBuilder.Append("@MarriageName,@Is_Married,@InputCode)");
            stringBuilder.Append(";select @@IDENTITY");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@MarriageName", SqlDbType.VarChar, 8),
                new SqlParameter("@IsMarried", SqlDbType.Int, 4),
                new SqlParameter("@InputCode", SqlDbType.VarChar, 8)
            };
            array[0].Value = model.MarriageName;
            array[1].Value = model.IsMarried;
            array[2].Value = model.InputCode;
            object single = DbHelperSQL.GetSingle(stringBuilder.ToString(), array);
            int    result;

            if (single == null)
            {
                result = 0;
            }
            else
            {
                result = Convert.ToInt32(single);
            }
            return(result);
        }
コード例 #2
0
ファイル: DictMarriage.cs プロジェクト: myonhu/PEIS-PEIS
        public PEIS.Model.DictMarriage GetModel(int MarriageID)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("select  top 1 MarriageID,MarriageName,IsMarried,InputCode from DictMarriage ");
            stringBuilder.Append(" where MarriageID=@MarriageID");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@MarriageID", SqlDbType.Int, 4)
            };
            array[0].Value = MarriageID;
            PEIS.Model.DictMarriage marriage = new PEIS.Model.DictMarriage();
            DataSet dataSet = DbHelperSQL.Query(stringBuilder.ToString(), array);

            PEIS.Model.DictMarriage result;
            if (dataSet.Tables[0].Rows.Count > 0)
            {
                if (dataSet.Tables[0].Rows[0]["MarriageID"].ToString() != "")
                {
                    marriage.MarriageID = int.Parse(dataSet.Tables[0].Rows[0]["MarriageID"].ToString());
                }
                marriage.MarriageName = dataSet.Tables[0].Rows[0]["MarriageName"].ToString();
                if (dataSet.Tables[0].Rows[0]["IsMarried"].ToString() != "")
                {
                    marriage.IsMarried = int.Parse(dataSet.Tables[0].Rows[0]["IsMarried"].ToString());
                }
                marriage.InputCode = dataSet.Tables[0].Rows[0]["InputCode"].ToString();
                result             = marriage;
            }
            else
            {
                result = null;
            }
            return(result);
        }
コード例 #3
0
ファイル: DictMarriage.cs プロジェクト: myonhu/PEIS-PEIS
        public bool Update(PEIS.Model.DictMarriage model)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("update DictMarriage set ");
            stringBuilder.Append("MarriageName=@MarriageName,");
            stringBuilder.Append("IsMarried=@IsMarried,");
            stringBuilder.Append("InputCode=@InputCode");
            stringBuilder.Append(" where MarriageID=@MarriageID");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@MarriageName", SqlDbType.VarChar, 8),
                new SqlParameter("@IsMarried", SqlDbType.Int, 4),
                new SqlParameter("@InputCode", SqlDbType.VarChar, 8),
                new SqlParameter("@MarriageID", SqlDbType.Int, 4)
            };
            array[0].Value = model.MarriageName;
            array[1].Value = model.IsMarried;
            array[2].Value = model.InputCode;
            array[3].Value = model.MarriageID;
            int num = DbHelperSQL.ExecuteSql(stringBuilder.ToString(), array);

            return(num > 0);
        }
コード例 #4
0
ファイル: DictMarriage.cs プロジェクト: myonhu/PEIS-PEIS
		public List<PEIS.Model.DictMarriage> DataTableToList(DataTable dt)
		{
			List<PEIS.Model.DictMarriage> list = new List<PEIS.Model.DictMarriage>();
			int count = dt.Rows.Count;
			if (count > 0)
			{
				for (int i = 0; i < count; i++)
				{
					PEIS.Model.DictMarriage marriage = new PEIS.Model.DictMarriage();
					if (dt.Rows[i]["MarriageID"].ToString() != "")
					{
                        marriage.MarriageID = int.Parse(dt.Rows[i]["MarriageID"].ToString());
					}
                    marriage.MarriageName = dt.Rows[i]["MarriageName"].ToString();
					if (dt.Rows[i]["MarriageID"].ToString() != "")
					{
                        marriage.MarriageID = int.Parse(dt.Rows[i]["MarriageID"].ToString());
					}
                    marriage.InputCode = dt.Rows[i]["InputCode"].ToString();
					list.Add(marriage);
				}
			}
			return list;
		}
コード例 #5
0
ファイル: DictMarriage.cs プロジェクト: myonhu/PEIS-PEIS
		public bool Update(PEIS.Model.DictMarriage model)
		{
			return this.dal.Update(model);
		}
コード例 #6
0
ファイル: DictMarriage.cs プロジェクト: myonhu/PEIS-PEIS
		public int Add(PEIS.Model.DictMarriage model)
		{
			return this.dal.Add(model);
		}