/// <summary>
 /// 检查是否含有该收款方式
 /// </summary>
 /// <param name="modeName"></param>
 /// <returns></returns>
 public static bool CheckHave(string modeName)
 {
     sql = string.Format(@" select * from MakeCollectionsMode where MakeCollectionsMode='{0}'", modeName);
     return(SqlHelper.GetTable(sql, ref error).Rows.Count >= 1 ? true : false);
 }
Пример #2
0
        /// <summary>
        /// 批量导入历史贸易报价单
        /// </summary>
        /// <param name="tods"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool BacthAddQuoteInfoTradingForListory(FileUpload FU_Excel, HttpServerUtility server, string userId, ref string error)
        {
            string sqlTemp = string.Format(" delete T_TradingQuoteDetail_Temp where userId='{0}' ", userId);

            SqlHelper.ExecuteSql(sqlTemp, ref error);

            DataSet ds = ToolManager.ImpExcel(FU_Excel, server);

            if (ds == null)
            {
                error = "选择的文件为空或不是标准的Excel文件!";
                return(false);
            }
            DataTable dt        = ds.Tables[0];
            int       i         = 0;
            string    tempError = string.Empty;

            if (dt.Rows.Count <= 0)
            {
                error = "没有要添加的数据";
                return(false);
            }
            foreach (DataRow dr in dt.Rows)
            {
                tempError = "";
                if (!AddQuoteInfoTradingForListory(dr, ref tempError, userId))
                {
                    i++;
                    error += string.Format("添加失败:原因--{0}<br/>", tempError);
                }
            }
            bool result = i > 0 ? false : true;

            if (!result)
            {
                error = string.Format("添加成功{0}条,添加失败{1}条。<br/>{2}", (dt.Rows.Count - i).ToString(), i.ToString(), error);
            }

            //=================================以下将临时表中的数据导入报价单======================================

            List <string> sqls     = new List <string>();
            string        sql      = string.Format(@" select userId,CustomerId,ContactId,QuoteTime from T_TradingQuoteDetail_Temp 
where userId='{0}'
group by userId,CustomerId,ContactId,QuoteTime ", userId);
            DataTable     dtNew    = SqlHelper.GetTable(sql);
            string        bjNumber = "";
            int           h        = 1;

            foreach (DataRow drNew in dtNew.Rows)
            {
                bjNumber = "MYBJ" + DateTime.Now.AddSeconds(h).ToString("yyyyMMddHHmmss");
                //开一个报价单
                sql = string.Format(@"insert into QuoteInfo(QuoteNumber,QuoteTime,QuoteType,CustomerId ,ContactId,CreateDateTime ,QuoteUser )
values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", bjNumber, drNew["QuoteTime"], "贸易报价单",
                                    drNew["CustomerId"], drNew["ContactId"], DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), userId);
                sqls.Add(sql);
                sql = string.Format(@" insert into  TradingQuoteDetail (QuoteNumber,ProductNumber,CustomerMaterialNumber,FixedLeadTime
 ,UnitPrice,MinPackage,MinMOQ,MaterialDescription,DW,Remark,SupplierMaterialNumber)
 select '{4}',MaterialNumber,CustomerMaterialNumber,FixedLeadTime
 ,UnitPrice,MinPackage,MinMOQ,MaterialDescription, DW,Remark ,SupplierMaterialNumber from T_TradingQuoteDetail_Temp 
 where  userId='{0}' and  CustomerId='{1}' and ContactId='{2}' 
and  QuoteTime='{3}' ", userId, drNew["CustomerId"], drNew["ContactId"], drNew["QuoteTime"], bjNumber);
                sqls.Add(sql);
                h++;
            }
            string tempErrorNew = string.Empty;

            SqlHelper.BatchExecuteSql(sqls, ref tempErrorNew);
            return(result);
        }