示例#1
0
        public int Add(PEIS.Model.DictNation model)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("insert into DictNation(");
            stringBuilder.Append("NationName,InputCode)");
            stringBuilder.Append(" values (");
            stringBuilder.Append("@NationName,@InputCode)");
            stringBuilder.Append(";select @@IDENTITY");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@NationName", SqlDbType.VarChar, 10),
                new SqlParameter("@InputCode", SqlDbType.VarChar, 8)
            };
            array[0].Value = model.NationName;
            array[1].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
        public PEIS.Model.DictNation GetModel(int NationID)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("select  top 1 NationID,NationName,InputCode from DictNation ");
            stringBuilder.Append(" where NationID=@NationID");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@NationID", SqlDbType.Int, 4)
            };
            array[0].Value = NationID;
            PEIS.Model.DictNation dctNation = new PEIS.Model.DictNation();
            DataSet dataSet = DbHelperSQL.Query(stringBuilder.ToString(), array);

            PEIS.Model.DictNation result;
            if (dataSet.Tables[0].Rows.Count > 0)
            {
                if (dataSet.Tables[0].Rows[0]["NationID"].ToString() != "")
                {
                    dctNation.NationID = int.Parse(dataSet.Tables[0].Rows[0]["NationID"].ToString());
                }
                dctNation.NationName = dataSet.Tables[0].Rows[0]["NationName"].ToString();
                dctNation.InputCode  = dataSet.Tables[0].Rows[0]["InputCode"].ToString();
                result = dctNation;
            }
            else
            {
                result = null;
            }
            return(result);
        }
示例#3
0
        public bool Update(PEIS.Model.DictNation model)
        {
            StringBuilder stringBuilder = new StringBuilder();

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

            return(num > 0);
        }
示例#4
0
        public List <PEIS.Model.DictNation> DataTableToList(DataTable dt)
        {
            List <PEIS.Model.DictNation> list = new List <PEIS.Model.DictNation>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    PEIS.Model.DictNation dctNation = new PEIS.Model.DictNation();
                    if (dt.Rows[i]["NationID"].ToString() != "")
                    {
                        dctNation.NationID = int.Parse(dt.Rows[i]["NationID"].ToString());
                    }
                    dctNation.NationName = dt.Rows[i]["NationName"].ToString();
                    dctNation.InputCode  = dt.Rows[i]["InputCode"].ToString();
                    list.Add(dctNation);
                }
            }
            return(list);
        }
示例#5
0
 public bool Update(PEIS.Model.DictNation model)
 {
     return(this.dal.Update(model));
 }
示例#6
0
 public int Add(PEIS.Model.DictNation model)
 {
     return(this.dal.Add(model));
 }