Esempio n. 1
0
        /// <summary>
        /// 添加企业信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int AddStation(Entity.Station entity)
        {
            int            iReturn = 0;
            DBOperatorBase db      = new DataBase();

            IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory();
            SqlTransactionHelper  thelper   = new SqlTransactionHelper(Config.constr);
            IDbTransaction        trans     = thelper.StartTransaction();
            DrawSample            drawop    = new DrawSample();

            try
            {
                IDbDataParameter[] prams =
                {
                };
                string instr = @"insert into t_委托单位(单位全称,单位法人代码,单位曾用名全称,单位详细地址,所属镇街道,邮政编码,法定代表人,tel1,mobile1,市府网1,环保分管人,tel2,mobile2,市府网2,环保负责人,tel3,mobile3,市府网3,传真号码,电子邮箱,行业类别,kzlevel) values('"
                               + entity.qymc + "','"
                               + entity.frdm + "','"
                               + entity.cname + "','"
                               + entity.dz + "','"
                               //+ entity.jgdm + "','"
                               + entity.sd + "','"
                               + entity.yzbm + "','"
                               + entity.frdb + "','"
                               + entity.tel1 + "','"
                               + entity.mobile1 + "','"
                               + entity.zfw1 + "','"
                               + entity.hbfg + "','"
                               + entity.tel2 + "','"
                               + entity.mobile2 + "','"
                               + entity.zfw2 + "','"
                               + entity.hbfz + "','"
                               + entity.tel3 + "','"
                               + entity.mobile3 + "','"
                               + entity.zfw3 + "','"
                               + entity.czhm + "','" + entity.email + "','" + entity.industry + "'," + entity.control + ")";
                iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, instr, prams);
                if (iReturn <= 0)
                {
                    throw new Exception("单位保存失败!");
                }

                thelper.CommitTransaction(trans);
                iReturn = 1;
            }
            catch (Exception ex)
            {
                thelper.RollTransaction(trans);

                iReturn = -1;
            }
            finally
            {
                if (db.Conn != null)
                {
                    db.Conn.Close();
                }
            }
            return(iReturn);
        }
Esempio n. 2
0
        /// <summary>
        /// 编辑企业信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int UpdateStation(Entity.Station entity)
        {
            int            iReturn = 0;
            DBOperatorBase db      = new DataBase();

            IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory();
            SqlTransactionHelper  thelper   = new SqlTransactionHelper(Config.constr);
            IDbTransaction        trans     = thelper.StartTransaction();
            DrawSample            drawop    = new DrawSample();

            try
            {
                IDbDataParameter[] prams =
                {
                };
                string      checkstr = "select 1 from [dbo].[t_委托单位] where 单位全称='" + entity.qymc + "' and ID!='" + entity.ID + "'";
                IDataReader idr      = db.ExecuteReader(Config.constr, CommandType.Text, checkstr, prams);
                int         i        = 0;
                while (idr.Read())
                {
                    i++;
                    break;
                }

                if (i > 0)
                {
                    iReturn = 0;
                }
                else
                {
                    string upstrwt = "update t_委托单位 set 单位全称='" + entity.qymc + "',单位法人代码='" + entity.frdm + "',单位曾用名全称='"
                                     + entity.cname + "',单位详细地址='"
                                     + entity.dz + "',所属镇街道='"
                                     + entity.sd + "',邮政编码='"
                                     + entity.yzbm + "',法定代表人='"
                                     + entity.frdb + "',tel1='"
                                     + entity.tel1 + "',mobile1='"
                                     + entity.mobile1 + "',市府网1='"
                                     + entity.zfw1 + "',环保分管人='"
                                     + entity.hbfg + "',tel2='"

                                     + entity.tel2 + "',mobile2='"
                                     + entity.mobile2 + "',市府网2='"
                                     + entity.zfw2 + "',环保负责人='"
                                     + entity.hbfz + "',tel3='"
                                     + entity.tel3 + "',mobile3='"
                                     + entity.mobile3 + "',市府网3='"
                                     + entity.zfw3 + "',传真号码='" + entity.czhm
                                     + "',电子邮箱='" + entity.email + "',行业类别='"
                                     + entity.industry + "',kzlevel="
                                     + entity.control

                                     + " where id = '" + entity.ID + "'";
                    iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, upstrwt, prams);
                    if (iReturn < 0)
                    {
                        throw new Exception("编辑保存失败!");
                    }
                    thelper.CommitTransaction(trans);
                    iReturn = 1;
                }
            }
            catch (Exception ex)
            {
                thelper.RollTransaction(trans);

                iReturn = 0;
            }
            finally
            {
                if (db.Conn != null)
                {
                    db.Conn.Close();
                }
            }
            return(iReturn);
        }