Example #1
0
        public SurveyObj GetSurveyByID(int orderID)
        {
            using (helper = new SqlHelper())
            {
                helper.AddIntParameter("@OrderID", orderID);

                using (SqlDataReader dr = helper.ExecuteReader("select OrderID,SurveyLike,CustomerName,Gender,Mobile,Email,Survey.RegionID,Address,Type,SquareType,Options,Days,HopeTime,Pic,Memo,City.CityID,City.ProvinceID,HopeHour,RegionName,CityName,ProvinceName from Survey left join Region on Region.RegionID=Survey.RegionID left join City on Region.CityID=City.CityID left join Province on Province.ProvinceID=City.ProvinceID where OrderID=@OrderID", CommandType.Text))
                {
                    if (dr.HasRows && dr.Read())
                    {
                        SurveyObj surveyObj = new SurveyObj();
                        surveyObj.OrderID      = dr[0] == DBNull.Value ? 0 : (int)dr[0];
                        surveyObj.SurveyLike   = dr[1] == DBNull.Value ? 0 : (int)dr[1];
                        surveyObj.CustomerName = dr[2] == DBNull.Value ? null : (string)dr[2];
                        surveyObj.Gender       = dr[3] == DBNull.Value ? false : (bool)dr[3];
                        surveyObj.Mobile       = dr[4] == DBNull.Value ? null : (string)dr[4];
                        surveyObj.Email        = dr[5] == DBNull.Value ? null : (string)dr[5];
                        surveyObj.RegionID     = dr[6] == DBNull.Value ? 0 : (int)dr[6];
                        surveyObj.Address      = dr[7] == DBNull.Value ? null : (string)dr[7];
                        surveyObj.Type         = dr[8] == DBNull.Value ? 0 : (int)dr[8];
                        surveyObj.SquareType   = dr[9] == DBNull.Value ? 0 : (int)dr[9];
                        surveyObj.Options      = dr[10] == DBNull.Value ? null : (string)dr[10];
                        surveyObj.Days         = dr[11] == DBNull.Value ? 0 : (int)dr[11];
                        surveyObj.HopeTime     = dr[12] == DBNull.Value ? null : (string)dr[12];
                        surveyObj.Pic          = dr[13] == DBNull.Value ? null : (string)dr[13];
                        surveyObj.Memo         = dr[14] == DBNull.Value ? null : (string)dr[14];
                        surveyObj.CityID       = dr[15] == DBNull.Value ? 0 : (int)dr[15];
                        surveyObj.ProvinceID   = dr[16] == DBNull.Value ? 0 : (int)dr[16];
                        surveyObj.HopeHour     = dr[17] == DBNull.Value ? 0 : (int)dr[17];
                        surveyObj.RegionName   = dr[18] == DBNull.Value ? null : (string)dr[18];
                        surveyObj.CityName     = dr[19] == DBNull.Value ? null : (string)dr[19];
                        surveyObj.ProvinceName = dr[20] == DBNull.Value ? null : (string)dr[20];

                        return(surveyObj);
                    }
                    return(null);
                }
            }
        }
Example #2
0
        public void SetSurvey(SurveyObj surveyObj)
        {
            using (helper = new SqlHelper())
            {
                helper.AddIntParameter("@OrderID", surveyObj.OrderID);
                helper.AddIntParameter("@SurveyLike", surveyObj.SurveyLike);
                helper.AddStringParameter("@CustomerName", 50, surveyObj.CustomerName);
                helper.AddBoolenParameter("@Gender", surveyObj.Gender);
                helper.AddStringParameter("@Mobile", 50, surveyObj.Mobile);
                helper.AddStringParameter("@Email", 100, surveyObj.Email);
                helper.AddIntParameter("@RegionID", surveyObj.RegionID);
                helper.AddStringParameter("@Address", 400, surveyObj.Address);
                helper.AddIntParameter("@Type", surveyObj.Type);
                helper.AddIntParameter("@SquareType", surveyObj.SquareType);
                helper.AddStringParameter("@Options", 50, surveyObj.Options);
                helper.AddIntParameter("@Days", surveyObj.Days);
                helper.AddStringParameter("@HopeTime", 100, surveyObj.HopeTime);
                helper.AddStringParameter("@Pic", 200, surveyObj.Pic);
                helper.AddTextParameter("@Memo", surveyObj.Memo);
                helper.AddIntParameter("@HopeHour", surveyObj.HopeHour);

                helper.ExecuteNonQuery("if exists (select 1 from Survey where OrderID=@OrderID) update Survey set SurveyLike=@SurveyLike,CustomerName=@CustomerName,Gender=@Gender,Mobile=@Mobile,Email=@Email,RegionID=@RegionID,Address=@Address,Type=@Type,SquareType=@SquareType,Options=@Options,Days=@Days,HopeTime=@HopeTime,Pic=@Pic,Memo=@Memo,HopeHour=@HopeHour where OrderID=@OrderID else insert into Survey (OrderID,SurveyLike,CustomerName,Gender,Mobile,Email,RegionID,Address,Type,SquareType,Options,Days,HopeTime,Pic,Memo,HopeHour) values (@OrderID,@SurveyLike,@CustomerName,@Gender,@Mobile,@Email,@RegionID,@Address,@Type,@SquareType,@Options,@Days,@HopeTime,@Pic,@Memo,@HopeHour)", CommandType.Text);
            }
        }
Example #3
0
 public void SetSurvey(SurveyObj surveyObj)
 {
     dal.SetSurvey(surveyObj);
 }