Esempio n. 1
0
        public int Add(PEIS.Model.DictCultrul model)
        {
            StringBuilder stringBuilder = new StringBuilder();

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

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

            PEIS.Model.DictCultrul result;
            if (dataSet.Tables[0].Rows.Count > 0)
            {
                if (dataSet.Tables[0].Rows[0]["CultrulID"].ToString() != "")
                {
                    dctCultrul.CultrulID = int.Parse(dataSet.Tables[0].Rows[0]["CultrulID"].ToString());
                }
                dctCultrul.CultrulName = dataSet.Tables[0].Rows[0]["CultrulName"].ToString();
                dctCultrul.InputCode   = dataSet.Tables[0].Rows[0]["InputCode"].ToString();
                result = dctCultrul;
            }
            else
            {
                result = null;
            }
            return(result);
        }
Esempio n. 3
0
        public List <PEIS.Model.DictCultrul> DataTableToList(DataTable dt)
        {
            List <PEIS.Model.DictCultrul> list = new List <PEIS.Model.DictCultrul>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    PEIS.Model.DictCultrul dctCultrul = new PEIS.Model.DictCultrul();
                    if (dt.Rows[i]["CultrulID"].ToString() != "")
                    {
                        dctCultrul.CultrulID = int.Parse(dt.Rows[i]["CultrulID"].ToString());
                    }
                    dctCultrul.CultrulName = dt.Rows[i]["CultrulName"].ToString();
                    dctCultrul.InputCode   = dt.Rows[i]["InputCode"].ToString();
                    list.Add(dctCultrul);
                }
            }
            return(list);
        }
Esempio n. 4
0
        public bool Update(PEIS.Model.DictCultrul model)
        {
            StringBuilder stringBuilder = new StringBuilder();

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

            return(num > 0);
        }
Esempio n. 5
0
 public bool Update(PEIS.Model.DictCultrul model)
 {
     return(this.dal.Update(model));
 }
Esempio n. 6
0
 public int Add(PEIS.Model.DictCultrul model)
 {
     return(this.dal.Add(model));
 }