示例#1
0
        /// <summary>
        /// 更新企业信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pictures"></param>
        /// <returns></returns>
        public int UpdateCompanyModel(CompanyModel model, string pictures)
        {
            var sqlStr = new StringBuilder("update `settled_info` set ");
            sqlStr.Append(Helper.CreateField(model).Trim().TrimEnd(','));
            sqlStr.Append(" where innerid = @innerid");

            using (var conn = Helper.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {
                    conn.Execute(sqlStr.ToString(), model, tran);

                    const string delPic = "delete from settled_picture where settid=@settid;";
                    conn.Execute(delPic, new { settid = model.Innerid }, tran);

                    const string addPic = "insert into settled_picture (innerid, settid, typeid, path, sort, createdtime) values (@innerid, @settid, @typeid, @path, @sort, @createdtime);";
                    var i = 1;
                    foreach (var item in pictures.Split(','))
                    {
                        conn.Execute(addPic, new
                        {
                            innerid = Guid.NewGuid().ToString(),
                            settid = model.Innerid,
                            typeid = 0,
                            path = item,
                            sort = i,
                            createdtime = DateTime.Now
                        }, tran);
                        i++;
                    }

                    tran.Commit();
                    return 1;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    return 0;
                }
            }
        }
示例#2
0
        /// <summary>
        /// 更新企业信息(后台系统)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateCompanyModel(CompanyModel model)
        {
            var sqlStr = new StringBuilder("update `settled_info` set ");
            sqlStr.Append(Helper.CreateField(model).Trim().TrimEnd(','));
            sqlStr.Append(" where innerid = @innerid");

            using (var conn = Helper.GetConnection())
            {
                try
                {
                    conn.Execute(sqlStr.ToString(), model);
                    return 1;
                }
                catch (Exception ex)
                {
                    return 0;
                }
            }
        }
示例#3
0
        /// <summary>
        /// 导入公司
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public int ImportCompany(DataTable dt)
        {
            const string sql = @"INSERT INTO settled_info
                                (innerid, companyname, address, opername, originalregistcapi, scope, companystatus, officephone, spare1, spare2, createrid, createdtime, modifierid, modifiedtime)
                                VALUES (@innerid, @companyname, @address, @opername, @originalregistcapi, @scope, @companystatus, @officephone, @spare1, @spare2, @createrid, @createdtime, @modifierid, @modifiedtime);";
            using (var conn = Helper.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {
                    var model = new CompanyModel();
                    foreach (DataRow row in dt.Rows)
                    {
                        model.CompanyName = row["CompanyName"].ToString();
                        model.Address = row["Address"].ToString();
                        model.OperName = row["OperName"].ToString();
                        model.OriginalRegistCapi = row["OriginalRegistCapi"].ToString();
                        model.Scope = row["Scope"].ToString();
                        model.CompanyStatus = row["CompanyStatus"].ToString();
                        model.OfficePhone = row["OfficePhone"].ToString();
                        model.Innerid = Guid.NewGuid().ToString();
                        model.Createdtime = DateTime.Now;
                        model.Createrid = "";
                        conn.Execute(sql, model, tran);
                    }

                    tran.Commit();
                    return 1;
                }
                catch (Exception ex)
                {
                    LoggerFactories.CreateLogger().Write("导入公司数据失败:" + ex.Message, TraceEventType.Information);
                    tran.Rollback();
                    return 0;
                }
            }
        }