//修改
 public int GovernmentUpdate(Tz888.Model.Register.GovernmentInfoModel model,
                             Tz888.Model.Register.OrgContactModel ContactModel,
                             List <Tz888.Model.Register.OrgContactMan> ContactManModels,
                             List <Tz888.Model.MemberResourceModel> infoResourceModels)
 {
     return(dal.GovernmentUpdate(model, ContactModel, ContactManModels, infoResourceModels));
 }
Пример #2
0
        //修改
        public int GovernmentUpdate(Tz888.Model.Register.GovernmentInfoModel model,
                                    Tz888.Model.Register.OrgContactModel ContactModel,
                                    List <Tz888.Model.Register.OrgContactMan> ContactManModels,
                                    List <Tz888.Model.MemberResourceModel> infoResourceModels)
        {
            SqlParameter[] parameters =
            {
                #region 基本信息
                new SqlParameter("@GovernmentID",     SqlDbType.Int,       4),
                new SqlParameter("@LoginName",        SqlDbType.Char,     16),
                new SqlParameter("@GovernmentName",   SqlDbType.VarChar, 200),
                new SqlParameter("@GovAbout",         SqlDbType.VarChar,  -1),
                new SqlParameter("@GovAboutBrief",    SqlDbType.VarChar,  -1),
                new SqlParameter("@SubjectType",      SqlDbType.Char,     10),
                new SqlParameter("@CountryCode",      SqlDbType.Char,     10),
                new SqlParameter("@ProvinceID",       SqlDbType.Char,     10),
                new SqlParameter("@CityID",           SqlDbType.Char,     10),
                new SqlParameter("@CountyID",         SqlDbType.Char,     10),
                new SqlParameter("@AuditingStatus",   SqlDbType.TinyInt,   1),
                new SqlParameter("@hits",             SqlDbType.Int,       4),
                new SqlParameter("@ExhibitionHall",   SqlDbType.VarChar, 100),
                new SqlParameter("@remark",           SqlDbType.VarChar, 100),
                #endregion
                #region 联系方式
                new SqlParameter("@OrganizationName", SqlDbType.VarChar, 100),
                new SqlParameter("@Name",             SqlDbType.VarChar,  20),
                new SqlParameter("@Career",           SqlDbType.VarChar,  20),
                new SqlParameter("@TelCountryCode",   SqlDbType.Char,      3),
                new SqlParameter("@TelStateCode",     SqlDbType.Char,      4),
                new SqlParameter("@TelNum",           SqlDbType.VarChar,  60),
                new SqlParameter("@FaxCountryCode",   SqlDbType.Char,      3),
                new SqlParameter("@FaxStateCode",     SqlDbType.Char,      4),
                new SqlParameter("@FaxNum",           SqlDbType.VarChar,  60),
                new SqlParameter("@Email",            SqlDbType.VarChar,  50),
                new SqlParameter("@Mobile",           SqlDbType.VarChar,  30),
                new SqlParameter("@address",          SqlDbType.VarChar, 100),
                new SqlParameter("@PostCode",         SqlDbType.VarChar,  10),
                new SqlParameter("@Website",          SqlDbType.VarChar, 200),
                new SqlParameter("@IsDel",            SqlDbType.Bit,       1),
                new SqlParameter("@remark1",          SqlDbType.VarChar, 100)
                #endregion
            };
            parameters[0].Value  = model.GovernmentID;
            parameters[1].Value  = model.LoginName;
            parameters[2].Value  = model.GovernmentName;
            parameters[3].Value  = model.GovAbout;
            parameters[4].Value  = model.GovAboutBrief;
            parameters[5].Value  = model.SubjectType;
            parameters[6].Value  = model.CountryCode;
            parameters[7].Value  = model.ProvinceID;
            parameters[8].Value  = model.CityID;
            parameters[9].Value  = model.CountyID;
            parameters[10].Value = model.AuditingStatus;
            parameters[11].Value = model.Hits;
            parameters[12].Value = model.ExhibitionHall;
            parameters[13].Value = model.remark;

            parameters[14].Value = model.GovernmentName;
            parameters[15].Value = ContactModel.Name;
            parameters[16].Value = ContactModel.Career;
            parameters[17].Value = ContactModel.TelCountryCode;
            parameters[18].Value = ContactModel.TelStateCode;
            parameters[19].Value = ContactModel.TelNum;
            parameters[20].Value = ContactModel.FaxCountryCode;
            parameters[21].Value = ContactModel.FaxStateCode;
            parameters[22].Value = ContactModel.FaxNum;
            parameters[23].Value = ContactModel.Email;
            parameters[24].Value = ContactModel.Mobile;
            parameters[25].Value = ContactModel.address;
            parameters[26].Value = ContactModel.PostCode;
            parameters[27].Value = ContactModel.Website;
            parameters[28].Value = ContactModel.IsDel;
            parameters[29].Value = ContactModel.remark;


            int rowsAffected;
            int GovernmentID;

            using (SqlConnection sqlConn = DbHelperSQL.GetSqlConnection())
            {
                sqlConn.Open();
                SqlTransaction sqlTran = sqlConn.BeginTransaction();
                try
                {
                    //插入信息
                    DbHelperSQL.RunProcedure(sqlConn, sqlTran, "UP_GovernmentTab_Update", parameters, out rowsAffected);
                    if (rowsAffected > 0)
                    {
                        GovernmentID = (int)parameters[0].Value;
                    }
                    else
                    {
                        GovernmentID = 0;
                    }
                    //添加多个联系人(检查原联系人列表中是否己存在 LoginName = model.LoginName的联系人,
                    //如果己存就,将先删除全部后重新添加,obj2.InsertContactMan代码逻辑中)
                    Tz888.SQLServerDAL.Register.common obj2 = new common();
                    if (ContactManModels != null)
                    {
                        for (int i = 0; i < ContactManModels.Count; i++)
                        {
                            if (ContactManModels[i].Name != "" && ContactManModels[i].Name != null)
                            {
                                foreach (Tz888.Model.Register.OrgContactMan cm in ContactManModels)
                                {
                                    if (!obj2.InsertContactMan(sqlConn, sqlTran, cm))
                                    {
                                        throw new Exception();
                                    }
                                }
                            }
                        }
                    }
                    if (infoResourceModels != null)
                    {
                        //图片资源
                        Tz888.SQLServerDAL.MemberResourceDAL obj3 = new MemberResourceDAL();
                        foreach (Tz888.Model.MemberResourceModel modelRes in infoResourceModels)
                        {
                            modelRes.LoginName = model.LoginName;
                            int i = obj3.Add(sqlConn, sqlTran, modelRes);
                        }
                    }
                    sqlTran.Commit();
                }
                catch
                {
                    sqlTran.Rollback();
                    GovernmentID = -1;
                }
                finally
                {
                    sqlConn.Close();
                }
            }

            return(GovernmentID);
        }
    protected void buSend_Click(object sender, ImageClickEventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }
        obj  = new GovernmentRegisterBLL();
        mode = new GovernmentInfoModel();

        List <Tz888.Model.Common.IndustryModel>   industryModels   = new List <Tz888.Model.Common.IndustryModel>();   //行业实体列表
        List <Tz888.Model.Register.OrgContactMan> ContactManModels = new List <Tz888.Model.Register.OrgContactMan>(); //联系人实体列表

        Tz888.Model.Register.OrgContactModel   ContactModel       = new Tz888.Model.Register.OrgContactModel();       //创建信息联系方式主体
        List <Tz888.Model.MemberResourceModel> infoResourceModels = new List <Tz888.Model.MemberResourceModel>();     //图片资料

        //基本信息
        mode.LoginName      = Page.User.Identity.Name;
        mode.GovernmentName = tbGovernmentName.Text;
        mode.GovAbout       = Tz888.Common.Utility.PageValidate.TxtToHtml(tbGovAbout.Text);//公司介绍
        mode.GovAboutBrief  = "";
        mode.SubjectType    = ddlSubjectType.SelectedValue;
        mode.CountryCode    = this.ZoneSelectControl1.CountryID;
        mode.ProvinceID     = this.ZoneSelectControl1.ProvinceID;
        mode.CityID         = this.ZoneSelectControl1.CityID;
        mode.CountyID       = this.ZoneSelectControl1.CountyID;
        mode.AuditingStatus = 0;//审核状态



        //if (mode.ProvinceID == "" && mode.CountryCode.Trim() == "CN")
        //{
        //    Tz888.Common.MessageBox.Show(this.Page, "请选取更详细的注册地址");
        //    return;
        //}

        mode.ExhibitionHall = tbExhibitionHall.Text; //展厅
        mode.Hits           = 0;                     //点击数


        mode.remark = "";

        //联系信息
        ContactModel     = this.OrgContactControl1.OrgContact;  //联系信息
        ContactManModels = this.OrgContactControl1.ContactMans; //联系人


        if (ContactModel.Name.Trim() == "" && ContactModel.TelNum.Trim() == "" && ContactModel.Mobile.Trim() == "")
        {
            Tz888.Common.MessageBox.Show(this.Page, "请输入完整的联系信息!");
            return;
        }

        //将已上传的图片从临时目录迁移到正式目录
        //infoResourceModels = Tz888.Common.InfoResourceManage.MemberImageTransfer("Image", "GovernmentRegister", Tz888.Common.ResourceType.Image, Tz888.Common.MemberResourceProperty.RP0, ImageUploadControl1.InfoList);
        infoResourceModels = ImageUploadControl1.InfoList;

        //展厅
        if (this.ViewState["WebInfo"].ToString() == "1")
        {
            bool IsVip = false;
            if (Page.User.IsInRole("GT1002"))
            {
                IsVip = true;
            }

            SelfCreateWeb.Model.DatabaseOperationStatus dos = new SelfCreateWeb.BLL.BSelfCreateWebInfo().AddSelfCreateWebInfo(new SelfCreateWeb.Model.MSelfCreateWebInfo(0, Page.User.Identity.Name, "", 0, tbExhibitionHall.Text.Trim(), DateTime.Now, DateTime.Now, 0, ""), new SelfCreateWeb.ParameterMap.PSelfCreateWebInfo(false, true, false, false, true, false, false, false, false));
            if (dos == SelfCreateWeb.Model.DatabaseOperationStatus.Success)
            {
                new SelfCreateWeb.BLL.BSelfCreateWebInfo().InitPageParameter(Page.User.Identity.Name, IsVip, true);
            }
            else
            {
                Tz888.Common.MessageBox.Show(this.Page, "此域名不可用,请重新输入!");
                return;
            }
        }

        int type = 0;

        if (Page.User.IsInRole("GT1001"))   //普通会员

        {
            type = 0;
        }
        else
        {
            type = 1;
        }

        int GovernmentId = Convert.ToInt32(ViewState["GovermentID"].ToString());

        if (GovernmentId == 0)
        {
            int rv = obj.GovernmentAdd(mode, ContactModel, ContactManModels, infoResourceModels);
            if (rv > 0)
            {
                Response.Redirect("OrgRegisterSucceed.aspx?type=" + type + "&reg=Gov_Add&web=" + tbExhibitionHall.Text + ".gov.");
            }
            else
            {
                Tz888.Common.MessageBox.Show(this.Page, "此域名不可用,请重新输入!");
                return;
            }
        }
        else
        {
            mode.GovernmentID = GovernmentId;
            int rv = obj.GovernmentUpdate(mode, ContactModel, ContactManModels, infoResourceModels);
            Response.Redirect("OrgRegisterSucceed.aspx?type=" + type + "&reg=Gov_Update&web=" + tbExhibitionHall.Text + ".gov.");
        }
    }