Пример #1
0
        //修改
        public int EnterpriseUpdate(Tz888.Model.Register.EnterpriseInfoModel model,
                                    Tz888.Model.Register.OrgContactModel ContactModel,
                                    List <Tz888.Model.Register.OrgContactMan> ContactManModels,
                                    List <Tz888.Model.MemberResourceModel> infoResourceModels)
        {
            SqlParameter[] parameters =
            {
                #region  公司基本信息
                new SqlParameter("@EnterpriseID",     SqlDbType.Int,         4),
                new SqlParameter("@LoginName",        SqlDbType.Char,       16),
                new SqlParameter("@EnterpriseName",   SqlDbType.VarChar,   200),
                new SqlParameter("@ComAbout",         SqlDbType.VarChar,    -1),
                new SqlParameter("@ComAboutBrief",    SqlDbType.VarChar,    -1),
                new SqlParameter("@SetComTypeID",     SqlDbType.Char,       10),
                new SqlParameter("@Industrylist",     SqlDbType.Char,       10),
                new SqlParameter("@RegisterDate",     SqlDbType.DateTime),
                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("@currency",         SqlDbType.Char,       10),
                new SqlParameter("@RegCapital",       SqlDbType.Float,       8),
                new SqlParameter("@MainProduct",      SqlDbType.VarChar,    30),
                new SqlParameter("@RequirInfo",       SqlDbType.Char,       30),
                new SqlParameter("@AuditingStatus",   SqlDbType.TinyInt,     1),
                new SqlParameter("@ExhibitionHall",   SqlDbType.VarChar,   100),
                new SqlParameter("@hits",             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,        6),
                new SqlParameter("@TelStateCode",     SqlDbType.Char,        8),
                new SqlParameter("@TelNum",           SqlDbType.VarChar,   100),
                new SqlParameter("@FaxCountryCode",   SqlDbType.Char,        6),
                new SqlParameter("@FaxStateCode",     SqlDbType.Char,        8),
                new SqlParameter("@FaxNum",           SqlDbType.VarChar,   100),
                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.EnterpriseID;
            parameters[1].Value  = model.LoginName;
            parameters[2].Value  = model.EnterpriseName;
            parameters[3].Value  = model.ComAbout;
            parameters[4].Value  = model.ComAboutBrief;
            parameters[5].Value  = model.SetComTypeID;
            parameters[6].Value  = model.Industrylist;
            parameters[7].Value  = model.RegisterDate;
            parameters[8].Value  = model.CountryCode;
            parameters[9].Value  = model.ProvinceID;
            parameters[10].Value = model.CityID;
            parameters[11].Value = model.CountyID;
            parameters[12].Value = model.currency;
            parameters[13].Value = model.RegCapital;
            parameters[14].Value = model.MainProduct;
            parameters[15].Value = model.RequirInfo;
            parameters[16].Value = model.AuditingStatus;
            parameters[17].Value = model.ExhibitionHall;
            parameters[18].Value = model.hits;
            parameters[19].Value = model.remark;

            parameters[20].Value = model.EnterpriseName;; //ContactModel.Name;
            parameters[21].Value = ContactModel.Name;
            parameters[22].Value = ContactModel.Career;
            parameters[23].Value = ContactModel.TelCountryCode;
            parameters[24].Value = ContactModel.TelStateCode;
            parameters[25].Value = ContactModel.TelNum;
            parameters[26].Value = ContactModel.FaxCountryCode;
            parameters[27].Value = ContactModel.FaxStateCode;
            parameters[28].Value = ContactModel.FaxNum;
            parameters[29].Value = ContactModel.Email;
            parameters[30].Value = ContactModel.Mobile;
            parameters[31].Value = ContactModel.address;
            parameters[32].Value = ContactModel.PostCode;
            parameters[33].Value = ContactModel.Website;
            parameters[34].Value = ContactModel.IsDel;
            parameters[35].Value = ContactModel.remark;

            int rowsAffected;
            int EnterpriseID;

            using (SqlConnection sqlConn = DbHelperSQL.GetSqlConnection())
            {
                sqlConn.Open();
                SqlTransaction sqlTran = sqlConn.BeginTransaction();
                try
                {
                    //插入信息
                    DbHelperSQL.RunProcedure(sqlConn, sqlTran, "UP_EnterpriseTab_Update", parameters, out rowsAffected);
                    if (rowsAffected > 0)
                    {
                        EnterpriseID = (int)parameters[0].Value;
                    }
                    else
                    {
                        EnterpriseID = 0;
                    }

                    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)
                                {
                                    // model.ContactID = ContactID;
                                    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();
                    EnterpriseID = -1;
                }
                finally
                {
                    sqlConn.Close();
                }
            }
            return(EnterpriseID);
        }
Пример #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);
        }