发布房源页CS文件

来源:互联网 发布:北京软件开发公司排名 编辑:程序博客网 时间:2024/04/26 17:13

/// <summary>
/// 企业客户二手房数据录入,修改
/// <para>
/// 文件名: webclient_entsecondhouseinput
/// </para>
/// <para>
/// 作者:张枫
/// </para>
/// <para>
/// 日期:2010/8/1
/// </para>
/// <para>
/// 版本:1.00  (版本号规则:测试通过的原始版本号为1.00;
/// </para>
/// </summary>
/// <remarks>
/// Copyright (C) 2010 时期网络研发中心
///</remarks>

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.IO;
using Times;
using System.Data.SqlClient;

 

public partial class webclient_entsecondhouseinput : System.Web.UI.Page
{
    MemberCenter mc=new MemberCenter();
    private string id = "";
    ConfirmList confirmlist = new ConfirmList();
    TextHandle txthandle = new TextHandle();
    TCommonQuery hcommonquery = new TCommonQuery();
    private int picsum = 0;//上传图数量设定
    int[] pageparameter = new int[2];
    ViewLayerDataHandle vldh = new ViewLayerDataHandle();
    SecondHouse sh=new SecondHouse();
    SecondHouseOtherInfo sho = new SecondHouseOtherInfo();
    SecondHouseEquipment she = new SecondHouseEquipment();
   
    protected void Page_Load(object sender, EventArgs e)
    {
        pageparameter = GetPageParameter();
        User user1=this.GetUser();
        if (!IsPostBack)
        {
            user1 = this.GetUser();//张枫写的
           
        }
        if (user1 == null)
        {
            Response.Redirect("../index.aspx");
        }
        if (user1.ServiceState == null)
        {
            Response.Redirect("../index.aspx");
        }
        if(user1.UserType == UserType.NotLogin)
        {
            Response.Write("<script>alert('你的登陆时间可能过长,请重新登陆!');parent.location.href ='/UserLogin.aspx'</script>");
        }
        int a = user1.EntID;
       if (!string.IsNullOrEmpty(Request.QueryString["id"]))
        {
            id = Request.QueryString["id"].ConvertToDecryptString();
            if (pageparameter[0] > 3)  //修改房产信息
            {
                if (!IsPostBack)
                {  
                    this.txtLinkMan.Text = user1.RealName;//企业为公司名
                    this.txtPublisher.Text = user1.RealName;
                    txtEntId.Text = user1.EntID.ToString();
                    txtinfstat.Value = pageparameter[0].ToString();
                    BindList();
                    mod();
                }
            }
        }
        else
        {
            if (pageparameter[0] < 4)   //新增房产信息
            {
                if (!IsPostBack)
                {
                    DDLSectionID.LoadSection(22);
                    DDLBlockHousing.LoadHousingBlockBySectionID(Convert.ToInt32(DDLSectionID.SelectedValue));
                    this.txtLinkMan.Text = user1.RealName;//用户姓名
                    this.txtPublisher.Text = user1.RealName;
                    txtEntId.Text = user1.EntID.ToString();
                    txtinfstat.Value = pageparameter[0].ToString();
                    if (pageparameter[0] == 1)
                    {
                        rblinfotype.SelectedIndex = 1;
                    }
                    BindList();
                    //DataRow dr;//取企业登录类型
                    //if (user1.UserType == UserType.TopStaff)
                    //{
                    //    dr = InformationProvider.GetContact(user1.EntID, UserType.Enterprise);
                    //}
                    //else
                    //{
                    //    dr = InformationProvider.GetContact(user1.EntID, UserType.Staff);
                    //}
                    DataRow dr = InformationProvider.GetContact(user1.UserID, user1.UserType);
                    if(dr!=null)
                    {
                        if (dr[4]!=null)
                        {
                            SetCellPhoneNo(dr[4].ToString());
                        }
                        if (dr[3]!=null)
                        {
                             SetTelePhoneNo(dr[3].ToString());
                        }
                        if(dr[6]!=null)
                        {
                            txtInstantMessaging.Text = dr[6].ToString();
                        }
                    }
                   
                  
                }
            }
        }
    }

    #region 绑定列表
    private void BindList()
    {
        //*****************出售,出租产权***************
        ddlOwer.Items.Add("全产权");
        ddlOwer.Items.Add("使用权");
        ddlOwer.Items.Add("其他");
        //*****************求购产权***************
        ddlOwer3.Items.Add("全产权");
        ddlOwer3.Items.Add("使用权");
        ddlOwer3.Items.Add("其他");
        //***************新增房屋方向****************** 徐 20091011
        //ddlHouseDirection12.Items.Add("其它");
        //ddlHouseDirection12.Items.Add("东");
        //ddlHouseDirection12.Items.Add("南");
        //ddlHouseDirection12.Items.Add("西");
        //ddlHouseDirection12.Items.Add("北");
        //ddlHouseDirection12.Items.Add("东南");
        //ddlHouseDirection12.Items.Add("西南");
        //ddlHouseDirection12.Items.Add("东北");
        //ddlHouseDirection12.Items.Add("西北");
        //ddlHouseDirection12.Items.Add("南北");
        //ddlHouseDirection12.Items.Add("东西");
        //ddlHouseDirection12.Items.Add("双阳");
        //ddlHouseDirection12.Items.Add("双东");
        //ddlHouseDirection12.Items.Add("三东");
        //ddlHouseDirection12.Items.Add("双西");
        //ddlHouseDirection12.Items.Add("三西");
        //ddlHouseDirection12.Items.Add("双北");
        //ddlHouseDirection12.Items.Add("三北");
        //ddlHouseDirection12.Items.Add("三阳");
        //ddlHouseDirection12.Items.Add("南北西");
        //ddlHouseDirection12.Items.Add("南西北");
        //ddlHouseDirection12.Items.Add("东西北");
        //ddlHouseDirection12.Items.Add("南北东");
        ddlHouseDirection12.Items.Add("南北");
        ddlHouseDirection12.Items.Add("东南");
        ddlHouseDirection12.Items.Add("西南");
        ddlHouseDirection12.Items.Add("双阳");
        ddlHouseDirection12.Items.Add("三阳");
        ddlHouseDirection12.Items.Add("东");
        ddlHouseDirection12.Items.Add("南");
        ddlHouseDirection12.Items.Add("西");
        ddlHouseDirection12.Items.Add("北");
        ddlHouseDirection12.Items.Add("其他");

        //*****************新增求租求购房屋方向********************
        //ddlHouseDirection34.Items.Add("其它");
        //ddlHouseDirection34.Items.Add("东");
        //ddlHouseDirection34.Items.Add("南");
        //ddlHouseDirection34.Items.Add("西");
        //ddlHouseDirection34.Items.Add("北");
        //ddlHouseDirection34.Items.Add("东南");
        //ddlHouseDirection34.Items.Add("西南");
        //ddlHouseDirection34.Items.Add("东北");
        //ddlHouseDirection34.Items.Add("西北");
        //ddlHouseDirection34.Items.Add("南北");
        //ddlHouseDirection34.Items.Add("东西");
        //ddlHouseDirection34.Items.Add("双阳");
        //ddlHouseDirection34.Items.Add("双东");
        //ddlHouseDirection34.Items.Add("三东");
        //ddlHouseDirection34.Items.Add("双西");
        //ddlHouseDirection34.Items.Add("三西");
        //ddlHouseDirection34.Items.Add("双北");
        //ddlHouseDirection34.Items.Add("三北");
        //ddlHouseDirection34.Items.Add("三阳");
        //ddlHouseDirection34.Items.Add("南北西");
        //ddlHouseDirection34.Items.Add("南西北");
        //ddlHouseDirection34.Items.Add("东西北");
        //ddlHouseDirection34.Items.Add("南北东");
        ddlHouseDirection34.Items.Add("南北");
        ddlHouseDirection34.Items.Add("东南");
        ddlHouseDirection34.Items.Add("西南");
        ddlHouseDirection34.Items.Add("双阳");
        ddlHouseDirection34.Items.Add("三阳");
        ddlHouseDirection34.Items.Add("东");
        ddlHouseDirection34.Items.Add("南");
        ddlHouseDirection34.Items.Add("西");
        ddlHouseDirection34.Items.Add("北");
        ddlHouseDirection34.Items.Add("其他");
        //******************付款方式出售*****************************
        ddlPay1.Items.Add("一次性");
        ddlPay1.Items.Add("可按揭");
        ddlPay1.Items.Add("可分期");
        ddlPay1.Items.Add("可协商");
        //******************付款方式出租*****************************
        ddlPay2.Items.Add("面议");
        ddlPay2.Items.Add("押一付三");
        ddlPay2.Items.Add("押一付六");
        ddlPay2.Items.Add("押一付全年");
        //******************付款方式求租求购*****************************
        ddlPay3.Items.Add("一次性");
        ddlPay3.Items.Add("可按揭");
        ddlPay3.Items.Add("可分期");
        ddlPay3.Items.Add("可协商");
        ddlPay4.Items.Add("面议");
        ddlPay4.Items.Add("押一付三");
        ddlPay4.Items.Add("押一付六");
        ddlPay4.Items.Add("押一付全年");

    }
    #endregion

    #region 发布房源加载
    public void issues()
    {
        User user1 = this.GetUser();
        sh.AgentHouseNo = txtAgentHouseNo.Text;
        if (rblinfotype.SelectedValue == "出售" || rblinfotype.SelectedValue == "出租")
        {
           sh.Area = txtArea12.Text.ConvertToSafeString();
            if(tb.Text!="")
            {
                txtDetialAddress12.Text = tb.Text;
            }
           sh.DetialAddress = txtDetialAddress12.Text;
           sh.HouseDirection = ddlHouseDirection12.Text;
           sh.Ower = ddlOwer.SelectedValue;
           if (!string.IsNullOrEmpty(txtAcreage.Text))
           {
               sh.Acreage = Convert.ToDouble(txtAcreage.Text);
           }
           else
           {
               txtAcreage.Text = "0";
           }
            sh.AuxiliaryEquipment = confirmlist.getCheckBoxList(cblAuxiliaryEquipment12);
            sh.Config = confirmlist.getCheckBoxList(cblConfig12);
            sh.InFloor = txtInFloor.Text;
            sh.Remark = txtRemark12.Text.ConvertToSafeString();
            sh.Solo = ddlSolo112.SelectedValue + ddlSolo212.SelectedValue + ddlSolo312.SelectedValue + ddlSolo412.SelectedValue + ddlSolo512.SelectedValue;

        }
        if (rblinfotype.SelectedValue == "求购" || rblinfotype.SelectedValue == "求租")
        {
            sh.Area = txtArea34.Text.ConvertToSafeString();
            if (tb.Text != "")
            {
                txtDetialAddress34.Text = tb.Text;
            }
            sh.DetialAddress = txtDetialAddress34.Text;
            sh.HouseDirection = ddlHouseDirection34.Text;
            sh.Ower = ddlOwer3.SelectedValue;
            sh.Acreage = Convert.ToDouble(rblAcreage.SelectedValue);
            sh.InFloor = txtInFloor34.Text;
            sh.Config = confirmlist.getCheckBoxList(cblConfig34);
            sh.Remark = txtRemark34.Text.ConvertToSafeString();
            sh.AuxiliaryEquipment = confirmlist.getCheckBoxList(cblAuxiliaryEquipment34);
            sh.Ower = ddlOwer3.SelectedValue;
            sh.Solo = ddlSolo134.SelectedValue + ddlSolo234.SelectedValue + ddlSolo334.SelectedValue + ddlSolo434.SelectedValue + ddlSolo534.SelectedValue;
        }
        sh.BuildDate = txtBuildDate.Text;
        if (rblinfotype.SelectedValue == "出售")
        {
            if (rblPriceType.SelectedValue == "0")
            {  
                if (!string.IsNullOrEmpty(txtBuyPriceTotal1.Text))
                {
                    sh.BuyPrice = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(txtBuyPriceTotal1.Text) * 10000));
                }
            }
            else
            {
                sh.BuyPrice = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(txtBuyPriceUnit1.Text) * sh.Acreage.Value));
            }
            sh.Pay = ddlPay1.SelectedValue;
        }
        if (rblinfotype.SelectedValue == "出租")
        {
            if(!string.IsNullOrEmpty(txtBuyPriceRent2.Text))
            {
                 sh.BuyPrice = Convert.ToInt32(txtBuyPriceRent2.Text);
            }
            sh.Pay = ddlPay2.SelectedValue;
        }
        if (rblinfotype.SelectedValue == "求租")
        {
            sh.BuyPrice = Convert.ToInt32(rblBuyPrice4.SelectedValue);
            sh.Pay = ddlPay4.SelectedValue;
        }
        if (rblinfotype.SelectedValue == "求购")
        {
            sh.BuyPrice = Convert.ToInt32(rblBuyPrice3.SelectedValue);
            sh.Pay = ddlPay3.SelectedValue;
        }
        sh.CreateTime = DateTime.Now;
        sh.LinkMan = txtLinkMan.Text;
        if (!string.IsNullOrEmpty(txtOtherAcreage.Text))
        {
            sh.OtherAcreage = Convert.ToDouble(txtOtherAcreage.Text);
        }
       
        sh.Perimeter = "000000000";
        sh.EntId = user1.EntID;
        sh.Phone = getTelePhone();
        string pic = "";
        ListItemCollection itemCol;
        itemCol = listimg.Items;
        foreach (ListItem item in itemCol)
        {
            pic += item.Text + ";";
        }
        if (pic.Length > 0)
            pic = pic.Substring(0, pic.Length - 1);
        sh.Pic = pic;
        sh.Publisher = txtPublisher.Text;
        sh.Auditer = "";
        sh.SectionID = Convert.ToInt32(DDLSectionID.SelectedValue);
        sh.Seq = txtSeq.Text;
       
        switch (user1.UserType)
        {
            case UserType.IndependentBroker:
                sh.IndID=user1.UserID;
                sh.StaID = 0;
                sh.EntId = 0;
                sh.PerID = 0;
                break;
            case UserType.Personal:
                sh.PerID = user1.UserID;
                sh.StaID = 0;
                sh.EntId = 0;
                sh.IndID = 0;
                break;
            case UserType.Staff:
                sh.StaID = user1.UserID;
                sh.PerID = 0;
                sh.IndID = 0;
                sh.EntId = user1.EntID;
                break;
            case UserType.TopStaff:
                sh.StaID = user1.UserID;
                sh.PerID = 0;
                sh.IndID = 0;
                sh.EntId = user1.EntID;
                break;
        }
        sh.Status = 0;//txtStatus.Text = sh.Status.ToString();
        sh.Style = rblStyle.SelectedValue;
        sh.SumFloor = txtSumFloor.Text;
        sh.Type = rbltype.SelectedValue;
        sh.Validity = getValidity();
        sh.CityId = 22;
        sh.InfoType = rblinfotype.SelectedItem.Text;
       
        sh.IsTop = '0';
        if (user1.ServiceState.HousingIssue == true)
        {
            sh.IsAudit = '1';
        }
        else
        {
            sh.IsAudit = '0';
        }
        sh.Publisher = user1.RealName;
       

        if (txtSeq.Text.Length == 0)
        {
            SequenceHandle sequencehandle = new SequenceHandle();
            if (rblinfotype.SelectedValue == "出售")
            {
               txtSeq.Text = sequencehandle.GetHouseInfoSeqNumber(HouseInfoType.Sell);
            }
            if (rblinfotype.SelectedValue == "出租")
            {
                txtSeq.Text = sequencehandle.GetHouseInfoSeqNumber(HouseInfoType.Rent);
            }
            if (rblinfotype.SelectedValue == "求购")
            {
                txtSeq.Text = sequencehandle.GetHouseInfoSeqNumber(HouseInfoType.AsksToBuy);
            }
            if (rblinfotype.SelectedValue == "求租")
            {
                txtSeq.Text = sequencehandle.GetHouseInfoSeqNumber(HouseInfoType.AsksToRent);
            }
            sh.Seq = txtSeq.Text;
        }
        else
        {
            sh.Seq = txtSeq.Text;
        }

        int cal = vldh.CalculateSecondhouseIntegrity(sh);
        if (cal > -1)
        {
            sh.Integrity = cal;
        }
        else
        {
            cal = 1;
        }
        SecondHouseOtherInfo sho = sh.SecondHouseOtherInfo.FirstOrDefault();
        if (sho == null)
        {
            sho = new SecondHouseOtherInfo();
            shoadd(sho);
        }
        else
        {
            shoadd(sho);
        }
        SecondHouseEquipment she = sh.SecondHouseEquipment.FirstOrDefault();
        if (she == null)
        {
            she = new SecondHouseEquipment();
            sheadd(she);
        }
        else
        {
            sheadd(she);
        }
    }
    #endregion

    #region 修改房源加载
    private void mod()
    {
       int sid = Convert.ToInt32(id);
       sh = mc.GetSecondHandHouseToModify(sid);
       DDLSectionID.LoadSection(22);
      
       if (!sh.Acreage.HasValue == false)
       {
           txtAcreage.Text = Convert.ToString(sh.Acreage);
       }
       else
       {
           txtAcreage.Text = "0";
       }
       txtAgentHouseNo.Text = sh.AgentHouseNo;
       if (sh.InfoType == "出售" || sh.InfoType == "出租")
       {
            txtArea12.Text = sh.Area;
            txtDetialAddress12.Text = sh.DetialAddress;
            ddlHouseDirection12.Text = sh.HouseDirection;
            ddlOwer.SelectedValue = sh.Ower;
            confirmlist.setCheckBoxList(sh.Config, cblConfig12);
            confirmlist.setCheckBoxList(sh.AuxiliaryEquipment,cblAuxiliaryEquipment12);
            if (sh.Acreage!=null)
            {
                txtAcreage.Text = sh.Acreage.ToString();
            }
            else
            {
                txtAcreage.Text = "0";
            }
       ddlSolo112.SelectedValue = sh.Solo.Substring(0, 1);
       ddlSolo212.SelectedValue = sh.Solo.Substring(1, 1);
       ddlSolo312.SelectedValue = sh.Solo.Substring(2, 1);
       ddlSolo412.SelectedValue = sh.Solo.Substring(3, 1);
       ddlSolo512.SelectedValue = sh.Solo.Substring(4, 1);
       txtRemark12.Text = sh.Remark;
       }
       if (sh.InfoType == "求购" || sh.InfoType == "求租")
       {
           txtArea34.Text = sh.Area;
           txtDetialAddress34.Text = sh.DetialAddress;
           ddlHouseDirection34.Text = sh.HouseDirection;
           ddlOwer3.SelectedValue = sh.Ower;
           confirmlist.setCheckBoxList(sh.Config, cblConfig34);
           confirmlist.setCheckBoxList(sh.AuxiliaryEquipment,cblAuxiliaryEquipment34);
           rblAcreage.SelectedValue=  sh.Acreage.ToString();
           txtInFloor34.Text= sh.InFloor;
           ddlSolo134.SelectedValue = sh.Solo.Substring(0, 1);
           ddlSolo234.SelectedValue = sh.Solo.Substring(1, 1);
           ddlSolo334.SelectedValue = sh.Solo.Substring(2, 1);
           ddlSolo434.SelectedValue = sh.Solo.Substring(3, 1);
           ddlSolo534.SelectedValue = sh.Solo.Substring(4, 1);
           txtRemark34.Text = sh.Remark;
       }
       txtBuildDate.Text = sh.BuildDate;
       rblPriceType.SelectedIndex = 0;
       if (sh.InfoType == "出售" )
        {    
            txtBuyPriceTotal1.Text = Convert.ToString(sh.BuyPrice / 10000);
        }
       if (sh.InfoType == "出租" )
        {
            txtBuyPriceRent2.Text = sh.BuyPrice.ToString();
        }
       sh.CreateTime = DateTime.Now;
       txtInFloor.Text = sh.InFloor;
       txtLinkMan.Text = sh.LinkMan;
       txtOtherAcreage.Text = sh.OtherAcreage.ToString();
       SetTelePhoneNo(sh.Phone);
       string[] picArray;
       if (!string.IsNullOrEmpty(sh.Pic))
       {
           picArray = sh.Pic.Split(';');
           if (!string.IsNullOrEmpty(sh.Pic))
            {
                if (picArray.Length != 0)
                    {
                        picsum = picArray.Length;
                    }
          
                 Image1.ImageUrl = "~/houseimages/" + picArray[0];
            }
            ViewState.Add("picsumtemp", picsum);
            foreach (string str in picArray)
            {
                    if (str != "")
                    listimg.Items.Add(str);
            }
       }
       else
       {
           picsum = 0;
       }
       this.HidImg.Value = Server.MapPath("houseimages/");
       txtPublisher.Text = sh.Publisher;
       txtRemark12.Text = sh.Remark;
       SecondHouseOtherInfo sho = sh.SecondHouseOtherInfo.FirstOrDefault();
       if (sh.InfoType == "出售")
       {
           if (sho.PriceType == 0)
           {
               if (sh.BuyPrice != null)
               {
                   txtBuyPriceTotal1.Text = Convert.ToString(sh.BuyPrice / 10000);

               }
           }
           else
           {
               txtBuyPriceUnit1.Text = Convert.ToString(sh.BuyPrice / sh.Acreage.Value);
           }
           ddlPay1.SelectedValue = sh.Pay;
       }
       if (sh.InfoType == "出租")
       {
           if (sho.PriceType == 0)
           {
               if (sh.BuyPrice != null)
               {
                   txtBuyPriceTotal1.Text = Convert.ToString(sh.BuyPrice / 10000);

               }
           }
           else
           {
               txtBuyPriceUnit1.Text = Convert.ToString(sh.BuyPrice / sh.Acreage.Value);
           }
           ddlPay2.SelectedValue = sh.Pay;
       }
       if (sh.InfoType == "求租")
       {
           rblBuyPrice4.SelectedValue = sh.BuyPrice.ToString();
           ddlPay4.SelectedValue = sh.Pay;
       }
       if (sh.InfoType == "求购")
       {
           rblBuyPrice3.SelectedValue = sh.BuyPrice.ToString();
           ddlPay3.SelectedValue = sh.Pay;
       }
        if(sho!=null)
        {
            if (!string.IsNullOrEmpty(sho.BuildingType))
            {
                rblBuildingtype.SelectedValue = sho.BuildingType;
            }
            if (!string.IsNullOrEmpty(sho.CellPhone))
            {
                SetCellPhoneNo(sho.CellPhone);
            }
            if (sho.HouId != 0)
            {
                txtHouID12.Text = sho.HouId.ToString();
            }
            if (!string.IsNullOrEmpty(sho.InstantMessaging))
            {
                txtInstantMessaging.Text = sho.InstantMessaging;
            }
            if (sho.ManageFree != -1)
            {
                txtManageFree.Text = sho.ManageFree.ToString();
            }
            if (sho.Negotiable == true)//1为可面议
            {
                cbNegotiable1.Checked = true;
            }
            else
            {
                cbNegotiable1.Checked = false;
            }
            if (sho.PriceType == 0)//0为总价
            {
                rblPriceType.SelectedValue = "0";
            }
            else
            {
                rblPriceType.SelectedValue = "1";
            }
            if (!string.IsNullOrEmpty(sho.Title))
            {
                txtTitle.Text = sho.Title;
            }
        }
        DDLSectionID.SelectedValue = sh.SectionID.ToString();
        DDLBlockHousing.LoadHousingBlockBySectionID(Convert.ToInt32(DDLSectionID.SelectedValue));
       SecondHouseEquipment she = sh.SecondHouseEquipment.FirstOrDefault();
       if (she != null)
       {
           if (she.Hotarea != null)
           {
               DDLBlockHousing.SelectedValue = she.Hotarea.ToString();//咨询川哥,为片区
           }
       }
     
       txtSeq.Text = sh.Seq;
      
       txtStatus.Text = sh.Status.ToString();
       rblStyle.SelectedValue = sh.Style;
       txtSumFloor.Text = sh.SumFloor;
       rbltype.SelectedValue = sh.Type;
        if(sh.InfoType=="出售")
        {
            rblinfotype.SelectedIndex = 0;
        }
        else if(sh.InfoType=="出租")
        {
            rblinfotype.SelectedIndex = 1;
        }
        else if(sh.InfoType=="求购")
        {
            rblinfotype.SelectedIndex = 2;
        }
        else
        {
            rblinfotype.SelectedIndex = 3;
        }
       txtSeq.Text = sh.Seq;
    }
    #endregion

    #region 修改房源加载2
    private void mod2()
    {
        int sid = Convert.ToInt32(id);
        sh = mc.GetSecondHandHouseToModify(sid);
        issues();
    }
    #endregion

    #region sho加载
    private void shoadd(SecondHouseOtherInfo sho)
    {

        sho.BuildingType = rblBuildingtype.SelectedValue;
        sho.CellPhone = getCellPhone();
        if (txtHouID12.Text.Length == 0)
        {
            sho.HouId = null;
        }
        else
        {
            sho.HouId = Convert.ToInt32(txtHouID12.Text);
        }
        sho.InstantMessaging = txtInstantMessaging.Text.ConvertToSafeString();
        if (txtManageFree.Text.Length > 0)
        {
            sho.ManageFree = Convert.ToDouble(txtManageFree.Text);
        }
        else
        {
            sho.ManageFree = -1;
        }

        if (cbNegotiable1.Checked == true)//1为可面议
        {
            sho.Negotiable = true;
        }
        else
        {
            sho.Negotiable = false;
        }
        if (rblPriceType.SelectedValue == "0")//0为总价
        {
            sho.PriceType = 0;
        }
        else
        {
            sho.PriceType = 1;
        }
        sho.Title = txtTitle.Text.ConvertToSafeString();
       
    }
    #endregion

    #region she加载
    private void sheadd(SecondHouseEquipment she)
    {
        she.Hotarea = Convert.ToInt32(DDLBlockHousing.SelectedValue);//咨询川哥,为片区
       
    }
    #endregion

    #region 保存出售
    protected void bt1_Click(object sender, EventArgs e)
    {
        issa(sh, "00");
    }
    #endregion

    #region 上传图片
    protected void btfu_Click(object sender, EventArgs e)
    {
       
        User user1 = this.GetUser();
        picsum = Convert.ToInt32(ViewState["picsumtemp"]);
        if (picsum >= user1.ServiceState.PictureQuantityLimit)
        {
            string alterstring = "每条信息最多可传" + user1.ServiceState.PictureQuantityLimit + "张图!";
            Client.ResponseAlert(this, alterstring);
        }
        else if (this.fulPic.FileName.Equals(""))
        {
            Client.ResponseAlert(this, "请选择文件名!");
            return;
        }

        else
        {

            SavePic();
        }
        if (tb.Text!="")
        {
            txtDetialAddress12.Text =  tb.Text;
        }
       

    }
    #endregion 上传图片

    #region 图片处理
    private void SavePic()
    {

        ImageHandle ih = new ImageHandle();//实例化图片处理类
        ih.SetUploadImage(fulPic, 100, false, "/houseimages/");//设置上传参数
        UploadErrorType state;//定义状态变量
        string name1 = ih.UploadImage(out state, 4);//执行上传,获取服务器端文件名和上传状态
        if (state == UploadErrorType.Success)//如果状态为成功
        {
            string changeName = string.Empty;
            System.Drawing.Image ig1 = ih.ReadImage("/houseimages/" + name1);//载入刚刚传上来的文件
            System.Drawing.Image ig2 = ih.ReadImage("/images/watermark001.png");//载入水印图片

            ih.SetImgWaterMark(1, true);//设置水印参数 透明度0.3,水印居中或者 ih.SetImgWaterMark(0.3f, 0, 0);//设置水印参数 透明度0.3,水印在左上角
            System.Drawing.Image ig3 = ih.AddMark(ig1, ig2);//执行叠加水印,取得加印后的图像

            bool b = ih.WriteImage(ig3, "/houseimages/" + name1);//写入加印图像到指定位置
            ListItem item = new ListItem(name1, this.fulPic.PostedFile.FileName);
            this.listimg.Items.Add(item);
            //this.Image.ImageUrl = "..//houseimages//" + name1;
            this.Image1.ImageUrl = "~/houseimages/" + name1;

            picsum += 1;
            ViewState.Add("picsumtemp", picsum);


        }
        else if (state == UploadErrorType.FileSizeTooBig)
        {

            Client.ResponseAlert(this, "图片不能大于100K!");//图片超大
        }
        else if (state == UploadErrorType.PictureTypeWrong)
        {
            Client.ResponseAlert(this, "图片格式错误!");//图片格式错误

        }

    }
    #endregion

    #region 删除图片信息

    protected void btdlt_Click(object sender, EventArgs e)
    {
        bool imagechecked = false;
        for (int i = 0; i < this.listimg.Items.Count; ++i)
        {
            if (this.listimg.Items[i].Selected)
            {
                imagechecked = true;
                break;
            }

        }


        if (imagechecked == true)
        {

            for (int a = 0; a < this.listimg.Items.Count; ++a)
            {
                //删除选中图

                if (this.listimg.Items[a].Selected)
                {

                    try
                    {
                        string imagename = this.listimg.Items[a].Text;
                        string delimg = Server.MapPath("../houseimages/" + imagename);
                        File.Delete(delimg);

                        this.listimg.Items.Remove(this.listimg.Items[a]);

                        picsum = Convert.ToInt32(ViewState["picsumtemp"]) - 1;
                        ViewState.Add("picsumtemp", picsum);
                        if (listimg.Items.Count > 0)
                        {
                            Image1.ImageUrl = "../houseimages/" + listimg.Items[0].Text;
                        }
                        else
                        {
                            Image1.ImageUrl = "../images/defaulthouse.jpg";
                        }

                    }
                    catch (Exception ex)
                    {
                        Client.ResponseAlert(this, "删除失败!");
                    }
                }
            }

        }
        else
        {
            Client.ResponseAlert(this, "请选择图片进行删除!");
        }

        //将所有选中项强行设为false
        for (int b = 0; b < this.listimg.Items.Count; ++b)
        {
            this.listimg.Items[b].Selected = false;
        }
    }//删除图片信息
    #endregion

    #region 保存出租

    protected void bt2_Click(object sender, EventArgs e)
    {
        issa(sh, "10");
    }

    #endregion

    #region 保存求购

    protected void bt3_Click(object sender, EventArgs e)
    {
        issa(sh, "20");
    }

    #endregion

    #region 保存求租

    protected void bt4_Click(object sender, EventArgs e)
    {
        issa(sh, "30");
    }

    #endregion

    #region 取得页面参数
    private int[] GetPageParameter()
    {
        string pageaction = "0";
        int[] pageParameter = new int[2];
        int pageactioncode = 5;
        int idcode = 5;
        TextHandle th = new TextHandle();
        pageaction = th.DecryptString(Request.QueryString["infstat"], out pageactioncode);
        id = th.DecryptString(Request.QueryString["id"], out idcode);
        if (pageaction == null)
        {
            pageParameter[0] = 0;
            pageParameter[1] = 0;
        }
        else
        {
            if (pageaction.Length == 0)
            {
                pageParameter[0] = 0;
                pageParameter[1] = 0;
            }
            else
            {
                try
                {
                    pageParameter[0] = Convert.ToInt32(pageaction);
                    if (pageParameter[0] > 3)
                    {
                        pageParameter[1] = Convert.ToInt32(id);
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<script language=javascript>history.go(-2);</script>");
                }
                if (pageParameter[0] < 1 && pageParameter[0] > 7)
                {
                    pageParameter[0] = 0;
                    pageParameter[1] = 0;
                }
            }
        }
        return pageParameter;
    }
    #endregion

    #region 设定有效期,默认为3个月

    private string getValidity()
    {
        DateTime dt = DateTime.Now;
        string validity = "";
        if (rblValidity.SelectedValue == "0")
        {
            validity = dt.AddDays(7).ToString("yyyy-M-d H:mm:ss");
        }
        else if (rblValidity.SelectedValue == "1")
        {
            validity = dt.AddDays(15).ToString("yyyy-M-d H:mm:ss");
        }
        else if (rblValidity.SelectedValue == "2")
        {
            validity = dt.AddMonths(1).ToString("yyyy-M-d H:mm:ss");
        }
        else if (rblValidity.SelectedValue == "3")
        {
            validity = dt.AddMonths(2).ToString("yyyy-M-d H:mm:ss");
        }
        else if (rblValidity.SelectedValue == "4")
        {
            validity = dt.AddMonths(3).ToString("yyyy-M-d H:mm:ss");
        }
        return validity;
    }

    #endregion

    #region 取得移动电话号
    private string getCellPhone()
    {
        string cellphone = "";
        if (txtmobile1.Text.Length > 1)
        {
            cellphone = txtmobile1.Text;
            if (txtmobile2.Text.Length > 1)
            {
                cellphone = cellphone + ";" + txtmobile2.Text;
                if (txtmobile3.Text.Length > 1)
                {
                    cellphone = cellphone + ";" + txtmobile3.Text;
                }
            }
        }
        return cellphone;
    }

    #endregion

    #region 取得固定电话号

    private string getTelePhone()
    {
        string telephone = "";

        if (txtPhone12.Text.Length > 1)//第1部电话
        {
            if (txtPhone13.Text.Length < 1)
            {
                telephone = txtPhone11.Text + "-" + txtPhone12.Text;
            }
            else
            {
                telephone = txtPhone11.Text + "-" + txtPhone12.Text + "-" + txtPhone13.Text;
            }
            if (txtPhone22.Text.Length > 1)//第2部电话
            {

                if (txtPhone23.Text.Length < 1)
                {
                    telephone = telephone + ";" + txtPhone21.Text + "-" + txtPhone22.Text;
                }
                else
                {
                    telephone = telephone + ";" + txtPhone21.Text + "-" + txtPhone22.Text + "-" + txtPhone23.Text;
                }
                if (txtPhone32.Text.Length > 1)//第3部电话
                {
                    if (txtPhone33.Text.Length < 1)
                    {
                        telephone = telephone + ";" + txtPhone31.Text + "-" + txtPhone32.Text;
                    }
                    else
                    {
                        telephone = telephone + ";" + txtPhone31.Text + "-" + txtPhone32.Text + "-" + txtPhone33.Text;
                    }
                    if (txtPhone42.Text.Length > 1)//第4部电话
                    {

                        if (txtPhone43.Text.Length < 1)
                        {
                            telephone = telephone + ";" + txtPhone41.Text + "-" + txtPhone42.Text;
                        }
                        else
                        {
                            telephone = telephone + ";" + txtPhone41.Text + "-" + txtPhone42.Text + "-" + txtPhone43.Text;
                        }
                        if (txtPhone52.Text.Length > 1)//第5部电话
                        {
                            if (txtPhone53.Text.Length < 1)
                            {
                                telephone = telephone + ";" + txtPhone51.Text + "-" + txtPhone52.Text;
                            }
                            else
                            {
                                telephone = telephone + ";" + txtPhone51.Text + "-" + txtPhone52.Text + "-" + txtPhone53.Text;
                            }
                        }
                    }
                }
            }
        }
        return telephone;
    }

    #endregion

    #region 设置参数

    #region 设定移动电话号

    private void SetCellPhoneNo(string cellphoneno)
    {
        if (string.IsNullOrEmpty(cellphoneno))
        {
            txtHideCellPhoneNo.Value = "0";
        }
        else
        {
            TextBox[] cellPhones = new TextBox[3];
            cellPhones[0] = txtmobile1;
            cellPhones[1] = txtmobile2;
            cellPhones[2] = txtmobile3;
            string[] tempCellPhoneNo = cellphoneno.Split(';');
            int sumCellPhone = tempCellPhoneNo.Length;
            if (sumCellPhone > 0)
            {
                for (int i = 0; i < sumCellPhone; i++)
                {
                    cellPhones[i].Text = tempCellPhoneNo[i];
                }
            }
            txtHideCellPhoneNo.Value = sumCellPhone.ToString();
        }

    }

    #endregion

 

    #region 设定固定电话号

    private void SetTelePhoneNo(string telephoneno)
    {
        if (string.IsNullOrEmpty(telephoneno))
        {
            txtHideTelePhoneNo.Value = "0";
        }
        else
        {
            TextBox[] telePhonesareacode = new TextBox[5];
            telePhonesareacode[0] = txtPhone11;
            telePhonesareacode[1] = txtPhone21;
            telePhonesareacode[2] = txtPhone31;
            telePhonesareacode[3] = txtPhone41;
            telePhonesareacode[4] = txtPhone51;

            TextBox[] telePhonesLocalNumber = new TextBox[5];
            telePhonesLocalNumber[0] = txtPhone12;
            telePhonesLocalNumber[1] = txtPhone22;
            telePhonesLocalNumber[2] = txtPhone32;
            telePhonesLocalNumber[3] = txtPhone42;
            telePhonesLocalNumber[4] = txtPhone52;

            TextBox[] telePhonesSubNumber = new TextBox[5];
            telePhonesSubNumber[0] = txtPhone13;
            telePhonesSubNumber[1] = txtPhone23;
            telePhonesSubNumber[2] = txtPhone33;
            telePhonesSubNumber[3] = txtPhone43;
            telePhonesSubNumber[4] = txtPhone53;

            string[] tempTelePhoneNo = telephoneno.Split(';');
            int sumTelePhone = tempTelePhoneNo.Length;
            if (sumTelePhone > 0)
            {
                for (int i = 0; i < sumTelePhone; i++)
                {
                    string[] eachPhoneNo = tempTelePhoneNo[i].Split('-');
                    int sumEachPhoneNo = eachPhoneNo.Length;
                    if (sumEachPhoneNo == 1)
                    {
                        telePhonesareacode[i].Text = eachPhoneNo[0];
                    }
                    else if (sumEachPhoneNo == 2)
                    {
                        telePhonesareacode[i].Text = eachPhoneNo[0];
                        telePhonesLocalNumber[i].Text = eachPhoneNo[1];
                    }
                    else if (sumEachPhoneNo == 3)
                    {
                        telePhonesareacode[i].Text = eachPhoneNo[0];
                        telePhonesLocalNumber[i].Text = eachPhoneNo[1];
                        telePhonesSubNumber[i].Text = eachPhoneNo[2];
                    }
                }
            }
            txtHideTelePhoneNo.Value = sumTelePhone.ToString();
        }
    }

    #endregion
    #endregion

    #region 审核发布状态
    private void issa(SecondHouse sh,string x)
    {
        User user1 = this.GetUser();
        if (user1 == null || user1.UserType == UserType.NotLogin)
        {
            Response.Redirect("/UserLogin.aspx");
        }
       int infotype = -1;
        //为infotype赋值
       switch(x)
       {
           case "00":
               infotype = 0;
               break;
           case "10":
               infotype = 1;
               break;
           case "20":
               infotype = 2;
               break;
           case "30":
               infotype = 3;
               break;
       }
       int looktype;
        //为房源信息范围赋值s
       if (user1.UserType == UserType.TopStaff)
       {
           looktype = -1;
       }
       else
       {
           looktype = 0;
       }
        if (txtcheckjs.Text == "1")
        {
            if (!string.IsNullOrEmpty(txtinfstat.Value))
            {
                pageparameter[0] = Convert.ToInt32(txtinfstat.Value);
            }
            if (pageparameter[0] < 4)
            {
                issues();
                shoadd(sho);
                sh.SecondHouseOtherInfo.Add(sho);
                sheadd(she);
                sh.SecondHouseEquipment.Add(she);
                int wzd = vldh.CalculateSecondhouseIntegrity(sh);
                sh.Integrity = wzd;
                if (mc.AddSecondHandHouseInfo(sh) > 0)
                {
                    CacheHandle.RemoveApproximateItemsFromCache("SHListByCAS");
                    CacheHandle.RemoveFromSessionCache("SecondHoufoCount", true);
                    Response.Write("<script>alert('发布成功!');window.location='listsecondhouse.aspx?infotype=" + infotype.ToString().ConvertToEncryptString() + "&infostate=" + Convert.ToString(0).ConvertToEncryptString() + "&looktype=" + Convert.ToString(looktype).ConvertToEncryptString() + "';</script>");
                  
                }
                else
                {
                    Response.Write("<script>alert('发布失败,请稍候再试或咨询客服。');window.location='listsecondhouse.aspx?infotype=" + infotype.ToString().ConvertToEncryptString() + "&infostate=" + Convert.ToString(0).ConvertToEncryptString() + "&looktype=" + Convert.ToString(looktype).ConvertToEncryptString() + "';</script>");
                }
            }
            else if (pageparameter[0] > 3 && pageparameter[0] < 8)
            {
                mod2();
                int wzd = vldh.CalculateSecondhouseIntegrity(sh);
                sh.Integrity = wzd;
                if (mc.ApplyChange() == true)
                {
                    CacheHandle.RemoveApproximateItemsFromCache("SHListByCAS");
                    CacheHandle.RemoveFromSessionCache("SecondHoufoCount", true);
                    Response.Write("<script>alert('修改成功!');window.location='listsecondhouse.aspx?infotype=" + infotype.ToString().ConvertToEncryptString() + "&infostate=" + Convert.ToString(0).ConvertToEncryptString() + "&looktype=" + Convert.ToString(looktype).ConvertToEncryptString() + "';</script>");
                }
                else
                {
                    Response.Write("<script>alert('修改失败,请稍候再试或咨询客服。');window.location='listsecondhouse.aspx?infotype=" + infotype.ToString().ConvertToEncryptString() + "&infostate=" + Convert.ToString(0).ConvertToEncryptString() + "&looktype=" + Convert.ToString(looktype).ConvertToEncryptString() + "';</script>");
                }
            }
        }
    
    }
    #endregion

    protected void DDLSectionID_SelectedIndexChanged(object sender, EventArgs e)
    {
        DDLBlockHousing.LoadHousingBlockBySectionID(Convert.ToInt32(DDLSectionID.SelectedValue));
    }

}

原创粉丝点击