Exemplo n.º 1
0
        public bool Update(DatumModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update EPM_Datum_All set ");
            builder.Append("i_id=@i_id,");
            builder.Append("PrjCode=@PrjCode,");
            builder.Append("AffairClass=@AffairClass,");
            builder.Append("AffairTitle=@AffairTitle,");
            builder.Append("AddDate=@AddDate,");
            builder.Append("Remark=@Remark,");
            builder.Append("Context=@Context,");
            builder.Append("DatumClass=@DatumClass,");
            builder.Append("CA=@CA");
            builder.Append(" where i_id=@i_id ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@i_id", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@PrjCode", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@AffairClass", SqlDbType.VarChar, 30), new SqlParameter("@AffairTitle", SqlDbType.VarChar, 200), new SqlParameter("@AddDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.VarChar, 300), new SqlParameter("@Context", SqlDbType.VarChar, 0x7d0), new SqlParameter("@DatumClass", SqlDbType.Int, 4), new SqlParameter("@CA", SqlDbType.Int, 4) };
            commandParameters[0].Value = model.i_id;
            commandParameters[1].Value = model.PrjCode;
            commandParameters[2].Value = model.AffairClass;
            commandParameters[3].Value = model.AffairTitle;
            commandParameters[4].Value = model.AddDate;
            commandParameters[5].Value = model.Remark;
            commandParameters[6].Value = model.Context;
            commandParameters[7].Value = model.DatumClass;
            commandParameters[8].Value = model.CA;
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters) > 0);
        }
Exemplo n.º 2
0
        public DatumModel GetModel(Guid i_id)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select  top 1 i_id,PrjCode,AffairClass,AffairTitle,AddDate,Remark,Context,DatumClass,CA from EPM_Datum_All ");
            builder.Append(" where i_id=@i_id ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@i_id", SqlDbType.UniqueIdentifier, 0x10) };
            commandParameters[0].Value = i_id;
            DatumModel model = new DatumModel();
            DataSet    set   = new DataSet();
            DataTable  table = SqlHelper.ExecuteQuery(CommandType.Text, builder.ToString(), commandParameters);

            set.Tables.Add(table);
            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if ((set.Tables[0].Rows[0]["i_id"] != null) && (set.Tables[0].Rows[0]["i_id"].ToString() != ""))
            {
                model.i_id = new Guid(set.Tables[0].Rows[0]["i_id"].ToString());
            }
            if ((set.Tables[0].Rows[0]["PrjCode"] != null) && (set.Tables[0].Rows[0]["PrjCode"].ToString() != ""))
            {
                model.PrjCode = new Guid(set.Tables[0].Rows[0]["PrjCode"].ToString());
            }
            if ((set.Tables[0].Rows[0]["AffairClass"] != null) && (set.Tables[0].Rows[0]["AffairClass"].ToString() != ""))
            {
                model.AffairClass = set.Tables[0].Rows[0]["AffairClass"].ToString();
            }
            if ((set.Tables[0].Rows[0]["AffairTitle"] != null) && (set.Tables[0].Rows[0]["AffairTitle"].ToString() != ""))
            {
                model.AffairTitle = set.Tables[0].Rows[0]["AffairTitle"].ToString();
            }
            if ((set.Tables[0].Rows[0]["AddDate"] != null) && (set.Tables[0].Rows[0]["AddDate"].ToString() != ""))
            {
                model.AddDate = DateTime.Parse(set.Tables[0].Rows[0]["AddDate"].ToString());
            }
            if ((set.Tables[0].Rows[0]["Remark"] != null) && (set.Tables[0].Rows[0]["Remark"].ToString() != ""))
            {
                model.Remark = set.Tables[0].Rows[0]["Remark"].ToString();
            }
            if ((set.Tables[0].Rows[0]["Context"] != null) && (set.Tables[0].Rows[0]["Context"].ToString() != ""))
            {
                model.Context = set.Tables[0].Rows[0]["Context"].ToString();
            }
            if ((set.Tables[0].Rows[0]["DatumClass"] != null) && (set.Tables[0].Rows[0]["DatumClass"].ToString() != ""))
            {
                model.DatumClass = int.Parse(set.Tables[0].Rows[0]["DatumClass"].ToString());
            }
            if ((set.Tables[0].Rows[0]["CA"] != null) && (set.Tables[0].Rows[0]["CA"].ToString() != ""))
            {
                model.CA = new int?(int.Parse(set.Tables[0].Rows[0]["CA"].ToString()));
            }
            return(model);
        }
Exemplo n.º 3
0
        public int Add(DatumModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into EPM_Datum_All(");
            builder.Append("i_id,PrjCode,AffairClass,AffairTitle,AddDate,Remark,Context,DatumClass,CA)");
            builder.Append(" values (");
            builder.Append("@i_id,@PrjCode,@AffairClass,@AffairTitle,@AddDate,@Remark,@Context,@DatumClass,@CA)");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@i_id", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@PrjCode", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@AffairClass", SqlDbType.VarChar, 30), new SqlParameter("@AffairTitle", SqlDbType.VarChar, 200), new SqlParameter("@AddDate", SqlDbType.DateTime), new SqlParameter("@Remark", SqlDbType.VarChar, 300), new SqlParameter("@Context", SqlDbType.VarChar, 0x7d0), new SqlParameter("@DatumClass", SqlDbType.Int, 4), new SqlParameter("@CA", SqlDbType.Int, 4) };
            commandParameters[0].Value = Guid.NewGuid();
            commandParameters[1].Value = model.PrjCode;
            commandParameters[2].Value = model.AffairClass;
            commandParameters[3].Value = model.AffairTitle;
            commandParameters[4].Value = model.AddDate;
            commandParameters[5].Value = model.Remark;
            commandParameters[6].Value = model.Context;
            commandParameters[7].Value = model.DatumClass;
            commandParameters[8].Value = model.CA;
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters));
        }