public void PublishGroup(string jsondata, string version, string equType, string equName)
        {
            string json_result = string.Empty;
            //解析jsondata
            if (string.IsNullOrEmpty(jsondata))
            {
                json_result = "{\"status\":\"false\",\"data\":\"参数不能为空!\"}";
                Context.Response.Write(json_result);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                return;
            }
            try
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(jsondata);

                Model.tourgroup model = new Model.tourgroup();
                BLL.tourgroup bll = new BLL.tourgroup();
                int manager_id = 0;
                int.TryParse(json["groupteamid"].ToString(), out manager_id);

                //验证旅行社的有效性
                BLL.manager bll_manager = new BLL.manager();
                Model.manager managerModel = bll_manager.GetModel(manager_id);
                if (managerModel == null || managerModel.is_lock != 0 || DateTime.Parse(managerModel.end_date) < DateTime.Now)
                {
                    json_result = "{\"status\":\"false\",\"data\":\"此旅行社现不能发团,请联系管理员!\"}";
                    Context.Response.Write(json_result);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    return;
                }

                model.manager_id = manager_id;
                model.channel_id = (int)DTEnums.ChannelEnum.lvtuan;
                model.title = json["title"].ToString();
                model.category_id = int.Parse(json["category"].ToString());
                model.content = "";
                model.book_require = json["bookrequire"].ToString();

                #region 类别处理
                //处理类别,根据名称与标识转为类别ID
                int languagetype = 0;
                int accounttype = 0;
                int linecity = 0;
                int property = 0;
                int restauranttype = 0;
                int tickettype = 0;
                int fromplaceid = 0;
                int toplaceid = 0;

                //将省级名称转为ID
                if (json.ContainsKey("fromplace") && !string.IsNullOrEmpty(json["fromplace"].ToString()))
                {
                    fromplaceid = bll_city.GetParentIdByName(json["fromplace"].ToString(), 1);
                    if (fromplaceid == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"客源地不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }
                if (json.ContainsKey("toplace") && !string.IsNullOrEmpty(json["toplace"].ToString()))
                {
                    toplaceid = bll_city.GetParentIdByName(json["toplace"].ToString(), 1);
                    if (toplaceid == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"目的地不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }

                if (json.ContainsKey("languagetype") && !string.IsNullOrEmpty(json["languagetype"].ToString()))
                {
                    languagetype = bll_category.GetCategoryIdByName(json["languagetype"].ToString(), DTEnums.CategoryEnum.language.ToString());
                    if (languagetype == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"语种类型不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }
                if (json.ContainsKey("accounttype") && !string.IsNullOrEmpty(json["accounttype"].ToString()))
                {
                    accounttype = bll_category.GetCategoryIdByName(json["accounttype"].ToString(), DTEnums.CategoryEnum.period.ToString());
                    if (accounttype == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"账单周期不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }
                if (json.ContainsKey("linecity") && !string.IsNullOrEmpty(json["linecity"].ToString()))
                {
                    linecity = bll_category.GetCategoryIdByName(json["linecity"].ToString(), DTEnums.CategoryEnum.world.ToString());
                    if (linecity == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"国际线路不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }
                if (json.ContainsKey("property") && !string.IsNullOrEmpty(json["property"].ToString()))
                {
                    property = bll_category.GetCategoryIdByName(json["property"].ToString(), DTEnums.CategoryEnum.groupteam.ToString());
                    if (property == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"团属类型不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }
                if (json.ContainsKey("restauranttype") && !string.IsNullOrEmpty(json["restauranttype"].ToString()))
                {
                    restauranttype = bll_category.GetCategoryIdByName(json["restauranttype"].ToString(), DTEnums.CategoryEnum.pay.ToString());
                    if (restauranttype == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"餐厅支付类型不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }
                if (json.ContainsKey("tickettype") && !string.IsNullOrEmpty(json["tickettype"].ToString()))
                {
                    tickettype = bll_category.GetCategoryIdByName(json["tickettype"].ToString(), DTEnums.CategoryEnum.pay.ToString());
                    if (tickettype == 0)
                    {
                        json_result = "{\"status\":\"false\",\"data\":\"门票支付类型不存在,请重新选择!\"}";
                        Context.Response.Write(json_result);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        return;
                    }
                }
                #endregion

                model.fromplace_id = fromplaceid;
                model.toplace_id = toplaceid;

                model.account_type = accounttype;
                model.language_type = languagetype;
                model.linecity_id = linecity;
                model.group_property = property;
                model.restaurant_type = restauranttype;
                model.ticket_type = tickettype;

                model.sex = int.Parse(json["sex"].ToString());
                model.is_stay = string.IsNullOrEmpty(json["isstay"].ToString()) ? 0 : int.Parse(json["isstay"].ToString());
                model.is_red = 0;
                model.is_slide = 0;
                model.is_top = 0;

                model.people_count = int.Parse(json["peoplecount"].ToString());
                model.total_count = int.Parse(json["totalcount"].ToString());
                model.service_price = decimal.Parse(json["serviceprice"].ToString());
                model.status = 1; //0申请 1正常 2过期
                model.sort_id = 99;
                model.start_date = json["startdate"].ToString();
                model.end_date = json["enddate"].ToString();
                model.add_time = DateTime.Now;
                model.remark1 = "";
                model.remark2 = 0;

                model.albums = null;
                if (bll.Add(model) < 1)
                {
                    json_result = "{\"status\":\"false\",\"data\":\"发布失败!\"}";
                }
                else
                {
                    json_result = "{\"status\":\"true\",\"data\":\"发布成功!\"}";

                }

            }
            catch (Exception ex)
            {
                json_result = "{\"status\":\"false\",\"data\":\"" + ex.Message + "\"}";
            }
            WriteWebServiceLog(version, equType, equName, "PublishGroup", "");
            Context.Response.Write(json_result);
            Context.Response.End();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取实体
        /// </summary>
        public Model.tourgroup GetTourGroupModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  TOP 1 [id],[channel_id],[manager_id],[category_id],[title],[group_property],[sex],[people_count],[start_date],[end_date],[total_count]");
            strSql.Append("  ,(case when f.book_count is null  then '0' else  f.book_count end)  as book_count , ");
            strSql.Append("  [is_stay],[book_require],[language_type],[ticket_type],[restaurant_type],[account_type],[linecity_id],[fromplace_id],[toplace_id],[service_price],[status],[content],[add_time],[description],[is_top],[is_slide],[is_red],[remark1],[remark2],[sort_id] ");
            strSql.Append("   FROM  [dbo].[dt_group] a ");
            strSql.Append("   left join (select COUNT(*) as book_count,group_id  from dbo.dt_group_guid  t group by t.group_id) f on a.id=f.group_id ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) };
            parameters[0].Value = id;

            Model.tourgroup model = new Model.tourgroup();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region  DATA
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["manager_id"] != null && ds.Tables[0].Rows[0]["manager_id"].ToString() != "")
                {
                    model.manager_id = int.Parse(ds.Tables[0].Rows[0]["manager_id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["category_id"] != null && ds.Tables[0].Rows[0]["category_id"].ToString() != "")
                {
                    model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }

                if (ds.Tables[0].Rows[0]["group_property"] != null && ds.Tables[0].Rows[0]["group_property"].ToString() != "")
                {
                    model.group_property = int.Parse(ds.Tables[0].Rows[0]["group_property"].ToString());
                }

                if (ds.Tables[0].Rows[0]["sex"] != null && ds.Tables[0].Rows[0]["sex"].ToString() != "")
                {
                    model.sex = int.Parse(ds.Tables[0].Rows[0]["sex"].ToString());
                }

                if (ds.Tables[0].Rows[0]["people_count"] != null && ds.Tables[0].Rows[0]["people_count"].ToString() != "")
                {
                    model.people_count = int.Parse(ds.Tables[0].Rows[0]["people_count"].ToString());
                }

                if (ds.Tables[0].Rows[0]["start_date"] != null && ds.Tables[0].Rows[0]["start_date"].ToString() != "")
                {
                    model.start_date = ds.Tables[0].Rows[0]["start_date"].ToString();
                }

                if (ds.Tables[0].Rows[0]["end_date"] != null && ds.Tables[0].Rows[0]["end_date"].ToString() != "")
                {
                    model.end_date = ds.Tables[0].Rows[0]["end_date"].ToString();
                }

                if (ds.Tables[0].Rows[0]["total_count"] != null && ds.Tables[0].Rows[0]["total_count"].ToString() != "")
                {
                    model.total_count = int.Parse(ds.Tables[0].Rows[0]["total_count"].ToString());
                }

                if (ds.Tables[0].Rows[0]["book_count"] != null && ds.Tables[0].Rows[0]["book_count"].ToString() != "")
                {
                    model.book_count = int.Parse(ds.Tables[0].Rows[0]["book_count"].ToString());
                }

                if (ds.Tables[0].Rows[0]["is_stay"] != null && ds.Tables[0].Rows[0]["is_stay"].ToString() != "")
                {
                    model.is_stay = int.Parse(ds.Tables[0].Rows[0]["is_stay"].ToString());
                }

                if (ds.Tables[0].Rows[0]["book_require"] != null && ds.Tables[0].Rows[0]["book_require"].ToString() != "")
                {
                    model.book_require = ds.Tables[0].Rows[0]["book_require"].ToString();
                }

                if (ds.Tables[0].Rows[0]["language_type"] != null && ds.Tables[0].Rows[0]["language_type"].ToString() != "")
                {
                    model.language_type = int.Parse(ds.Tables[0].Rows[0]["language_type"].ToString());
                }

                if (ds.Tables[0].Rows[0]["ticket_type"] != null && ds.Tables[0].Rows[0]["ticket_type"].ToString() != "")
                {
                    model.ticket_type = int.Parse(ds.Tables[0].Rows[0]["ticket_type"].ToString());
                }

                if (ds.Tables[0].Rows[0]["restaurant_type"] != null && ds.Tables[0].Rows[0]["restaurant_type"].ToString() != "")
                {
                    model.restaurant_type = int.Parse(ds.Tables[0].Rows[0]["restaurant_type"].ToString());
                }

                if (ds.Tables[0].Rows[0]["account_type"] != null && ds.Tables[0].Rows[0]["account_type"].ToString() != "")
                {
                    model.account_type = int.Parse(ds.Tables[0].Rows[0]["account_type"].ToString());
                }

                if (ds.Tables[0].Rows[0]["linecity_id"] != null && ds.Tables[0].Rows[0]["linecity_id"].ToString() != "")
                {
                    model.linecity_id = int.Parse(ds.Tables[0].Rows[0]["linecity_id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["fromplace_id"] != null && ds.Tables[0].Rows[0]["fromplace_id"].ToString() != "")
                {
                    model.fromplace_id = int.Parse(ds.Tables[0].Rows[0]["fromplace_id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["toplace_id"] != null && ds.Tables[0].Rows[0]["toplace_id"].ToString() != "")
                {
                    model.toplace_id = int.Parse(ds.Tables[0].Rows[0]["toplace_id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["service_price"] != null && ds.Tables[0].Rows[0]["service_price"].ToString() != "")
                {
                    model.service_price = decimal.Parse(ds.Tables[0].Rows[0]["service_price"].ToString());
                }

                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }

                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }

                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }

                if (ds.Tables[0].Rows[0]["description"] != null && ds.Tables[0].Rows[0]["description"].ToString() != "")
                {
                    model.description = ds.Tables[0].Rows[0]["description"].ToString();
                }

                if (ds.Tables[0].Rows[0]["is_top"] != null && ds.Tables[0].Rows[0]["is_top"].ToString() != "")
                {
                    model.is_top = int.Parse(ds.Tables[0].Rows[0]["is_top"].ToString());
                }

                if (ds.Tables[0].Rows[0]["is_slide"] != null && ds.Tables[0].Rows[0]["is_slide"].ToString() != "")
                {
                    model.is_slide = int.Parse(ds.Tables[0].Rows[0]["is_slide"].ToString());
                }

                if (ds.Tables[0].Rows[0]["is_red"] != null && ds.Tables[0].Rows[0]["is_red"].ToString() != "")
                {
                    model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString());
                }

                if (ds.Tables[0].Rows[0]["remark1"] != null && ds.Tables[0].Rows[0]["remark1"].ToString() != "")
                {
                    model.remark1 = ds.Tables[0].Rows[0]["remark1"].ToString();
                }

                if (ds.Tables[0].Rows[0]["remark2"] != null && ds.Tables[0].Rows[0]["remark2"].ToString() != "")
                {
                    model.remark2 = int.Parse(ds.Tables[0].Rows[0]["remark2"].ToString());
                }

                #endregion
                model.albums = new article_albums().GetList(id);
                return model;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 3
0
        private bool DoAdd()
        {
            bool result = true;
            Model.tourgroup model = new Model.tourgroup();
            BLL.tourgroup bll = new BLL.tourgroup();
            Model.manager managerModel = GetAdminInfo();
            if (managerModel != null)
            {
                model.manager_id = managerModel.id;
            }
            else
            {
                Response.Redirect("../login.aspx");
            }
            model.channel_id = this.channel_id;
            model.title = txtTitle.Text.Trim();
            model.category_id =  int.Parse(ddlGroupType.SelectedValue);
            model.content ="";
            model.book_require = txtContent.Text.Trim();

            model.account_type = string.IsNullOrEmpty(ddlAccount.SelectedValue) ? 0 : int.Parse(ddlAccount.SelectedValue);
            model.fromplace_id = string.IsNullOrEmpty(ddlFromCity.SelectedValue) ? 0 : int.Parse(ddlFromCity.SelectedValue);
            model.language_type = string.IsNullOrEmpty(ddlLanguage.SelectedValue) ? 0 : int.Parse(ddlLanguage.SelectedValue);
            model.linecity_id = string.IsNullOrEmpty(ddlLineCity.SelectedValue) ? 0 : int.Parse(ddlLineCity.SelectedValue);
            model.group_property = string.IsNullOrEmpty(ddlProperty.SelectedValue) ? 0 : int.Parse(ddlProperty.SelectedValue);
            model.restaurant_type = string.IsNullOrEmpty(ddlRestaurant.SelectedValue) ? 0 : int.Parse(ddlRestaurant.SelectedValue);
            model.ticket_type = string.IsNullOrEmpty(ddlTicketType.SelectedValue) ? 0 : int.Parse(ddlTicketType.SelectedValue);
            model.toplace_id = string.IsNullOrEmpty(ddlToCity.SelectedValue) ? 0 : int.Parse(ddlToCity.SelectedValue);
            model.sex = int.Parse(rdoSex.SelectedValue);
            model.is_stay = string.IsNullOrEmpty(rdoStayType.SelectedValue) ? 0 : int.Parse(rdoStayType.SelectedValue);
            model.is_red = 0;
            model.is_slide = 0;
            model.is_top = 0;
            if (cblItem.Items[0].Selected == true)
            {
                model.is_top = 1;
            }
            if (  cblItem.Items[1].Selected == true)
            {
                model.is_red = 1;
            }
            model.people_count = int.Parse(txtPeople.Text.Trim());
            model.total_count = int.Parse(txtTotal.Text.Trim());
            model.service_price = decimal.Parse(txtServicePrice.Text.Trim());
            model.status = 1; //0申请 1正常 2过期
            model.sort_id = int.Parse(txtSortId.Text.Trim());
            model.start_date = txtStartDate.Text.Trim();
            model.end_date = txtEndDate.Text.Trim();
            model.add_time = DateTime.Now;
            model.remark1 = "";
            model.remark2 = 0;

            model.albums = null;
            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return result;
        }