예제 #1
0
        /// <summary>
        /// 用事务导入品目对应信息
        /// </summary>
        /// <param name="excel"></param>
        /// <param name="ProjectId"></param>
        /// <param name="UserId"></param>
        /// <param name="success"></param>
        /// <param name="failure"></param>
        /// <returns></returns>
        public int LeadExcel(string excel, int ProjectId, int UserId, out string result, int isUseTypeCompare)
        {
            List <string> listsql    = new List <string>();
            List <string> listTypeId = new List <string>();
            DataTable     dt_new     = ImportExcel("select 客户一级品目,客户二级品目,客户三级品目,客户池子编号,领先类别名称,领先类别编码,投标承诺折扣 from [Sheet1$]", excel);

            result = "";
            int rows = dt_new.Rows.Count;

            if (rows > 0)
            {
                for (int i = 0; i < dt_new.Rows.Count; i++)
                {
                    string categoryCode = dt_new.Rows[i]["客户池子编号"].ToString();
                    string category1    = dt_new.Rows[i]["客户一级品目"].ToString();
                    string category2    = dt_new.Rows[i]["客户二级品目"].ToString();
                    string category     = dt_new.Rows[i]["客户三级品目"].ToString();
                    string typeId       = dt_new.Rows[i]["领先类别编码"].ToString();
                    string typeName     = dt_new.Rows[i]["领先类别名称"].ToString();
                    string discount     = dt_new.Rows[i]["投标承诺折扣"].ToString();
                    bool   IsNullCheck  = false;
                    if (isUseTypeCompare == 1 && category1 != "" && category != "" && categoryCode != "" && typeId != "" && typeName != "")
                    {
                        IsNullCheck = true;
                    }
                    else if (isUseTypeCompare == 2 && category1 != "" && category != "" && typeId != "" && typeName != "")
                    {
                        IsNullCheck = true;
                    }

                    if (IsNullCheck)
                    {
                        if (!listTypeId.Contains(typeId))
                        {
                            string sql = "insert into TPI_Category(ProjectId,Category1,Category2,Category,TypeName,TypeId,CategoryCode,UserId,Discount) values ('" + ProjectId + "','" + category1 + "','" + category2 + "','" + category + "','" + typeName + "','" + typeId + "','" + categoryCode + "','" + UserId + "','" + discount + "')";
                            listsql.Add(sql);
                            listTypeId.Add(typeId);
                        }
                        else
                        {
                            result += "TypeId为" + typeId + "的有重复值 /r/n";//typeid  duplicates.
                        }
                    }
                    else
                    {
                        result += "客户一级品目或客户三级品目或领先类别编码或领先类别名称有空值,请详细阅读操作手册!";  //category1 || category||  typeId || typeName has null
                    }
                }
            }

            if (result != "")
            {
                return(-1);
            }
            else
            {
                return(m_dbo.ExecNoQuerySqlTran(listsql));
            }
        }