Ejemplo n.º 1
0
        //根据adoptID 获取对应的信息
        public CTAdoptPet GetAdoptInfoByAdoptID(string adoptID)
        {
            CTAdoptPet adoptInfo = new CTAdoptPet();
            SqlParameter parm = new SqlParameter();
            parm.ParameterName = PARM_ADOPT_ID;
            parm.Value = adoptID;
            try
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ADOPTPET_BY_ADIPTID, parm))
                {
                    while (reader.Read())
                    {
                        CTAdoptPet adoptPet = new CTAdoptPet();
                        adoptPet.AdoptID = reader["AdoptID"].ToString();
                        adoptPet.UserID = reader["UserID"].ToString();
                        adoptPet.AddressID = reader["AddressID"].ToString();
                        adoptPet.AdoptInfo = reader["AdoptInfo"].ToString();
                        adoptPet.AdoptTitle = reader["AdoptTitle"].ToString();
                        adoptPet.PetCategoryID = reader["PetCategoryID"].ToString();
                        adoptPet.PriorityScore = int.Parse(reader["PriorityScore"].ToString());
                        adoptPet.WeiBoID = reader["WeiBoID"].ToString();
                        bool tempIsAdopt = true;
                        adoptPet.IsAdopt = bool.TryParse(reader["IsAdopt"].ToString(), out tempIsAdopt) ? tempIsAdopt : true;

                        DateTime tempLastEditTime = DateTime.Now;
                        tempLastEditTime = DateTime.TryParse(reader["LastEditTime"].ToString(), out tempLastEditTime) ? tempLastEditTime : DateTime.Now;
                        adoptPet.LastEditTime = tempLastEditTime.ToString("yyyy/MM/dd hh:mm:ss");

                        DateTime tempAdoptTime = DateTime.Now;
                        tempAdoptTime = DateTime.TryParse(reader["AdoptTime"].ToString(), out tempAdoptTime) ? tempAdoptTime : DateTime.Now;
                        adoptPet.AdoptTime = tempAdoptTime.ToString("yyyy/MM/dd hh:mm:ss");

                        adoptPet.IsVisible = bool.Parse(reader["IsVisible"].ToString());
                        adoptPet.IP = reader["IP"].ToString();
                        int tempFocusNum = 0;
                        adoptPet.FocusNum = int.TryParse(reader["FocusNum"].ToString(), out tempFocusNum) ? tempFocusNum : 0;
                        adoptInfo=adoptPet;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return adoptInfo;
        }
Ejemplo n.º 2
0
        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            string title = tbTitle.Text.Trim().ToString();
            string content = tbContent.Text.ToString();
            string userID = ddlUser.SelectedValue.ToString();
            string categoryID = ddlCategoryAdd.SelectedValue.ToString();
            string addressID = ddlAddressAdd.SelectedValue.ToString();
            string adoptID = Guid.NewGuid().ToString();
            bool isAdopt = bool.Parse(CheckBox1.Checked.ToString());
            //获取本机IP
            IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName());
            IPAddress ipa = ipe.AddressList[0];
            string ip=ipa.ToString();

            CTAdoptPet adoptPet = new CTAdoptPet();
            adoptPet.AddressID = addressID;
            adoptPet.PetCategoryID = categoryID;
            adoptPet.AdoptID = adoptID;
            adoptPet.AdoptInfo = content;
            adoptPet.AdoptTime = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss");
            adoptPet.LastEditTime = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss");
            adoptPet.AdoptTitle = title;
            adoptPet.FocusNum = 0;
            adoptPet.IP = ip;
            adoptPet.IsVisible = true;
            adoptPet.PriorityScore = 0;
            adoptPet.WeiBoID = "";
            adoptPet.UserID = userID;
            adoptPet.IsAdopt = isAdopt;

            AdoptPet adoptPetone = new AdoptPet();
            int insertStatus = 0;
            insertStatus=adoptPetone.InsertAdoptPet(adoptPet);
            if (insertStatus == 1)
            {
                Response.Write("<script>alert('添加成功!')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败!')</script>");
            }
        }
Ejemplo n.º 3
0
 protected void Btn_Save_Click(object sender, EventArgs e)
 {
     CTAdoptPet ctadopt = new CTAdoptPet();
     ctadopt.AdoptID = TextBox_AdoptID.Text;
     ctadopt.AdoptInfo = TextBox_AdoptInfo.Text;
     ctadopt.AddressID = TextBox_AddressID.Text;
     ctadopt.AdoptTime = TextBox_AdoptTime.Text.ToString();
     ctadopt.AdoptTitle = TextBox_AdoptTitle.Text.ToString();
     ctadopt.FocusNum =int.Parse(TextBox_FocusNum.Text.ToString());
     ctadopt.IP = TextBox_IP.Text.ToString();
     ctadopt.PetCategoryID = TextBox_PetCategoryID.Text.ToString();
     ctadopt.PriorityScore = int.Parse(TextBox_PriorityScore.Text.ToString());
     ctadopt.UserID = TextBox_UserID.Text.ToString();
     ctadopt.WeiBoID = TextBox_WeiBoID.Text.ToString();
     ctadopt.LastEditTime = DateTime.Now.ToShortDateString();
     AdoptPet adoptPet = new AdoptPet();
     int editStatus = 0;
     editStatus=adoptPet.EditAdoptInfo(ctadopt);
     if (editStatus == 1)
     {
         Response.Write("<script>alert('Edit成功!')</script>");
     }
     else
     {
         Response.Write("<script>alert('Edit失败!')</script>");
     }
 }
Ejemplo n.º 4
0
        protected void BtnEdit_Click(object sender, EventArgs e)
        {
            string sqlstr=string.Empty;
            int checkNumber = 0;
            for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
            {
                CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxs");
                if (cbox.Checked == true)
                {
                    sqlstr = GridView1.DataKeys[i].Value.ToString();
                    checkNumber++;
                    break;
                }
            }
            if (checkNumber > 1 || checkNumber < 1)
            {
                Response.Write("<script>alert('请选择一个!')</script>");
            }
            else
            {

                AdoptPet adoptPet = new AdoptPet();
                CTAdoptPet ctadopt = new CTAdoptPet();
                ctadopt = adoptPet.GetPetAdoptPetByAdoptID(sqlstr);
                TextBox_AdoptID.Text = ctadopt.AdoptID;
                TextBox_AdoptInfo.Text = ctadopt.AdoptInfo;
                TextBox_AddressID.Text = ctadopt.AddressID;
                TextBox_AdoptTime.Text = ctadopt.AdoptTime.ToString();
                TextBox_AdoptTitle.Text = ctadopt.AdoptTitle.ToString();
                TextBox_FocusNum.Text = ctadopt.FocusNum.ToString();
                TextBox_IP.Text = ctadopt.IP.ToString();
                TextBox_PetCategoryID.Text = ctadopt.PetCategoryID.ToString();
                TextBox_PriorityScore.Text = ctadopt.PriorityScore.ToString();
                TextBox_UserID.Text = ctadopt.UserID.ToString();
                TextBox_WeiBoID.Text = ctadopt.WeiBoID.ToString();
            }
        }
Ejemplo n.º 5
0
        //更新记录
        public int UpdateAdoptPet(CTAdoptPet AdoptPetInfo)
        {
            int updateStatus = 0;

            //得到所有的参数数组
            SqlParameter[] adoptPetParams = null;
            adoptPetParams = new SqlParameter[]
                            {
                                new SqlParameter("@AdoptID",SqlDbType.NVarChar,32),
                                new SqlParameter("@AddressID",SqlDbType.NVarChar,20),
                                new SqlParameter("@PetCategoryID",SqlDbType.NVarChar,20),
                                new SqlParameter("@AdoptTitle",SqlDbType.NVarChar,20),
                                new SqlParameter("@LastEditTime",SqlDbType.DateTime ),
                                new SqlParameter("@AdoptInfo",SqlDbType.NVarChar),
                                new SqlParameter("@IP",SqlDbType.NVarChar,20),
                            };
            adoptPetParams[0].Value = AdoptPetInfo.AdoptID;
            adoptPetParams[1].Value = AdoptPetInfo.AddressID;
            adoptPetParams[2].Value = AdoptPetInfo.PetCategoryID;
            adoptPetParams[3].Value = AdoptPetInfo.AdoptTitle;
            adoptPetParams[4].Value = Convert.ToDateTime(AdoptPetInfo.LastEditTime);
            adoptPetParams[5].Value = AdoptPetInfo.AdoptInfo;
            adoptPetParams[6].Value = AdoptPetInfo.IP;

            try
            {
                using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringOrderDistributedTransaction))
                {
                    updateStatus = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_UPDATE_ADOPTPET, adoptPetParams);
                }
            }
            catch (Exception ex)
            {

            }
            return updateStatus;
        }
Ejemplo n.º 6
0
        //添加新记录
        public int InsertAdoptPet(CTAdoptPet AdoptPetInfo)
        {
            int insertStatus = 0;
            //得到所有的参数数组
            SqlParameter[] adoptPetParams = null;
            adoptPetParams = new SqlParameter[]
                            {
                                new SqlParameter("@AdoptID",SqlDbType.NVarChar,32),
                                new SqlParameter("@UserID",SqlDbType.NVarChar,20),
                                new SqlParameter("@AddressID",SqlDbType.NVarChar,20),
                                new SqlParameter("@PetCategoryID",SqlDbType.NVarChar,20),
                                new SqlParameter("@WeiBoID",SqlDbType.NVarChar,20),
                                new SqlParameter("@AdoptTitle",SqlDbType.NVarChar,20),
                                new SqlParameter("@AdoptTime",SqlDbType.DateTime ),
                                new SqlParameter("@LastEditTime",SqlDbType.DateTime ),
                                new SqlParameter("@AdoptInfo",SqlDbType.NVarChar),
                                new SqlParameter("@IP",SqlDbType.NVarChar,20),
                                new SqlParameter("@PriorityScore",SqlDbType.Int),
                                new SqlParameter("@FocusNum",SqlDbType.Int),
                                new SqlParameter("@IsVisible",SqlDbType.Bit),
                                new SqlParameter("@IsAdopt",SqlDbType.Bit),
                            };
            adoptPetParams[0].Value = AdoptPetInfo.AdoptID;
            adoptPetParams[1].Value = AdoptPetInfo.UserID;
            adoptPetParams[2].Value = AdoptPetInfo.AddressID;
            adoptPetParams[3].Value = AdoptPetInfo.PetCategoryID;
            adoptPetParams[4].Value = AdoptPetInfo.WeiBoID;
            adoptPetParams[5].Value = AdoptPetInfo.AdoptTitle;
            adoptPetParams[6].Value = Convert.ToDateTime(AdoptPetInfo.AdoptTime);
            adoptPetParams[7].Value = Convert.ToDateTime(AdoptPetInfo.LastEditTime);
            adoptPetParams[8].Value = AdoptPetInfo.AdoptInfo;
            adoptPetParams[9].Value = AdoptPetInfo.IP;
            adoptPetParams[10].Value = AdoptPetInfo.PriorityScore;
            adoptPetParams[11].Value = AdoptPetInfo.FocusNum;
            adoptPetParams[12].Value = AdoptPetInfo.IsVisible;
            adoptPetParams[13].Value = AdoptPetInfo.IsAdopt;

            try
            {
                using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringOrderDistributedTransaction))
                {
                    insertStatus = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_INSERT_ADOPTPET, adoptPetParams);
                }
            }
            catch (Exception ex)
            {

            }

            return insertStatus;
        }
Ejemplo n.º 7
0
        //获取所有的petlist
        public List<CTAdoptPet> GetAllAdoptPetList()
        {
            List<CTAdoptPet> AdoptPetList = new List<CTAdoptPet>();
            try
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ADOPTPET, null))
                {
                    while (reader.Read())
                    {
                        CTAdoptPet adoptPet = new CTAdoptPet();
                        adoptPet.AdoptID = reader["AdoptID"].ToString();
                        adoptPet.UserID = reader["UserID"].ToString();
                        adoptPet.AddressID = reader["AddressID"].ToString();
                        adoptPet.AdoptInfo = reader["AdoptInfo"].ToString();
                        adoptPet.AdoptTitle = reader["AdoptTitle"].ToString();
                        adoptPet.PetCategoryID = reader["PetCategoryID"].ToString();
                        adoptPet.PriorityScore = int.Parse(reader["PriorityScore"].ToString());
                        adoptPet.WeiBoID = reader["WeiBoID"].ToString();
                        bool tempIsAdopt = true;
                        adoptPet.IsAdopt = bool.TryParse(reader["IsAdopt"].ToString(), out tempIsAdopt) ? tempIsAdopt : true;

                        DateTime tempLastEditTime = DateTime.Now;
                        tempLastEditTime = DateTime.TryParse(reader["LastEditTime"].ToString(), out tempLastEditTime) ? tempLastEditTime : DateTime.Now;
                        adoptPet.LastEditTime = tempLastEditTime.ToString("yyyy/MM/dd hh:mm:ss");

                        DateTime tempAdoptTime = DateTime.Now;
                        tempAdoptTime = DateTime.TryParse(reader["AdoptTime"].ToString(), out tempAdoptTime) ? tempAdoptTime : DateTime.Now;
                        adoptPet.AdoptTime = tempAdoptTime.ToString("yyyy/MM/dd hh:mm:ss");

                        adoptPet.IsVisible = bool.Parse(reader["IsVisible"].ToString());
                        adoptPet.IP = reader["IP"].ToString();
                        int tempFocusNum = 0;
                        adoptPet.FocusNum = int.TryParse(reader["FocusNum"].ToString(), out tempFocusNum) ? tempFocusNum : 0;
                        AdoptPetList.Add(adoptPet);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return AdoptPetList;
        }
Ejemplo n.º 8
0
        //根据userID获取其发布petlist
        public List<CTAdoptPet> GetAdoptPetListByUser(string UserID)
        {
            List<CTAdoptPet> AdoptPetList = new List<CTAdoptPet>();
            SqlParameter parm = new SqlParameter(PARM_USER_ID, SqlDbType.NVarChar);
            parm.Value = UserID;
            try
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ADOPTPET_BY_USERID, parm))
                {
                    while (reader.Read())
                    {
                        CTAdoptPet adoptPet = new CTAdoptPet();
                        adoptPet.AdoptID = reader["AdoptID"].ToString();
                        adoptPet.UserID = reader["UserID"].ToString();
                        adoptPet.AddressID = reader["AddressID"].ToString();
                        adoptPet.AdoptInfo = reader["AdoptInfo"].ToString();
                        adoptPet.AdoptTitle = reader["AdoptTitle"].ToString();
                        adoptPet.PetCategoryID = reader["PetCategoryID"].ToString();
                        adoptPet.PriorityScore = int.Parse(reader["PriorityScore"].ToString());
                        adoptPet.WeiBoID = reader["WeiBoID"].ToString();

                        DateTime tempLastEditTime = DateTime.Now;
                        tempLastEditTime = DateTime.TryParse(reader["LastEditTime"].ToString(), out tempLastEditTime) ? tempLastEditTime : DateTime.Now;
                        adoptPet.LastEditTime = tempLastEditTime.ToString("yyyy/MM/dd hh:mm:ss");

                        DateTime tempKnowledgeTime = DateTime.Now;
                        tempKnowledgeTime = DateTime.TryParse(reader["AdoptTime"].ToString(), out tempKnowledgeTime) ? tempKnowledgeTime : DateTime.Now;
                        adoptPet.AdoptTime = tempKnowledgeTime.ToString("yyyy/MM/dd hh:mm:ss");

                        adoptPet.IsVisible = bool.Parse(reader["IsVisible"].ToString());
                        adoptPet.IP = reader["IP"].ToString();
                        adoptPet.IsAdopt = bool.Parse(reader["IsAdopt"].ToString());
                        int tempFocusNum = 0;
                        adoptPet.FocusNum = int.TryParse(reader["FocusNum"].ToString(), out tempFocusNum) ? tempFocusNum : 0;
                        AdoptPetList.Add(adoptPet);
                    }
                }
            }
            catch (Exception ex)
            {

            }
            return AdoptPetList;
        }