Ejemplo n.º 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            SYCRM.Model.Festivals MF = new SYCRM.Model.Festivals();
            SYCRM.BLL.Festivals BF = new SYCRM.BLL.Festivals();

            DateTime temp = new DateTime();

            if (DateTime.TryParse(tbFDate.Text.Trim(), out temp))
            {
                MF.FName = tbFName.Text;
                MF.FDateTime = temp; ;
                MF.Status = 1;
                BF.Add(MF);
                tbFName.Text = "";
                tbFDate.Text = "";
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "添加成功!", "<script>alert('添加成功!');window.location.href='Festivals.aspx'</script>");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public SYCRM.Model.Festivals GetModel(Guid Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 * from Festivals ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.UniqueIdentifier)};
            parameters[0].Value = Id;

            SYCRM.Model.Festivals model=new SYCRM.Model.Festivals();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["Id"].ToString()!="")
                {
                    model.Id=new Guid(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Status"].ToString()!="")
                {
                    model.Status=int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                model.FName=ds.Tables[0].Rows[0]["FName"].ToString();
                if(ds.Tables[0].Rows[0]["FDateTime"].ToString()!="")
                {
                    model.FDateTime=DateTime.Parse(ds.Tables[0].Rows[0]["FDateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Code"].ToString() != "")
                {
                    model.Code = int.Parse(ds.Tables[0].Rows[0]["Code"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }